makePayment method
Future<PaymobResponse?>
makePayment(
- BuildContext context, {
- required String currency,
- required String amountInCents,
- void onPayment(
- PaymobResponse response
- required PaymentType paymentType,
- List? items,
- PaymobBillingData? billingData,
- required String authToken,
- required int orderID,
Second step: Make the payment
Implementation
Future<PaymobResponse?> makePayment(
BuildContext context, {
required String currency,
required String amountInCents,
void Function(PaymobResponse response)? onPayment,
required PaymentType paymentType,
List? items,
PaymobBillingData? billingData,
required String authToken,
required int orderID,
}) async {
final purchaseToken = await _getPurchaseToken(
authToken: authToken,
currency: currency,
orderID: orderID,
paymentType: paymentType,
amount: amountInCents,
billingData: billingData ?? PaymobBillingData(),
);
if (context.mounted) {
if (paymentType == PaymentType.card) {
final response = await PaymobIFrame.show(
context: context,
redirectURL: _iFrameURL + purchaseToken,
onPayment: onPayment,
);
return response;
} else {
final response = await PaymobIFrame.show(
context: context,
redirectURL: _mobileAccountiFrame + purchaseToken,
onPayment: onPayment,
);
return response;
}
}
return null;
}