Set up a subscription with BECS Direct Debit in Australia
Learn how to create and charge for a subscription with BECS Direct Debit.
Note
If you’re a new user, use the Payment Element instead of using Stripe Elements as described in this guide. The Payment Element provides a low-code integration path with built-in conversion optimisations. For instructions, see Build a subscription.
Use this guide to set up a subscription using BECS Direct Debit as a payment method.
Create a product and priceDashboard
Products represent the item or service you’re selling. Prices define how much and how frequently you charge for a product. This includes how much the product costs, what currency you accept, and whether it’s a one-off or recurring charge. If you only have a few products and prices, create and manage them in the Dashboard.
This guide uses a stock photo service as an example and charges customers a 15 AUD monthly subscription. To model this:
- Navigate to the Add a product page.
- Enter a Name for the product.
- Enter 15 for the price.
- Select AUD as the currency.
- Click Save product.
After you create the product and the price, record the price ID so you can use it in subsequent steps. The pricing page displays the ID and it looks similar to this: price_
.
Create a SetupIntentServer-side
A SetupIntent is an object that represents your intent to set up a customer’s payment method for future payments. The SetupIntent
will track the steps of this set-up process. For BECS Direct Debit, this includes collecting a mandate from the customer and tracking its validity throughout its lifecycle.
Create a SetupIntent on your server with payment_method_types set to au_
:
The returned SetupIntent
object contains a client_
property. Pass the client secret to the client-side application to continue with the setup process.
Collect payment method details and mandate acknowledgmentClient-side
You’re ready to collect payment information on the client with Stripe Elements. Elements is a set of pre-built UI components for collecting payment details.
A Stripe Element contains an iframe that securely sends the payment information to Stripe over an HTTPS connection. The checkout page address must also start with https:// rather than http:// for your integration to work.
You can test your integration without using HTTPS. Enable it when you’re ready to accept live payments.
Set up Stripe Elements
Submit the payment method details to StripeClient-side
Rather than sending the entire SetupIntent
object to the client, use its client secret from step 2. This is different from your API keys that authenticate Stripe API requests.
The client secret should be handled carefully because it can complete the setup. Do not log it, embed it in URLs, or expose it to anyone but the customer.
Create a customer with a PaymentMethodServer-side
Creating subscriptions requires a customer, which represents the customer purchasing your product. Because the price you created charges on a monthly basis, you need to add a stored payment method to the customer so future payments are successful. You do this by setting the payment method you just collected at the top level of the Customer object and as the default payment method for invoices:
This returns a Customer
object. You can see the default payment method in the invoice_
object:
{ "id": "cus_Gk0uVzT2M4xOKD", "object": "customer", "address": null, "balance": 0, "created": 1581797088, "currency": null, "default_source": null, "delinquent": false, "description": null, "discount": null, "email": "jenny.rosen@example.com", "invoice_prefix": "11D0B3D7", "invoice_settings": { "custom_fields": null, "default_payment_method": "pm_1FU2bgBF6ERF9jhEQvwnA7sX", "footer": null },
After creating the customer, store the id
value in your own database so you can use it later. The next step also requires this ID.
Create the subscriptionServer-side
Create a subscription with the price and customer:
Creating subscriptions automatically charges customers because the default payment method is set. After a successful payment, the status in the Stripe Dashboard changes to Active. The price you created earlier determines subsequent billings.
Manage subscription statusClient-side
Assuming the initial payment succeeds, the state of the subscription is active
and no further action is needed. When payments fail, the status is changed to the Subscription status configured in your automatic collection settings. You should notify the customer on failure and charge them with a different payment method.
Note
BECS Direct Debit payments are never automatically retried, even if you have a retry schedule configured for other payment methods.
Test the integration
You can test your form using the test BSB number 000-000
and one of the test account numbers below with your confirmAuBecsDebitSetup request.
BSB Number | Account Number | Description |
---|---|---|
000-000 | 000123456 | The PaymentIntent created with the resulting PaymentMethod transitions from processing to succeeded . The mandate status remains active . |
000-000 | 900123456 | The PaymentIntent created with the resulting PaymentMethod transitions from processing to succeeded (with a three-minute delay). The mandate status remains active . |
000-000 | 111111113 | The PaymentIntent created with the resulting PaymentMethod transitions from processing to requires_ with an account_ failure code. The mandate status becomes inactive at that point. |
000-000 | 111111116 | The PaymentIntent created with the resulting PaymentMethod transitions from processing to requires_ with a no_ failure code. The mandate status becomes inactive at that point. |
000-000 | 222222227 | The PaymentIntent created with the resulting PaymentMethod transitions from processing to requires_ with a refer_ failure code. The mandate status remains active . |
000-000 | 922222227 | The PaymentIntent created with the resulting PaymentMethod transitions from processing to requires_ with a refer_ failure code (with a three-minute delay). The mandate status remains active . |
000-000 | 333333335 | The PaymentIntent created with the resulting PaymentMethod transitions from processing to requires_ with a debit_ failure code. The mandate status becomes inactive at that point. |
000-000 | 666666660 | The PaymentIntent created with the resulting PaymentMethod transitions from processing to succeeded , but a dispute is immediately created. |
000-000 | 343434343 | The PaymentIntent that was created with the resulting PaymentMethod fails with a charge_ error due to the payment amount causing the account to exceed its weekly payment volume limit. |
000-000 | 121212121 | The PaymentIntent that was created with the resulting PaymentMethod fails with a charge_ error due to the payment amount exceeding the account’s transaction volume limit. |