Flutter Stripe payment intent without secret-key

497 Views Asked by At

I'm trying to add Stripe payment intent in flutter but the issue is in the new library flutter_stripe: ^7.0.0 requires a secret key but the secret key is handled in the backend API(server).

I did it earlier with stripe_payment but now the library stopped working. So if you guys have any solution let me know. Thanks

1

There are 1 best solutions below

0
On BEST ANSWER
 final paymentIntent = await Stripe.instance.confirmPayment(
      clientSecret,
      const PaymentMethodParams.card(
        paymentMethodData: PaymentMethodData(),
      ));
  // ignore: use_build_context_synchronously
  ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
      content: Text('Success!: The payment was confirmed successfully!')));
  NavigationHelper.pushReplacement(context, BottomNavBody(data: widget.data,));

This is the code for doing payment intent while stripe secret key is handled by server side.