Does flutter package flutter_stripe require backend to process payments?

300

Solution 1

The other answer posted seems to be correct, Stripe integrations require a backend according to their documentation about integrating payments. The example provided in the flutter_stripe repo does have a portion about locally building the server required for testing (On a real application this would need to be secured on a backend):

Set up env vars for the flutter app and a local backend.
    Get your test Stripe API keys
    cp lib/.env.example.dart lib/.env.dart and set your Stripe publishable key.
    cp server/.env.example server/.env and set the variable values in your newly created .env file.

You can definitely implement the backend with Firebase. Here is a guide of implementing a sample integration with Firebase as a backend, which has more fleshed out steps and available code. It can help you see the process in general of implementation with the sample application.

Some of these sources are not GCP official so I cannot vouch for their accuracy.

Solution 2

Almost all Stripe integrations require a backend portion as that is where you perform most secret key operations, like creating a PaymentIntent or a CheckoutSession.

The /server directory you linked does create a sample test mode server to play around with and it has endpoints for creating PaymentIntents like this here.

I haven't used that package so cannot say but in general, your server portion is going to create a PaymentIntent and your Flutter app will confirm that PaymentIntent using your Stripe publishable key.

Share:
300
Dylan
Author by

Dylan

Updated on January 01, 2023

Comments

  • Dylan
    Dylan over 1 year

    I am currently trying to implement stripe payments in my flutter application, and it looks like the best/intended way to do this is wish flutter_stripe. I have implemented stripe payments through other frameworks such as angular, and it usually requires some backend to securely process the payments, which you use something like firebase cloud functions to handle. With flutter_stripe though, they are pretty vague with this topic, and when looking for tutorials and examples on the proper way to implement it, it seems most do not cover the backend portion at all, so I am wondering if it is a requirement?

    On the pub page it seems like there's no documentation on requirements so it feels ambiguous: https://pub.dev/packages/flutter_stripe

    The flutter_stripe github repo includes an example usage that has a server folder with the type of http requests I expect: https://github.com/flutter-stripe/flutter_stripe/tree/main/example

    but it is pretty convoluted and absolutely no explanation to it, as well as just no documentation in general. Has anyone successfully set this pacakge up in their project and if so could you provide some advice on what are the backend requirements?

    Thank you!

  • Vincenzo
    Vincenzo over 2 years
    Hi, the whole Stripe thing is very confusing. So if using this package one ends up making calls to a server's endpoint on which a Stripe integration ( as I have on my Node server ) what's the point in using it? I mean.. to be PCI Compliant you should comunicate your customers' card details directly from the Client app to Stripe without passing through a server, so even with this package you're not PCI Compliant as you have to hit your server with the card information right? Am I misunderstanding something? Thanks