Accept a New Zealand BECS Direct Debit payment
Build a custom payment form to accept payments with New Zealand bank account debits.
Accepting New Zealand BECS Direct Debit payments on your website consists of creating an object to track a payment, collecting payment method information and mandate acknowledgement, and submitting the payment to Stripe for processing.
Stripe uses a payment object, the Payment Intent, to track and handle all the states of the payment until the payment completes.
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 or retrieve a CustomerServer-side
To reuse a bank account for future payments, attach it to a Customer.
Create a Customer object when your customer creates an account with your business. Associating the ID of the Customer object with your own internal representation of a customer enables you to retrieve and use the stored payment method details later.
Create a new Customer or retrieve an existing Customer to associate with this payment. Include the following code on your server to create a new Customer.
Create a PaymentIntentServer-side
A PaymentIntent is an object that represents your intent to collect payment from a customer and tracks the lifecycle of the payment process through each stage.
First, create a PaymentIntent on your server and specify the amount to collect and the nzd
currency. If you already have an integration using the Payment Intents API, add nz_
to the list of payment method types for your PaymentIntent. Specify the id of the Customer.
Also provide the setup_future_usage parameter with the value off_
to save the payment method to the Customer for future use.
Included in the returned PaymentIntent is a client secret, which the client side uses to securely complete the payment process instead of passing the entire PaymentIntent object. You can use different approaches to pass the client secret to the client side.
Retrieve the client secret
The PaymentIntent includes a client secret that the client side uses to securely complete the payment process. You can use different approaches to pass the client secret to the client side.
Collect payment method details and mandate acknowledgementClient-side
Set up Stripe Elements
Include the Stripe.js script on your checkout page by adding it to the head
of your HTML file. Always load Stripe.js directly from js.stripe.com. Don’t include the script in a bundle or host a copy of it yourself.
<head> <title>Checkout</title> <script src="https://js.stripe.com/v3/"></script> </head>
Create an instance of the Stripe object by providing your publishable API key as the first parameter, additionally passing the nz_
beta flag to access the Elements:
// Set your publishable key: remember to change this to your live publishable key in production // See your keys here: https://dashboard.stripe.com/apikeys const stripe = Stripe(
, { betas: ['nz_bank_account_beta_2'], apiVersion: "2025-03-31.basil;nz_bank_account_beta=v2" });'pk_test_TYooMQauvdEDq54NiTphI7jx'
Add the Payment Element to your checkout page
On your checkout page, create an empty DOM node with a unique ID for the Payment Element to render into.
<form id="payment-form"> <h3>Payment</h3> <div id="payment-element"></div> <button id="submit">Submit</button> </form>
When the form above finishes loading, create a new Elements group, passing the client secret from the previous step as configuration. You can also pass in the appearance option, customizing the Elements to match the design of your site.
Then, create an instance of the Payment Element and mount it to its corresponding DOM node:
// Customize the appearance of Elements using the Appearance API. const appearance = { /* ... */ }; // Create an elements group from the Stripe instance, passing the clientSecret (obtained in step 2) and appearance (optional). const elements = stripe.elements({clientSecret, appearance}); // Create Payment Element instance. const paymentElement = elements.create("payment"); // Mount the Payment Element to its corresponding DOM node. paymentElement.mount("#payment-element");
The Payment Element renders a dynamic form that allows your customer to pick a payment method type. The form automatically collects all necessary payments details for the payment method type that they select. For New Zealand BECS Diret Debit payments, that includes the customer’s name, email address, and bank account number.
Mandate acknowledgement
The Payment Element also displays the New Zealand BECS Direct Debit Service Terms and Conditions to your customer and collects their agreement with those terms. You’re not required to do anything else.
If you don’t use the Payment Element, you must separately display these terms and conditions to your customer and confirm their acceptance.
Note
By providing your bank account details and confirming this payment, you authorise Stripe New Zealand Limited (authorisation code 3143978), to debit your account with the amounts of direct debits payable to Rocket Rides (“we”, “us” or “Merchant”) in accordance with this authority.
You agree that this authority is subject to:
- your bank’s terms and conditions that relate to your account, and
- the Direct Debit Service Terms and Conditions
You certify that you are either the sole account holder on the bank account listed above or that you are an authorised signatory on, and have authority to operate, this bank account severally.
We will send you an email confirmation no later than 5 business days after your confirmation of this Direct Debit Authority.
If we request you to do so, you must promptly provide Stripe with a record of the mandates.
Submit the payment to StripeClient-side
Use stripe.confirmPayment to collect bank account details, create a PaymentMethod, and attach that PaymentMethod to the PaymentIntent.
For some other payment method types, your customer might be first redirected to an intermediate site, like a bank authorization page, before being redirected to the return_
. Provide a return_url to this function to indicate where Stripe should redirect the customer after they complete the payment.
Since New Zealand BECS Direct Debits don’t require a redirect, you can also set redirect to if_
in place of providing a return_
. A return_
will only be required if you add another redirect-based payment method later.
confirmationForm.addEventListener('submit', (ev) => { ev.preventDefault(); stripe.confirmPayment({elements, redirect: "if_required"}) .then(({paymentIntent, error}) => { if (error) { console.error(error.message); // The confirmation failed for some reason. } else if (paymentIntent.status === "requires_payment_method") { // Confirmation failed. Attempt again with a different payment method. } else if (paymentIntent.status === "processing") { // Confirmation succeeded! The account will be debited. // Display a message to the customer. } }); });
If successful, Stripe returns a PaymentIntent object with the status processing
. See the next step for information on how to confirm success of the PaymentIntent.
Customer notification emails
You must send an email confirmation of the mandate and collected bank account details to your customer after successfully confirming the PaymentIntent.
In addition, for every payment collected, including this one, you must send your customer an email notification of the debit date and amount at latest on the day the debit takes place.
Stripe handles sending these emails for you by default, but you can choose to send custom notifications.
Confirm the PaymentIntent succeededServer-side
New Zealand BECS Direct Debit are a delayed notification payment method. In addition, they require notifying your customer of any debit from their bank account, at latest, on the date of the debit.
Notification of success or failure of the PaymentIntent comes within 3 business days thereafter. When the payment succeeds, the PaymentIntent status changes from processing
to succeeded
.
The following events are sent when the PaymentIntent status changes:
Event | Description | Next Step |
---|---|---|
payment_ | The customer successfully submitted their payment to Stripe. | Wait for the initiated payment to succeed or fail. |
payment_ | The customer’s payment succeeded. | Fulfill the goods or services that were purchased. |
payment_ | The customer’s payment was declined. | Send the customer an email or push notification and request another payment method. |
We recommend using webhooks to confirm the charge succeeds and to notify the customer that the payment is complete. You can also view events on the Stripe Dashboard.
Accepting future paymentsServer-side
After the PaymentIntent succeeds with a Customer provided and the setup_future_usage parameter set to off_
, the PaymentMethod PaymentMethod is attached to the Customer. You can use these to initiate future payments without having to prompt the customer for their bank account a second time.