androidstripe-paymentspaymentstripe-payment-intent

Android Stripe Saved card missing from payment sheet


After fetching the customerId, ephemeralKey and clientSecret, I initialize the PaymentSheet with a Configuration object (which includes the app name, customerConfiguration(customerId, ephemeralKey and GooglePayConfiguration.

I then call presentWithPaymentIntent(clientSecrent, customerConfiguration), where the customerConfiguration is the object created at the first step.

The documentation says that if you pass the customer configuration and the user checks the "Save for future payments" checkbox, on the next payment the PaymentSheet will show the saved card, but for some reason, for me it doesn't.

I've checked and the customerId it's always the same for the current customer, only the ephemeralKey changes for new payments, which seems right.

Any idea what I might be doing wrong? The iOS client works as expected, so server side is configured ok.

Thanks!

Code sample:

PaymentSheet.GooglePayConfiguration googlePayConfiguration = new PaymentSheet.GooglePayConfiguration(getGooglePayEnvironment(), countryCode);
        PaymentSheet.CustomerConfiguration customerConfiguration = new PaymentSheet.CustomerConfiguration(mViewModel.getCustomerId(), mViewModel.getEphemeralKey());

        PaymentSheet.Configuration configuration = new PaymentSheet.Configuration(getString(R.string.app_name),
                customerConfiguration,
                googlePayConfiguration,
                null,
                null);

mPaymentSheet.presentWithPaymentIntent(mViewModel.getClientSecret(), configuration);

Solution

  • Your question does not show the code that is executed in the View Model, so I will give a working example of saving/loading card data:

    https://api.stripe.com/v1/payment_intents BODY PARAMS
    
     customer=$customerId
     amount=$amount
     currency=usd
    
    

    This request will return the secret key intent, which we will use during the initialization of our payment sheet.

    Next step is setting up the sheet. Use the following code:

    val customerConf = PaymentSheet.CustomerConfiguration(viewModel.customerId, ephemeralKey)
    val sheetConf = PaymentSheet.Configuration(
            merchantDisplayName = "Some product name",
            customer = customerConf,
            allowsDelayedPaymentMethods = false
    )
    paymentSheet.presentWithPaymentIntent(intentSecret, sheetConf)
    

    As the result, you will receive the preservation of your cards after re-payment.

    Payment by saved card. Image

    I also advise you to create a test user for the android application and check on the dashboard whether the card data is saved after clicking on the checkbox and paying