Unofficial PayMaya SDK for Flutter.
The plan for this package was to make it accessible to all platforms. But since PayMaya heavily relies on WebViews, The only possible way for this is to use WebView related packages such as webview_flutter, web_browser or Platform Channels.
PayMaya does not allow iframes to be loaded becasue the X-FRAME-OPTIONS
was set to deny
.
So the only solution is to make a redirect url that closes the window. that way,
you will have control thru your own logic.
Example:
/// returns payment link.
final redirectUrl = await payMayaSDK.createCheckout(checkout);
/// For Mobile:
/// From the webview of your page.
final bool result = await Navigator.push(context, YourWebView());
/// For Web:
/// Opens a new window to process payment.
if(await canLaunch(redirectUrl)){
await launch(redirectUrl);
}
Run this method first before invoking other methods.
final payMayaSDK = PayMayaSDK.init('pk-Mn124x69sda', isSandBox: true);
// inside of Future function
final checkout = PaymayaCheckout(
totalAmount: PaymayaAmount(
value: 700,
currency: 'PHP', // Default currency
),
items: [PaymayaItems(...)],
redirectUrl: PaymayaRedirectUrls(
success:'https://yourwebsite.com/success?id=65593',
failure:'https://yourwebsite.com/failure?id=65593',
cancel:'https://yourwebsite.com/cancel?id=65593',
),
requestReferenceNumber: '512396',
);
/// returns payment link.
final redirectUrl = await payMayaSDK.createCheckout(checkout);
TODOS:
- Webhooks. This is useful for flutter web to monitor the redirect callback url
- Custom Widget without using WebViews
- Wallet Link Widget
- Instructions for newly registered PayMaya Managers
- Support paymaya for non-flutter apps.