openCheckoutCard method

Future<bool> openCheckoutCard(
  1. int amount,
  2. String desc,
  3. String clientPhone,
  4. String companyName,
  5. String currency,
  6. String stripeSecret,
  7. dynamic onSuccess(
    1. String
    ),
)

Implementation

Future<bool> openCheckoutCard(int amount, String desc, String clientPhone, String companyName, String currency, String stripeSecret,
    Function(String) onSuccess) async {


  Map<String, dynamic>? paymentIntent = await createPaymentIntent(amount.toString(), currency, stripeSecret);
  if (paymentIntent == null)
    return false;
  dprint(paymentIntent.toString());

  await Stripe.instance.initPaymentSheet(
    paymentSheetParameters: SetupPaymentSheetParameters(
      applePay: true,
      googlePay: true,
      style: ThemeMode.dark,
      testEnv: true,
      // merchantCountryCode: 'UK',
      merchantDisplayName: companyName,
      customerId: paymentIntent['customer'],
      paymentIntentClientSecret: paymentIntent['client_secret'],
      // customerEphemeralKeySecret: paymentIntent['ephemeralKey'],
    ),
  );

  await Stripe.instance.presentPaymentSheet(
      // parameters: PresentPaymentSheetParameters(
      //   clientSecret: paymentIntent['client_secret'],
      //   confirmPayment: true,
      // )
  );
  dprint("Payment $currency${amount/100} stripe:${paymentIntent["id"]}");
  onSuccess("Payment $currency${amount/100} stripe:${paymentIntent["id"]}");
  return true;
}