#asim_1

1 messages · Page 1 of 1 (latest)

heavy badgeBOT
#

Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

  • asim_1, 1 day ago, 91 messages
charred flare
#

It is common to save the ID in assosciation with the customer on your side

rose lion
#

Why would I set some account as default? The payment sheet UI allows the user to select one particular account that he wants to get charged.

rose lion
#

The customer choose a payment method on the Android app. I want that payment's ID so I can use it with a payment intent later.

charred flare
#

Good question, checking in to this and will get back to you

heavy badgeBOT
warm sandal
#

you can do like this

private fun onPaymentSheetResult(paymentSheetResult: PaymentSheetResult) {
    when(paymentSheetResult) {
        is PaymentSheetResult.Canceled -> {
            // ...
        }
        is PaymentSheetResult.Failed -> {
            // ...
        }
        is PaymentSheetResult.Completed -> {
            stripe.retrieveSetupIntent(
                clientSecret,
                callback = object : ApiResultCallback<SetupIntent> {
                    override fun onSuccess(result: SetupIntent) {
                        var id = result.paymentMethodId
                        if (id != null) {
                            Log.d("paymentMethodId", id)
                        }
                            // ...
                    }
                    override fun onError(e: Exception) {
                        error("Could not retrieve SetupIntent, $e\n")
                            // ...
                    }
                }
            )
        // ...
        }
    }
}

or access .payment_method on the SetupIntent in the backend while handlng webhooks or so on.

charred flare
#

And you will also likely want to listen for the payment_method.attached event as things can go wrong with your client trying to tell your server about that ID