I want to connect Google Pay with Stripe in my Flutter app
Asked Answered
S

2

6

I want to use Google Pay in my app and I want to get my money in the Stripe dashboard.

I try the Flutter pay package, and now I am able to see the Google Pay sheet.

I am an Indian citizen, so I am not able to test Google Pay global in India, so how can I test my app? And I don't know how Google Pay responds when payment is a success.

Please attach some documentation or some example to integrate Google Pay with Stripe in Flutter.

I use this package: https://pub.dev/packages/pay

Here is my code for open Google Pay sheet:

import 'package:pay/pay.dart' as pay;

Widget _paymentOptions() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        pay.GooglePayButton(
          paymentConfigurationAsset: PaymentJson.googlePay,
          paymentItems: _paymentItems,
          width: 300,
          style: pay.GooglePayButtonStyle.black,
          type: pay.GooglePayButtonType.pay,
          margin: const EdgeInsets.only(top: 15.0),
          onPaymentResult: (val) {
            log(val.toString(), name: "Google Pay");
          },
          loadingIndicator: const Center(
            child: CircularProgressIndicator(),
          ),
        ),
        pay.ApplePayButton(
          paymentConfigurationAsset: PaymentJson.applePay,
          paymentItems: _paymentItems,
          width: 300,
          style: pay.ApplePayButtonStyle.black,
          type: pay.ApplePayButtonType.buy,
          margin: const EdgeInsets.only(top: 15.0),
          onPaymentResult: (val) {
            log(val.toString(), name: "Apple Pay");
          },
          childOnError: const Text(
            "Apple pay Not Available Now",
            style: TextStyle(
                color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold),
          ),
          onError: (e) {
            print(e);
            showAppSnackBar("Google pay Not Available Now");
          },
          loadingIndicator: const Center(
            child: CircularProgressIndicator(),
          ),
        ),
      ],
    );
  }


  final _paymentItems = [
    pay.PaymentItem(
      label: 'Total',
      amount: '99.99',
      status: pay.PaymentItemStatus.final_price,
    )
  ];
Shipowner answered 30/12, 2021 at 11:28 Comment(0)
D
2

Check this: Pay Plugin support

It's the Stripe package and it fully supports the Pay plugin.

Desperado answered 30/12, 2021 at 12:56 Comment(4)
in this plugin documentation they mention use pay plugin for google pay but I don't know how to connect stripe with google payShipowner
in the link above the pay plugin support have a code snippet for a function, this function should be called in your code here onPaymentResult: (val) { // onGooglePayResult(val); log(val.toString(), name: "Google Pay"); }, then your google pay is integrated with stripe and will pass the payment data to Stripe so it can be viewed in Stripe dashboardDesperado
can you share any reference?Shipowner
here is Stripe example code for apple pay: github.com/flutter-stripe/flutter_stripe/blob/main/example/lib/… and here is for google pay: github.com/flutter-stripe/flutter_stripe/blob/main/example/lib/… you have the whole repo full of code examples for different payment gateways and platformsDesperado
S
2

You can test Google Pay using test cards by following the instructions outlined at Test card suite or Testing Google Pay integrations without a debit or credit card #70.

It involves joining the googlepay-test-mode-stub-data Google group and using the integration in TEST mode (i.e., environment set to TEST).

Suppositive answered 30/12, 2021 at 18:7 Comment(2)
this link is not able to give me test credit card for google pay ca you share other references?Shipowner
Are you able to visit groups.google.com/g/googlepay-test-mode-stub-data/about and click the Join group button? Once you've done that, using Google Pay on a test integration should show the test cards. Here is a test integration you should be able to use: paydemo.withgoogle.com/detail/mens_outerwear/…Suppositive

© 2022 - 2024 — McMap. All rights reserved.