Set up a subscription with Bacs Direct Debit
Learn how to create and charge for a subscription with Bacs Direct Debit.
Use this guide to set up a subscription using Bacs Direct Debit as a payment method and Checkout.
Set up StripeServer-side
First, you need a Stripe account. Register now.
Use our official libraries for access to the Stripe API from your application:
Create recurring products and prices
Caution
The Prices API unifies how one-time purchases and subscriptions are modeled on Stripe. Existing integrations that don’t use the Prices API are still supported. However, some Checkout features only support Prices. See the migration guide to upgrade to the Prices API.
To use Checkout, you first need to create a Product and a Price. Different physical goods or levels of service must be represented by products. Each product’s pricing is represented by one or more prices.
For example, you can create a software product that has four prices: 10 USD/month, 100 USD/year, 9 GBP/month, and 90 GBP/year. This allows you to change and add prices without needing to change the details of your underlying products. You can create a product and price through the API or through the Stripe Dashboard.
If your price is determined at checkout (for example, the customer sets a donation amount) or you prefer not to create prices upfront, you can create prices inline at Checkout Session creation.
Create a Checkout SessionClient-sideServer-side
Add a checkout button to your website that calls a server-side endpoint to create a Checkout Session.
<html> <head> <title>Checkout</title> </head> <body> <form action="/create-checkout-session" method="POST"> <button type="submit">Checkout</button> </form> </body> </html>
Create a Session with the ID of an existing Price. Make sure that mode is set to subscription
and you pass at least one recurring price. You can add one-time prices in addition to recurring prices. After creating the Checkout Session, redirect your customer to the URL returned in the response.
When your customer successfully completes their payment, they are redirected to the success_
, a page on your website that informs the customer that their payment was successful. Make the Session ID available on your success page by including the {CHECKOUT_
template variable in the success_
as in the above example.
When your customer clicks on your logo in a Checkout Session without completing a payment, Checkout redirects them back to your website by navigating to the cancel_
. Typically, this is the page on your website that the customer viewed prior to redirecting to Checkout.
Checkout Sessions expire 24 hours after creation by default.
From the Dashboard, enable the payment methods you want to accept from your customers. Checkout supports several payment methods.
Caution
Don’t rely on the redirect to the success_
alone for detecting payment initiation, as:
- Malicious users could directly access the
success_
without paying and gain access to your goods or services.url - Customers may not always reach the
success_
after a successful payment—they might close their browser tab before the redirect occurs.url
Confirm the payment is successful
When your customer completes a payment, Stripe redirects them to the URL that you specified in the success_
parameter. Typically, this is a page on your website that informs your customer that their payment was successful.
However, Bacs Direct Debit is a delayed notification payment method, which means that funds aren’t immediately available. A Bacs Direct Debit payment typically takes three business days to make the funds available. Because of this, you’ll want to delay order fulfillment until the funds are available. After the payment succeeds, the underlying PaymentIntent status changes from processing
to succeeded
.
You can confirm the payment is successful in several ways:
Test the integration
There are several test bank account numbers you can use in test mode to make sure this integration is ready.
Sort code | Account number | Description |
---|---|---|
10-88-00 | 00012345 | The payment succeeds and the Invoice transitions to paid . |
10-88-00 | 90012345 | The payment succeeds after three minutes and the Invoice transitions to paid . |
10-88-00 | 33333335 | The payment fails with a debit_ failure code and the Invoice transitions to open . The Mandate becomes inactive and the PaymentMethod can not be used again. |
10-88-00 | 93333335 | The payment fails after three minutes with a debit_ failure code and the Invoice transitions to open . The Mandate becomes inactive and the PaymentMethod can not be used again. |
10-88-00 | 22222227 | The payment fails with an insufficient_ failure code and the Invoice transitions to open . The Mandate remains active and the PaymentMethod can be used again. |
10-88-00 | 92222227 | The payment fails after three minutes with an insufficient_ failure code and the Invoice transitions to open . The Mandate remains active and the PaymentMethod can be used again. |
10-88-00 | 55555559 | The payment succeeds after three minutes and the Invoice transitions to paid , but a dispute is immediately created. |
10-88-00 | 00033333 | Payment Method creation succeeds, but the Mandate is refused by the customer’s bank and immediately transitions to inactive. |
10-88-00 | 00044444 | The request to set up Bacs Direct Debit fails immediately due to an invalid account number and the customer is prompted to update their information before submitting. Payment details are not collected. |
You can test using any of the account numbers provided above. However, because Bacs Direct Debit payments take several days to process, use the test account numbers that operate on a three-minute delay to better simulate the behavior of live payments.
Note
By default, Stripe automatically sends emails to the customer when payment details are initially collected and each time a debit will be made on their account. These notifications aren’t sent in testmode.