Save the related setting details during a payment
Save your customer's the related setting payment method while processing a payment for future recurring use.
You can save a customer’s the related setting payment method while processing a payment. This allows you to charge the customer later for recurring payments without requiring them to enter a new the related setting code. When you save the related setting during a payment, the customer approves both the payment and the mandate authorization in their banking app.
To save the related setting during a payment, create a PaymentIntent with setup_future_usage set to off_session.
Checkout
Elements
Direct API
Create a Checkout Session Server-side
Create a Checkout Session in payment mode with setup_future_usage set to off_session. This tells Stripe to save the the related setting payment method for future off-session use after the payment completes.
Command Line
Select a language
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
After the customer completes the Checkout Session, a reusable the related setting PaymentMethod is attached to the Customer. The customer approves both the payment and the mandate authorization in their banking app.
Charge the saved the related setting PaymentMethod later Server-side
After you save a the related setting payment method, you can use it to charge the customer off-session without making them enter a new the related setting code.
Create a PaymentIntent with off_session set to true and the saved PaymentMethod and Customer IDs.
Command Line
Select a language
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
After confirming the PaymentIntent, it initiates a payment. The next_action has the blik_authorize type, which means that the next step is completed by the customer’s bank, who validates the payment against the terms of the original mandate. We recommend showing a timer or a dialog to your customer and polling your server or the Stripe API for the PaymentIntent status update.
Caution
You must listen for webhooks to determine the final payment status. Use the payment_intent.succeeded and payment_intent.payment_failed events to handle the outcome.
Handling failures
If the customer’s bank declines the payment, the PaymentIntent transitions to requires_payment_method. To resolve a failed off-session payment, you can bring the customer back on session and collect a new payment method, or retry the payment if the failure was transient.
Simulate failures in a sandbox
In addition to the one-time payment test patterns, you can simulate recurring-specific scenarios by passing email values matching the patterns below when creating the SetupIntent or PaymentIntent, as part of the billing details.
Mandate setup failures (immediate)
| Error code | Decline code | Explanation | Email pattern |
|---|---|---|---|
payment_method_provider_decline | recurring_not_supported_by_bank | The customer’s bank doesn’t support the related setting recurring payments. | .*recurring_not_supported@.* |
Mandate setup failures (60 second delay)
| Event produced | Explanation | Email pattern |
|---|---|---|
mandate.updated (pending to inactive) | The customer didn’t complete the mandate setup in their banking app. | .*setup_timeout@.* |
Mandate lifecycle events (6 minute delay)
These patterns simulate events that occur after a mandate has been successfully set up.
| Event produced | Explanation | Email pattern |
|---|---|---|
mandate.updated (active to inactive) | The customer removed the saved payment method from their banking app. | .*alias_unregistered@.* |
mandate.updated (active to inactive) | The mandate reached its expiration date. | .*alias_expired@.* |
Off-session payment failures (immediate)
These patterns affect off-session payments made with a saved the related setting payment method.
| Error code | Decline code | Explanation | Email pattern |
|---|---|---|---|
payment_method_provider_decline | generic_decline | The mandate setup succeeds, but all subsequent off-session payments are declined. | .*recurring_declined@.* |
payment_method_provider_decline | generic_decline | The off-session payment is declined and the mandate is revoked. The saved payment method can no longer be used. | .*alias_declined@.* |
