flutter-stripe / flutter_stripe

Flutter SDK for Stripe.
https://pub.dev/packages/flutter_stripe
961 stars 531 forks source link

`CustomerSheetResult` has a `null` payment method when selecting Apple/Google Pay option #1885

Closed nayanbabariya closed 1 month ago

nayanbabariya commented 3 months ago

Describe the bug

We have the option to manage payment methods using a customer sheet. I am opening it using the below code:

Reproducible code

// Before runApp()
Stripe.publishableKey = Environment.stripePublishableKey;
Stripe.merchantIdentifier = 'My Merchant identifier';
Stripe.urlScheme = 'flutterstripe';
await Stripe.instance.applySettings();
// I receive the `setupIntent` object from my backend API call.
await Stripe.instance.initCustomerSheet(
      customerSheetInitParams: CustomerSheetInitParams(
        merchantDisplayName: 'My App Name',
        returnURL: returnURL,
        customerId: setupIntent.customerId,
        setupIntentClientSecret: setupIntent.setupIntent,
        customerEphemeralKeySecret: setupIntent.ephemeralKey,
        defaultBillingDetails: billingDetails,
        billingDetailsCollectionConfiguration:
            billingDetailsCollectionConfiguration,
        style: themeMode,
        appearance: appearance,
        allowsRemovalOfLastSavedPaymentMethod: false,
      ),
    );

try {
      // This is the method that opens the customer sheet.
      final result = await stripe.presentCustomerSheet();
      log('Customer sheet result =====> ${result?.toJson()}');
    } on StripeException catch (e) {
      log(e.toString(), name: 'Stripe Exception');
    }

Logs

When selecting Google Pay in Android

Screenshot_20240807-113449

[log] Customer sheet result =====> 
{paymentOption: {label: Google Pay, image: byteImageString}, paymentMethod: null, error: null}

When selecting Apple Pay in iOS

Image_20240807_71710_674 a m

[log] Customer sheet result =====> 
{paymentOption: {label: Apple Pay, image: byteImageString}, paymentMethod: null, error: null}

Expected behavior

It should return the payment method object the same as when I select the other test card.

[log] Customer sheet result =====> 
{paymentOption: {label: ••••1117, image: byteImageString}, 
paymentMethod: {id: pm_1PkmZYIHwnvciW2rKGGl5e9u, livemode: false, paymentMethodType: Card,
billingDetails: {email: my_email, address: Address(city: My city name, country: IN, line1: line1 address, line2: , postalCode: 992345, state: state name), phone: null, name: My name},
Card: {brand: Discover, country: US, expYear: 2026, expMonth: 9, funding: credit, last4: 1117, preferredNetwork: null, availableNetworks: [discover], threeDSecureUsage: {isSupported: true}},
SepaDebit: {country: null, bankCode: null, fingerprint: null, last4: null},
BacsDebit: {sortCode: null, fingerprint: null, last4: null},
AuBecsDebit: {fingerprint: null, last4: null, bsbNumber: null},
Sofort: {country: null}, Ideal: {bankIdentifierCode: , bank: null},
Fpx: {bank: , accountHolderType: null}, Upi: {vpa: null},
USBankAccount: {routingNumber: null, last4: null, accountHolderType: Unknown, accountType: Unknown, bankName: null, fingerprint: null, linkedAccount: null, preferredNetwork: null, supportedNetworks: null},
customerId: cus_eqw786q87eq}, error: null}

Device Information

mihiravdevs commented 3 months ago

@nayanbabariya https://github.com/flutter-stripe/flutter_stripe/issues/1897 Google pay button is not visible on stripe paymentsheet.

I am facing above issue could you please help me on that?

remonh87 commented 1 month ago

Sorry for the late reply. This is expected behavior the sdk does not provide us any option here. Wallets are the exception