startPayment static method
Future<PaymentResponse>
startPayment({
- required BuildContext context,
- bool showServiceCharge = false,
- Widget builder(
- List<
PaymentMethod> methods, - LoadingState state,
- Future submit(
- PaymentMethod method
- List<
- required MyfatoorahRequest request,
- Widget? errorChild,
- Widget? successChild,
- AfterPaymentBehaviour afterPaymentBehaviour = AfterPaymentBehaviour.None,
- PreferredSizeWidget buildAppBar(
- BuildContext context
- List<
PaymentMethod> filterPaymentMethods(- List<
PaymentMethod> methods
- List<
- DirectPaymentCallBack? directPayment,
Implementation
static Future<PaymentResponse> startPayment({
required BuildContext context,
//If this is true service charge will be shown in subtitle defaults to false
bool showServiceCharge = false,
/// user this to build your own ui and then at the end call submit
/// submit method is future so you can wait it
/// the default is `ListView`
Widget Function(List<PaymentMethod> methods, LoadingState state,
Future Function(PaymentMethod method) submit)?
builder,
required MyfatoorahRequest request,
//Will be shown after failed payment `afterPaymentBehaviour must be none`
Widget? errorChild,
//Will be shown after success payment `afterPaymentBehaviour must be none`
Widget? successChild,
/// this will controls what happen after payment done
///
/// [AfterPaymentBehaviour.None] the default value , nothing will happen
///
/// [AfterPaymentBehaviour.AfterCallbackExecution] will pop after payment done and error or success callbacks finish
///
/// [AfterPaymentBehaviour.BeforeCallbackExecution] will pop after payment done and before error or success callbacks start
AfterPaymentBehaviour afterPaymentBehaviour = AfterPaymentBehaviour.None,
//Note if you override leading please use mayBePop instead of pop
PreferredSizeWidget Function(BuildContext context)? buildAppBar,
/// Filter payment methods after fetching it
List<PaymentMethod> Function(List<PaymentMethod> methods)?
filterPaymentMethods,
DirectPaymentCallBack? directPayment,
}) {
return showDialog(
context: context,
builder: (ctx) {
return Dialog(
child: _PaymentMethodsBuilder(
errorChild: errorChild,
directPayment: directPayment,
getAppBar: buildAppBar,
onResult: null,
successChild: successChild,
filterPaymentMethods: filterPaymentMethods,
afterPaymentBehaviour: afterPaymentBehaviour,
request: request,
showServiceCharge: showServiceCharge,
builder: builder,
),
);
},
).then((res) {
if (res is PaymentResponse)
return res;
else
throw Exception("The payment is not completed");
});
}