AwaisMajeed
AwaisMajeed

Reputation: 2314

Flutter Stripe Payment : StripeSource class missing

I am following this and this tutorial to integrate stripe payment into my flutter project. Both of these tutorials/examples reference the class StripeSource by calling its method

StripeSource.setPublishableKey("pk_test");

but this class seems to be missing from the latest stripe package for a flutter. I've added the flutter SDK using stripe_payment: ^1.0.0 in my pubspec.yaml file and other stripe classes are available.

Any help is highly appreciated :-).

Upvotes: 1

Views: 1723

Answers (1)

VinceM
VinceM

Reputation: 46

Those tutorial are outdated. The library changed and now it works in a different way. Instead of using StripeSource, you should use StripePayment. For example:

StripePayment.setOptions(StripeOptions(
                          publishableKey:
                              'YOUR_TEST_PUBLISH_KEY'));
                      StripePayment.paymentRequestWithCardForm(
                              CardFormPaymentRequest())
                          .catchError((e) {
                        print('ERROR ${e.toString()}');
                      }).then((paymentMethod) {
                        //DO SOMETHING WITH YOUR PAYMENT METHOD
                      });

EDIT

What matters to follow those tutorials, is to optain the 'token'. As it is not very clear and there is not a complete documentation, I want to point out that: paymentMethod.id is equal to the token returned by StripeSource.addSource() in the old versions.

Upvotes: 3

Related Questions