flutter_stripe_payment icon indicating copy to clipboard operation
flutter_stripe_payment copied to clipboard

How to create payment intent method Gpay and Apple Pay

Open curlyeto opened this issue 4 years ago • 1 comments

The native payment method in the package example returns a token. How can I post this token value to the stripe panel ?

Native paymet method function

  onPressed: () {
                if (Platform.isIOS) {
                  _controller.jumpTo(450);
                }
                StripePayment.paymentRequestWithNativePay(
                  androidPayOptions: AndroidPayPaymentRequest(
                    totalPrice: "1.20",
                    currencyCode: "EUR",
                  ),
                  applePayOptions: ApplePayPaymentOptions(
                    countryCode: 'DE',
                    currencyCode: 'EUR',
                    items: [
                      ApplePayItem(
                        label: 'Test',
                        amount: '13',
                      )
                    ],
                  ),
                ).then((token) {
                  setState(() {
                    _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text('Received ${token.tokenId}')));
                    _paymentToken = token;
                  });
                }).catchError(setError);
              },
            ),

curlyeto avatar Aug 31 '20 20:08 curlyeto

An helpful approach would be attaching the source to a customer object.

final response0 = await Dio().post(
          'https://api.stripe.com/v1/customers/${context.read<UserModel>().stripeAccount}/sources',
          data: {'source': token.tokenId},
          options: authHeaderSecret());
      final response = await Dio().post('https://api.stripe.com/v1/charges',
          data: {
            //'source': token.tokenId,
            'currency': 'EUR',
            'amount': 100,
            'customer': context.read<UserModel>().stripeAccount
          },
          options: authHeaderSecret());

fly-qp avatar Jun 11 '21 15:06 fly-qp