Stripe | Financial Infrastructure to Grow Your Revenue

Stripe | Financial Infrastructure to Grow Your Revenue

5282 articles

Set up a subscription with Bacs Direct Debit


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 Stripe Server-side

First, you need a Stripe account. Register now.

Use our official libraries for access to the Stripe API from your application:

Command Line

Select a language

Ruby

Python

PHP

Java

Node.js

Go

.NET

No results

# Available as a gem
sudo gem install stripe

Gemfile

Select a language

Ruby

Python

PHP

Java

Node.js

Go

.NET

No results

# If you use bundler, you can add this line to your Gemfile
gem 'stripe'

Create recurring products and prices

Caution

The Prices API unifies how one-off purchases and subscriptions are modelled 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.

Before you start configuring products, make sure you’re in a sandbox. Next, define the goods and services you plan to sell. To create a new product and price:

  • Go to the Products section in the Dashboard
  • Click Add product
  • Select “Recurring” when setting the price
  • Configure the pricing plan

You can define multiple pricing plans with different parameters for each recurring product. Each price has a generated ID that you can use as a reference during the checkout process.

Note

Products created in a sandbox can be copied to live mode so that you don’t need to re-create them. In the Product detail view in the Dashboard, click Copy to live mode on the upper right corner. You can copy the same sandbox product to live mode more than once. Each copy creates a separate live product, and subsequent updates to the sandbox product aren’t reflected in existing live copies.

Create a Checkout Session Client-side Server-side

Add a checkout button to your website that calls a server-side endpoint to create a Checkout Session.

index.html

<html>
 <head>
 <title>Checkout</title>
 </head>
 <body>
 <form action="/create-checkout-session" method="POST">
 <button type="submit">Checkout</button>
 </form>
 </body>
</html>

Create a Checkout 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-off prices in addition to recurring prices. After creating the Checkout Session, redirect your customer to the URL returned in the response.

Command Line

Select a language

cURL

Ruby

Python

PHP

Java

Node.js

Go

.NET

No results

When your customer successfully completes their payment, they’re redirected to the success_url, a page on your website that informs them that their payment was successful. Make the Session ID available on your success page by including the {the related setting} template variable in the success_url as in the above example.

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_url alone for detecting payment initiation, because:

  • Malicious users could directly access the success _ url without paying and gain access to your goods or services.
  • After a successful payment, customers might close their browser tab before they’re redirected to the success _ url .

Confirm the payment is successful

When your customer completes a payment, Stripe redirects them to the URL that you specified in the success_url 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. Delay order fulfilment until the payment succeeds. Don’t use the subscription status alone because a subscription can become active while its first payment is still processing. Before fulfilling goods or services, wait for the invoice.paid event or confirm that the underlying PaymentIntent has a succeeded status and verify that the related subscription is active.

You can confirm the payment is successful in several ways:

Successful payments display in the Dashboard’s list of payments. When you click a payment, it takes you to the payment details page. The Checkout summary section contains billing information and the list of items purchased, which you can use to manually fulfil the order.

Note

Stripe can help you keep up with incoming payments by sending you email notifications whenever a customer successfully completes one. Use the Dashboard to configure email notifications.

Test the integration

There are several test bank account numbers you can use in a sandbox to make sure this integration is ready. You can also use the corresponding token to skip manually entering bank account details.

Sort codeAccount numberTokenDescription
10-88-0000012345pm_bacsDebit_successThe payment succeeds and the Invoice transitions to paid.
10-88-0090012345pm_bacsDebit_successDelayedThe payment succeeds after three minutes and the Invoice transitions to paid.
10-88-0033333335pm_bacsDebit_debitNotAuthorizedThe payment fails with a debit_not_authorized failure code and the Invoice transitions to open. The Mandate becomes inactive and the PaymentMethod can’t be used again.
10-88-0093333335pm_bacsDebit_debitNotAuthorizedDelayedThe payment fails after three minutes with a debit_not_authorized failure code and the Invoice transitions to open. The Mandate becomes inactive and the PaymentMethod can’t be used again.
10-88-0022222227pm_bacsDebit_insufficientFundsThe payment fails with an insufficient_funds failure code and the Invoice transitions to open. The Mandate remains active and the PaymentMethod can be used again.
10-88-0092222227pm_bacsDebit_insufficientFundsDelayedThe payment fails after three minutes with an insufficient_funds failure code and the Invoice transitions to open. The Mandate remains active and the PaymentMethod can be used again.
10-88-0055555559pm_bacsDebit_disputeThe payment succeeds after three minutes and the Invoice transitions to paid, but a dispute is immediately created.
10-88-0000033333pm_bacsDebit_mandateRefusedPayment Method creation succeeds, but the Mandate is refused by the customer’s bank and immediately transitions to inactive.
10-88-0000044444—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 aren’t 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 sandboxes.

Optional Adding a one-time setup fee Server-side

Optional Create prices and products inline Server-side

Optional Existing customers Server-side

Optional Prefill customer data Server-side

Optional Handling trials Server-side

Optional Tax rates Server-side

Optional Adding coupons Server-side

See also

Last verified 2026-09-25

Is this helpful?