Flutter Stripe

abhishek p
1 min readJul 12, 2023

--

Accepting payment through your app is a easy task now a days with emerging tools and providers.

In this blog let us try to get started with the integration of stripe payment in flutter app.

We will get started with adding dependency and then later on implementation aspects.

Let’s add stripe dependency and specify the version

flutter_stripe: (ver)

Create a account on stripe and try to generate publishable key which looks similar to that of

Stripe.publishableKey = “pk_test_51MWx8OAVMyklfe3CsjEzA1CiiY0XBTlQlGi4aNeGv8J1HUw4rgSavMTLzTwgn0XRlwoTVRFXyu2h00mRUeWmAf”;

Now let’s start with coding by creating a payment intent and specify the amount and currency code as well.

paymentIntent = await createPaymentIntent('10000', 'GBP');

Also we will add GPay as a payment method in our app using Stripe, so for which declare merchant country code and related details as shown.

var gpay = PaymentSheetGooglePay(merchantCountryCode: "GB", currencyCode: "GBP", testEnv: true);

Now try to initialize the payment sheet and make use of above declared info.

await Stripe.instance .initPaymentSheet( paymentSheetParameters: SetupPaymentSheetParameters( paymentIntentClientSecret: paymentIntent![ 'client_secret'], //Gotten from payment intent style: ThemeMode.light, merchantDisplayName: 'Abhi', googlePay: gpay)) .then((value) {});

Once the payment is done process the result and do further steps accordingly.

try { await Stripe.instance.presentPaymentSheet().then((value) { print("Payment Successfully"); }); } catch (e) { print('$e'); }

Find more information from below article

https://androidcoding.in/2023/02/03/stripe-payment/

--

--

abhishek p
abhishek p

Written by abhishek p

Android Developer @androidcoding.in

No responses yet