onCreateIntent

abstract suspend fun onCreateIntent(paymentMethod: PaymentMethod, shouldSavePaymentMethod: Boolean): CreateIntentResult

Called when the customer confirms the payment or setup.

Your implementation should create and optionally confirm a PaymentIntent or SetupIntent on your server and return its client secret or an error if one occurred.

Parameters

paymentMethod

The PaymentMethod representing the customer's payment details. If your server needs the payment method, send PaymentMethod.id to your server and have it fetch the PaymentMethod object. Otherwise, you can ignore this. Don't send other properties besides the ID to your server.

shouldSavePaymentMethod

This is true if the customer selected the "Save this payment method for future use" checkbox. Set setup_future_usage on the PaymentIntent to off_session if this is true.