Billing
BECS Direct Debit in Australia

Set up a subscription with BECS Direct Debit in Australia

Learn how to create and charge for a subscription with BECS Direct Debit.

1 Create a product and price Dashboard

Products are what you sell, and you need to create at least one before you can charge for it. This guide uses a stock photo service as an example. Generally, if you only have a few products, you should create and manage them in the Dashboard.

To create a product in the Dashboard:

 

  1. Navigate to the Add a product page.

  2. Enter a Name for your product.

  3. Scroll down to the Pricing section.

  4. Create your price by entering in price data.

  5. Click the Save product button.

 

 

 

This creates the product and any entered prices and automatically opens the product detail page. Prices define how much and how frequently you charge for a product. This includes how much the product costs, what currency to use, and the billing period to use for recurring charges. For each currency you charge, a separate price should be created. Similar to products, if you only have a few prices it’s preferable to manage them in the Dashboard.

In this guide, a recurring quantity is used. This means customers are charged the same amount on a recurring basis. For example, charging 15 AUD a month for a streaming service or 120 AUD for a yearly subscription to an online publication. From the product detail page, click the Add price (or Add another price) button:

  1. In the Price field, enter 15.
  2. In the currency field, select AUD.
  3. Click the Add price button.

You have several other options for creating prices, but this basic example results in a price that:

  • Uses AUD
  • Costs 15 AUD per subscription
  • Charges customers monthly

After you create the price, record the ID so it can be used in subsequent steps. It’s displayed on the pricing page and should look similar to this: price_G0FvDp6vZvdwRZ.

2 Create a SetupIntent Server-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_becs_debit:

curl https://api.stripe.com/v1/setup_intents \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d "payment_method_types[]"=au_becs_debit
require 'sinatra' require 'json' require 'stripe' # Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' get '/wallet' do intent = Stripe::SetupIntent.create({ payment_method_types: ['au_becs_debit'], }) client_secret = setup_intent['client_secret'] # Pass the client secret to the client end
import stripe import json from flask import Flask, request, render_template app = Flask(__name__, static_folder=".", static_url_path="", template_folder=".") # Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' @app.route('/wallet') def wallet(): setup_intent = stripe.SetupIntent.create( payment_method_types=['au_becs_debit'], ) client_secret = setup_intent.client_secret # Pass the client secret to the client if __name__ == '__main__': app.run()
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); # vendor using composer require_once('vendor/autoload.php'); $setup_intent = \Stripe\SetupIntent::create([ 'payment_method_types' => ['au_becs_debit'], ]); $client_secret = $setup_intent->client_secret // Pass the client secret to the client
import java.util.HashMap; import java.util.Map; import com.stripe.Stripe; import com.stripe.model.SetupIntent; public class StripeJavaQuickStart { public static void main(String[] args) { // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; Map<String, Object> setupIntentParams = new HashMap<String, Object>(); ArrayList paymentMethodTypes = new ArrayList(); setupIntentParams.put("payment_method_types", Arrays.asList("au_becs_debit")); SetupIntent setupIntent = SetupIntent.create(setupIntentParams); String clientSecret = setupIntent.getClientSecret(); // Pass the client secret to the client } }
// Using Express const express = require('express'); const app = express(); app.use(express.json()); const { resolve } = require("path"); // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const setupIntent = await stripe.setupIntents.create({ payment_method_types: ['au_becs_debit'], }); const clientSecret = setupIntent.client_secret; // Pass the client secret to the client
package main import ( "encoding/json" "log" "net/http" "github.com/stripe/stripe-go/v71" "github.com/stripe/stripe-go/v71/setupintent" ) func main() { // Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" setupIntentParams := &stripe.SetupIntentParams{ PaymentMethodTypes: stripe.StringSlice([]string{ "au_becs_debit", }), } setupIntent, err := setupintent.New(setupIntentParams) clientSecret := setupIntent.ClientSecret // Pass the client secret to the client }
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; using System; using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using Stripe; namespace StripeExampleApi.Controllers { [Route("/wallet")] public class WalletController : Controller { public IActionResult Index() { var service = new SetupIntentService(); var options = new SetupIntentCreateOptions { PaymentMethodTypes = new List<string> { "au_becs_debit", }, }; SetupIntent intent = service.Create(options); var clientSecret = setupIntent.ClientSecret; // Pass the client secret to the client } } }

The returned SetupIntent object contains a client_secret property. Pass the client secret to the client-side application to continue with the setup process.

3 Collect payment method details and mandate acknowledgment Client-side

You’re ready to collect payment information on the client with Stripe Elements. Elements is a set of prebuilt UI components for collecting payment details.

A Stripe Element contains an iframe that securely sends the payment information to Stripe over a 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

Stripe Elements is automatically available as a feature of Stripe.js. Include the Stripe.js script on your payment page by adding it to the head of your HTML file. Always load Stripe.js directly from js.stripe.com to remain PCI compliant. Do not include the script in a bundle or host a copy of it yourself.

<head> <title>Payment Setup</title> <script src="https://js.stripe.com/v3/"></script> </head>

Create an instance of Elements with the following JavaScript on your payment page:

var stripe = Stripe('pk_test_TYooMQauvdEDq54NiTphI7jx'); var elements = stripe.elements();
const stripe = Stripe('pk_test_TYooMQauvdEDq54NiTphI7jx'); const elements = stripe.elements();

Direct Debit Requests

Before you can create a BECS Direct Debit payment, your customer must agree with the Direct Debit Request Service Agreement. They do so by submitting a completed Direct Debit Request (DDR). The approval gives you a mandate to debit their account. The Mandate is a record of the permission a customer has given you to debit their payment method corresponding to this Direct Debit Request.

For online mandate acceptance, you can create a form to collect the necessary information. The form should be served over HTTPS and capture the following information:

Information Description
Account name The full name of the account holder
BSB number The Bank-State-Branch number of the bank account (eg. 123-456)
Account number The bank account number (eg. 87654321)

When collecting a Direct Debit Request, you should follow our BECS Direct Debit Terms and as part of your checkout form:

  • Display the exact terms of Stripe’s DDR service agreement either inline on the form, or on a page linked from the form, and identifying it as the “DDR service agreement”
  • Ensure the accepted DDR and its accompanying DDR service agreement can be shared with your customer at all times, either as a printed or non-changeable electronic copy (such as via email). Stripe will host this for you
  • Display the following standard authorization text for your customer to accept the BECS DDR, where you replace Rocketship Inc with your company name. Their acceptance authorizes you to initiate BECS Direct Debit payments from their bank account.

The details of the accepted mandate are generated when setting up a PaymentMethod or confirming a PaymentIntent. At all times, you should be able to share this mandate—the accepted DDR and its accompanying DDR service agreement—with your customer, either in print or as a non-changeable electronic copy (such as via email). Stripe hosts this for you under the url property of the Mandate object linked to the PaymentMethod. You can review an example of how this looks.

Add and configure an Australia Bank Account Element

The Australia Bank Account Element will help you collect and validate both the BSB number and the account number. It needs a place to live in your payment form. Create empty DOM nodes (container) with unique IDs in your payment form. Additionally, your customer must read and accept the Direct Debit Request service agreement.

<form action="/setup" method="post" id="setup-form"> <div class="form-row inline"> <div class="col"> <label for="accountholder-name"> Name </label> <input id="accountholder-name" name="accountholder-name" placeholder="John Smith" required /> </div> <div class="col"> <label for="email"> Email Address </label> <input id="email" name="email" type="email" placeholder="john.smith@example.com" required /> </div> </div> <div class="form-row"> <!-- Using a label with a for attribute that matches the ID of the Element container enables the Element to automatically gain focus when the customer clicks on the label. --> <label for="au-bank-account-element"> Bank Account </label> <div id="au-bank-account-element"> <!-- A Stripe Element will be inserted here. --> </div> </div> <!-- Used to display bank (branch) name associated with the entered BSB --> <div id="bank-name"></div> <!-- Used to display form errors. --> <div id="error-message" role="alert"></div> <!-- Display mandate acceptance text. --> <div class="col" id="mandate-acceptance"> By providing your bank account details, you agree to this Direct Debit Request and the <a href="https://stripe.com/au-becs-dd-service-agreement/legal">Direct Debit Request service agreement</a>, and authorise Stripe Payments Australia Pty Ltd ACN 160 180 343 Direct Debit User ID number 507156 (“Stripe”) to debit your account through the Bulk Electronic Clearing System (BECS) on behalf of Rocketship Inc. (the "Merchant") for any amounts separately communicated to you by the Merchant. You certify that you are either an account holder or an authorised signatory on the account listed above. </div> <!-- Add the client_secret from the SetupIntent as a data attribute --> <button id="submit-button" data-secret="{{CLIENT_SECRET}}">Set up BECS Direct Debit</button> </form>
/** * Shows how you can use CSS to style your Element's container. * These classes are added to your Stripe Element by default. * You can override these classNames by using the options passed * to the `iban` element. * https://stripe.com/docs/js/elements_object/create_element?type=iban#elements_create-options-classes */ input, .StripeElement { height: 40px; padding: 10px 12px; color: #32325d; background-color: white; border: 1px solid transparent; border-radius: 4px; box-shadow: 0 1px 3px 0 #e6ebf1; -webkit-transition: box-shadow 150ms ease; transition: box-shadow 150ms ease; } input:focus, .StripeElement--focus { box-shadow: 0 1px 3px 0 #cfd7df; } .StripeElement--invalid { border-color: #fa755a; } .StripeElement--webkit-autofill { background-color: #fefde5 !important; }

When the form loads, you can create an instance of the Australia Bank Account Element and mount it to the Element container:

// Custom styling can be passed to options when creating an Element var style = { base: { color: '#32325d', fontSize: '16px', '::placeholder': { color: '#aab7c4' }, ':-webkit-autofill': { color: '#32325d', }, }, invalid: { color: '#fa755a', iconColor: '#fa755a', ':-webkit-autofill': { color: '#fa755a', }, } }; var options = { style: style, disabled: false, hideIcon: false, iconStyle: "default", // or "solid" } // Create an instance of the auBankAccount Element. var auBankAccount = elements.create('auBankAccount', options); // Add an instance of the auBankAccount Element into // the `au-bank-account-element` <div>. auBankAccount.mount('#au-bank-account-element');
// Custom styling can be passed to options when creating an Element const style = { base: { color: '#32325d', fontSize: '16px', '::placeholder': { color: '#aab7c4' }, ':-webkit-autofill': { color: '#32325d', }, }, invalid: { color: '#fa755a', iconColor: '#fa755a', ':-webkit-autofill': { color: '#fa755a', }, } }; const options = { style: style, disabled: false, hideIcon: false, iconStyle: "default", // or "solid" } // Create an instance of the auBankAccount Element. const auBankAccount = elements.create('auBankAccount', options); // Add an instance of the auBankAccount Element into // the `au-bank-account-element` <div>. auBankAccount.mount('#au-bank-account-element');

Install React Stripe.js and the Stripe.js loader from the npm public registry.

npm install --save @stripe/react-stripe-js @stripe/stripe-js

We also provide a UMD build for sites that do not use npm or modules.

Include the Stripe.js script, which exports a global Stripe function, and the UMD build of React Stripe.js, which exports a global ReactStripe object. Always load the Stripe.js script directly from js.stripe.com to remain PCI compliant. Do not include the script in a bundle or host a copy of it yourself.

<!-- Stripe.js --> <script src="https://js.stripe.com/v3/"></script> <!-- React Stripe.js development build --> <script src="https://unpkg.com/@stripe/react-stripe-js@latest/dist/react-stripe.umd.js"></script> <!-- When you are ready to deploy your site to production, remove the above development script, and include the following production build. --> <script src="https://unpkg.com/@stripe/react-stripe-js@latest/dist/react-stripe.umd.min.js"></script>

Add Stripe.js and Elements to your page

To use Element components, wrap the root of your React app in an Elements provider. Call loadStripe with your publishable key and pass the returned Promise to the Elements provider.

import React from 'react'; import ReactDOM from 'react-dom'; import {Elements} from '@stripe/react-stripe-js'; import {loadStripe} from '@stripe/stripe-js'; import PaymentSetupForm from './PaymentSetupForm'; // Make sure to call `loadStripe` outside of a component’s render to avoid // recreating the `Stripe` object on every render. const stripePromise = loadStripe("pk_test_TYooMQauvdEDq54NiTphI7jx"); function App() { return ( <Elements stripe={stripePromise}> <PaymentSetupForm /> </Elements> ); }; ReactDOM.render(<App />, document.getElementById('root'));

Direct Debit Requests

Before you can create a BECS Direct Debit payment, your customer must agree with the Direct Debit Request Service Agreement. They do so by submitting a completed Direct Debit Request (DDR). The approval gives you a mandate to debit their account. The Mandate is a record of the permission a customer has given you to debit their payment method corresponding to this Direct Debit Request.

For online mandate acceptance, you can create a form to collect the necessary information. The form should be served over HTTPS and capture the following information:

Information Description
Account name The full name of the account holder
BSB number The Bank-State-Branch number of the bank account (eg. 123-456)
Account number The bank account number (eg. 87654321)

When collecting a Direct Debit Request, you should follow our BECS Direct Debit Terms and as part of your checkout form:

  • Display the exact terms of Stripe’s DDR service agreement either inline on the form, or on a page linked from the form, and identifying it as the “DDR service agreement”
  • Ensure the accepted DDR and its accompanying DDR service agreement can be shared with your customer at all times, either as a printed or non-changeable electronic copy (such as via email). Stripe will host this for you
  • Display the following standard authorization text for your customer to accept the BECS DDR, where you replace Rocketship Inc with your company name. Their acceptance authorizes you to initiate BECS Direct Debit payments from their bank account.

The details of the accepted mandate are generated when setting up a PaymentMethod or confirming a PaymentIntent. At all times, you should be able to share this mandate—the accepted DDR and its accompanying DDR service agreement—with your customer, either in print or as a non-changeable electronic copy (such as via email). Stripe hosts this for you under the url property of the Mandate object linked to the PaymentMethod. You can review an example of how this looks.

Add and configure an AuBankAccountElement component

The AuBankAccountElement component will help you collect and validate both the BSB number and the account number. Additionally, your customer must read and accept the Direct Debit Request service agreement.

/** * Use the CSS tab above to style your Element's container. */ import React from 'react'; import {AuBankAccountElement} from '@stripe/react-stripe-js'; import './BecsFormStyles.css' // Custom styling can be passed as options when creating an Element. const AU_BANK_ACCOUNT_STYLE = { base: { color: '#32325d', fontSize: '16px', '::placeholder': { color: '#aab7c4' }, ':-webkit-autofill': { color: '#32325d', }, }, invalid: { color: '#fa755a', iconColor: '#fa755a', ':-webkit-autofill': { color: '#fa755a', }, } }; const AU_BANK_ACCOUNT_ELEMENT_OPTIONS = { style: AU_BANK_ACCOUNT_STYLE, disabled: false, hideIcon: false, iconStyle: "default", // or "solid" }; export default function BecsForm({onSubmit, disabled}) { return ( <form onSubmit={onSubmit}> <div className="form-row inline"> <div className="col"> <label> Name <input name="accountholder-name" placeholder="John Smith" required /> </label> </div> <div className="col"> <label> Email Address <input name="email" type="email" placeholder="john.smith@example.com" required /> </label> </div> </div> <div className="form-row"> <label> Bank Account <AuBankAccountElement options={AU_BANK_ACCOUNT_ELEMENT_OPTIONS} /> </label> </div> {/* Display mandate acceptance text. */} <div className="mandate-acceptance"> By providing your bank account details, you agree to this Direct Debit Request and the <a href="https://stripe.com/au-becs-dd-service-agreement/legal">Direct Debit Request service agreement</a>, and authorise Stripe Payments Australia Pty Ltd ACN 160 180 343 Direct Debit User ID number 507156 (“Stripe”) to debit your account through the Bulk Electronic Clearing System (BECS) on behalf of Rocketship Inc. (the "Merchant") for any amounts separately communicated to you by the Merchant. You certify that you are either an account holder or an authorised signatory on the account listed above. </div> <button type="submit" disabled={disabled}>Set up BECS Direct Debit</button> </form> ); };
/** * Shows how you can use CSS to style your Element's container. * These classes are added to your Stripe Element by default. * You can override these classNames by using the options passed * to the IbanElement component. * https://stripe.com/docs/js/elements_object/create_element?type=iban#elements_create-options-classes */ input, .StripeElement { height: 40px; padding: 10px 12px; color: #32325d; background-color: white; border: 1px solid transparent; border-radius: 4px; box-shadow: 0 1px 3px 0 #e6ebf1; -webkit-transition: box-shadow 150ms ease; transition: box-shadow 150ms ease; } input:focus, .StripeElement--focus { box-shadow: 0 1px 3px 0 #cfd7df; } .StripeElement--invalid { border-color: #fa755a; } .StripeElement--webkit-autofill { background-color: #fefde5 !important; }

Elements are completely customizable. You can style Elements to match the look and feel of your site, providing a seamless checkout experience for your customers. It’s also possible to style various input states, for example when the Element has focus.

4 Submit the payment method details to Stripe Client-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 still 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.

Use stripe.confirmAuBecsDebitSetup to complete the setup when the user submits the form.

A successful setup will return a succeeded value for the SetupIntent’s status property. If the setup is not successful, inspect the returned error to determine the cause.

var form = document.getElementById('setup-form'); var accountholderName = document.getElementById('accountholder-name'); var email = document.getElementById('email'); var submitButton = document.getElementById('submit-button'); var clientSecret = submitButton.dataset.secret; form.addEventListener('submit', function(event) { event.preventDefault(); stripe.confirmAuBecsDebitSetup( clientSecret, { payment_method: { au_becs_debit: auBankAccount, billing_details: { name: accountholderName.value, email: email.value } } } ); });
const form = document.getElementById('setup-form'); const accountholderName = document.getElementById('accountholder-name'); const email = document.getElementById('email'); const submitButton = document.getElementById('submit-button'); const clientSecret = submitButton.dataset.secret; form.addEventListener('submit', async (event) => { event.preventDefault(); stripe.confirmAuBecsDebitSetup( clientSecret, { payment_method: { au_becs_debit: auBankAccount, billing_details: { name: accountholderName.value, email: email.value } } } ); });

After successfully confirming the SetupIntent, you should share the mandate URL from the Mandate object with your customer. We also recommend including the following details to your customer when you confirm their mandate has been established:

  • an explicit confirmation message that indicates a Direct Debit arrangement has been set up
  • the business name that will appear on the customer’s bank statement whenever their account gets debited
  • the payment amount and schedule (if applicable)
  • a link to the generated DDR mandate URL

The Mandate object’s ID is accessible from the mandate on the SetupIntent object, which is sent as part of the setup_intent.succeeded event sent after confirmation, but can also be retrieved through the API.

curl https://api.stripe.com/v1/setup_intents/{{SETUP_INTENT_ID}} \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d "expand[]"=mandate
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' intent = Stripe::SetupIntent.retrieve({ id: '{{SETUP_INTENT_ID}}', expand: ['mandate'] }); mandate = intent.mandate
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' intent = stripe.SetupIntent.retrieve( '{{SETUP_INTENT_ID}}', expand=['mandate'] ) mandate = intent.mandate
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $intent = \Stripe\SetupIntent::retrieve([ 'id' => '{{SETUP_INTENT_ID}}', 'expand' => ['mandate'] ]); $mandate = $intent->mandate;
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; List<String> expandList = new ArrayList<>(); expandList.add("mandate"); Map<String, Object> params = new HashMap<>(); params.put("expand", expandList); SetupIntent intent = SetupIntent.retrieve("{{SETUP_INTENT_ID}}", params, null); Mandate mandate = intent.getMandateObject();
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const intent = stripe.setupIntents.retrieve('{{SETUP_INTENT_ID}}', {expand: ['mandate']}); const mandate = intent.mandate;
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.SetupIntentParams{}; params.AddExpand("mandate"); intent, _ := setupintent.Get("{{SETUP_INTENT_ID}}", params); m := intent.Mandate;
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var intentService = new SetupIntentService(); var options = new SetupIntentGetOptions(); options.AddExpand("mandate"); SetupIntent intent = intentService.Get("{{SETUP_INTENT_ID}}", options); var mandateService = new MandateService(); Mandate mandate = mandateService.Get(intent.Mandate);

Use stripe.confirmAuBecsDebitSetup to complete the mandate collection when the user submits the form. Including the customer’s email address and the account holder’s name in the billing_details property of the payment_method parameter is required to create a BECS Direct Debit PaymentMethod.

To call stripe.confirmAuBecsDebitSetup from your payment form component, use the useStripe and useElements hooks.

If you prefer traditional class components over hooks, you can instead use an ElementsConsumer.

import React from 'react'; import {useStripe, useElements, AuBankAccountElement} from '@stripe/react-stripe-js'; import BecsForm from './BecsForm'; export default function PaymentSetupForm() { const stripe = useStripe(); const elements = useElements(); const handleSubmit = async (event) => { // We don't want to let default form submission happen here, // which would refresh the page. event.preventDefault(); if (!stripe || !elements) { // Stripe.js has not yet loaded. // Make sure to disable form submission until Stripe.js has loaded. return; } const auBankAccount = elements.getElement(AuBankAccountElement); // For brevity, this example is using uncontrolled components for // the accountholder's name and email. In a real world app you will // probably want to use controlled components. // https://reactjs.org/docs/uncontrolled-components.html // https://reactjs.org/docs/forms.html#controlled-components const accountholderName = event.target['accountholder-name']; const email = event.target.email; const result = await stripe.confirmAuBecsDebitSetup('{{CLIENT_SECRET}}', { payment_method: { au_becs_debit: auBankAccount, billing_details: { name: accountholderName.value, email: email.value, }, } }); if (result.error) { // Show error to your customer. console.log(result.error.message); } else { // Show a confirmation message to your customer. // The SetupIntent is in the 'succeeded' state. } }; return ( <BecsForm onSubmit={handleSubmit} disabled={!stripe} /> ); }
import React from 'react'; import {ElementsConsumer, AuBankAccountElement} from '@stripe/react-stripe-js'; import BecsForm from './BecsForm'; class PaymentSetupForm extends React.Component { handleSubmit = async (event) => { // We don't want to let default form submission happen here, // which would refresh the page. event.preventDefault(); const {stripe, elements} = this.props if (!stripe || !elements) { // Stripe.js has not yet loaded. // Make sure to disable form submission until Stripe.js has loaded. return; } const auBankAccount = elements.getElement(AuBankAccountElement); // For brevity, this example is using uncontrolled components for // the accountholder's name and email. In a real world app you will // probably want to use controlled components. // https://reactjs.org/docs/uncontrolled-components.html // https://reactjs.org/docs/forms.html#controlled-components const accountholderName = event.target['accountholder-name']; const email = event.target.email; const result = await stripe.confirmAuBecsDebitSetup('{{CLIENT_SECRET}}', { payment_method: { au_becs_debit: auBankAccount, billing_details: { name: accountholderName.value, email: email.value, }, } }); if (result.error) { // Show error to your customer. console.log(result.error.message); } else { // Show a confirmation message to your customer. // The SetupIntent is in the 'succeeded' state. } }; render() { const {stripe} = this.props; return ( <BecsForm onSubmit={this.handleSubmit} disabled={!stripe} /> ); } } export default function InjectedPaymentSetupForm() { return ( <ElementsConsumer> {({stripe, elements}) => ( <PaymentSetupForm stripe={stripe} elements={elements} /> )} </ElementsConsumer> ); }

After successfully confirming the SetupIntent, you should share the mandate URL from the Mandate object with your customer. We also recommend including the following details to your customer when you confirm their mandate has been established:

  • an explicit confirmation message that indicates a Direct Debit arrangement has been set up
  • the business name that will appear on the customer’s bank statement whenever their account gets debited
  • the payment amount and schedule (if applicable)
  • a link to the generated DDR mandate URL

The Mandate object’s ID is accessible from the mandate on the SetupIntent object, which is sent as part of the setup_intent.succeeded event sent after confirmation, but can also be retrieved through the API.

curl https://api.stripe.com/v1/setup_intents/{{SETUP_INTENT_ID}} \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d "expand[]"=mandate
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' intent = Stripe::SetupIntent.retrieve({ id: '{{SETUP_INTENT_ID}}', expand: ['mandate'] }); mandate = intent.mandate
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' intent = stripe.SetupIntent.retrieve( '{{SETUP_INTENT_ID}}', expand=['mandate'] ) mandate = intent.mandate
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $intent = \Stripe\SetupIntent::retrieve([ 'id' => '{{SETUP_INTENT_ID}}', 'expand' => ['mandate'] ]); $mandate = $intent->mandate;
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; List<String> expandList = new ArrayList<>(); expandList.add("mandate"); Map<String, Object> params = new HashMap<>(); params.put("expand", expandList); SetupIntent intent = SetupIntent.retrieve("{{SETUP_INTENT_ID}}", params, null); Mandate mandate = intent.getMandateObject();
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const intent = stripe.setupIntents.retrieve('{{SETUP_INTENT_ID}}', {expand: ['mandate']}); const mandate = intent.mandate;
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.SetupIntentParams{}; params.AddExpand("mandate"); intent, _ := setupintent.Get("{{SETUP_INTENT_ID}}", params); m := intent.Mandate;
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var intentService = new SetupIntentService(); var options = new SetupIntentGetOptions(); options.AddExpand("mandate"); SetupIntent intent = intentService.Get("{{SETUP_INTENT_ID}}", options); var mandateService = new MandateService(); Mandate mandate = mandateService.Get(intent.Mandate);

5 Create a customer with a PaymentMethod Server-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:

curl https://api.stripe.com/v1/customers \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d email="jenny.rosen@example.com" \ -d payment_method=pm_1FU2bgBF6ERF9jhEQvwnA7sX \ -d "invoice_settings[default_payment_method]"=pm_1FU2bgBF6ERF9jhEQvwnA7sX
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' # This creates a new Customer and attaches the default PaymentMethod in one API call. customer = Stripe::Customer.create({ payment_method: intent.payment_method, email: 'jenny.rosen@example.com', invoice_settings: { default_payment_method: intent.payment_method, }, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' # This creates a new Customer and attaches the default PaymentMethod in one API call. customer = stripe.Customer.create( payment_method=intent.payment_method, email='jenny.rosen@example.com', invoice_settings={ 'default_payment_method': intent.payment_method, }, )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); // This creates a new Customer and attaches the default PaymentMethod in one API call. $customer = \Stripe\Customer::create([ 'payment_method' => $intent->payment_method, 'email' => 'jenny.rosen@example.com', 'invoice_settings' => [ 'default_payment_method' => $intent->payment_method, ], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; /** * This creates a new Customer and attaches the default PaymentMethod in one API call. */ CreatePaymentBody postBody = gson.fromJson(request.body(), CreatePaymentBody.class); Map<String, Object> customerParams = new HashMap<String, Object>(); customerParams.put("payment_method", intent.getPaymentMethod()); customerParams.put("email", "jenny.rosen@example.com"); Map<String, String> invoiceSettings = new HashMap<String, String>(); invoiceSettings.put("default_payment_method", intent.getPaymentMethod()); customerParams.put("invoice_settings", invoiceSettings); Customer customer = Customer.create(customerParams);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); // This creates a new Customer and attaches the PaymentMethod in one API call. const customer = await stripe.customers.create({ payment_method: intent.payment_method, email: 'jenny.rosen@example.com', invoice_settings: { default_payment_method: intent.payment_method, }, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" customerParams := &stripe.CustomerParams{ PaymentMethod: stripe.String(intent.PaymentMethod.ID), Email: stripe.String("jenny.rosen@example.com"), InvoiceSettings: &stripe.CustomerInvoiceSettingsParams{ DefaultPaymentMethod: stripe.String(intent.PaymentMethod.ID), }, } c, _ := customer.New(customerParams)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new CustomerCreateOptions { Email = "jenny.rosen@example.com", PaymentMethod = intent.PaymentMethodId, InvoiceSettings = new CustomerInvoiceSettingsOptions { DefaultPaymentMethod = intent.PaymentMethodId, }, }; var service = new CustomerService(); Customer customer = service.Create(options);

This returns a Customer object. You can see the default payment method in the invoice_settings 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 },
See all 56 lines "livemode": false, "metadata": { }, "name": null, "phone": null, "preferred_locales": [ ], "shipping": null, "sources": { "object": "list", "data": [ ], "has_more": false, "total_count": 0, "url": "/v1/customers/cus_Gk0uVzT2M4xOKD/sources" }, "subscriptions": { "object": "list", "data": [ ], "has_more": false, "total_count": 0, "url": "/v1/customers/cus_Gk0uVzT2M4xOKD/subscriptions" }, "tax_exempt": "none", "tax_ids": { "object": "list", "data": [ ], "has_more": false, "total_count": 0, "url": "/v1/customers/cus_Gk0uVzT2M4xOKD/tax_ids" } }

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.

6 Create the subscription Server-side

To create a subscription, combine a price with a customer:

curl https://api.stripe.com/v1/subscriptions \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d customer=cus_Gk0uVzT2M4xOKD \ -d "items[0][price]"=price_F52b2UdntfQsfR \ -d "expand[0]"="latest_invoice.payment_intent"
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' subscription = Stripe::Subscription.create({ customer: customer.id, items: [ { price: 'price_FSDjyHWis0QVwl', }, ], expand: ['latest_invoice.payment_intent'], })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' subscription = stripe.Subscription.create( customer=customer.id, items=[ { 'price': 'price_FSDjyHWis0QVwl', }, ], expand=['latest_invoice.payment_intent'], )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $subscription = \Stripe\Subscription::create([ 'customer' => $customer->id, 'items' => [ [ 'price' => 'price_FSDjyHWis0QVwl', ], ], 'expand' => ['latest_invoice.payment_intent'], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; Map<String, Object> item = new HashMap<>(); item.put("price", "price_FSDjyHWis0QVwl"); Map<String, Object> items = new HashMap<>(); items.put("0", item); Map<String, Object> expand = new HashMap<>(); expand.put("0", "latest_invoice.payment_intent"); Map<String, Object> params = new HashMap<>(); params.put("customer", customer.getId()); params.put("items", items); params.put("expand", expand); Subscription subscription = Subscription.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const subscription = await stripe.subscriptions.create({ customer: customer.id, items: [ { price: 'price_FSDjyHWis0QVwl', }, ], expand: ['latest_invoice.payment_intent'] });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" items := []*stripe.SubscriptionItemsParams{ { Price: stripe.String("price_FSDjyHWis0QVwl"), }, } params := &stripe.SubscriptionParams{ Customer: stripe.String(customer.ID), Items: items, } params.AddExpand("latest_invoice.payment_intent") subscription, _ := sub.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var items = new List<SubscriptionItemOptions> { new SubscriptionItemOptions { Price = "price_CBXbz9i7AIOTzr" } }; var options = new SubscriptionCreateOptions { Customer = customer.Id, Items = items }; options.AddExpand("latest_invoice.payment_intent"); var service = new SubscriptionService(); Subscription subscription = service.Create(options);

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.

7 Manage subscription status Client-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.

8 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.

Account Number Description
000123456 PaymentIntents created with the resulting PaymentMethod will transition from processing to succeeded. The mandate status will remain active.
900123456 PaymentIntents created with the resulting PaymentMethod will transition from processing to succeeded (with a three-minute delay). The mandate status will remain active.
111111113 The PaymentIntent created with the resulting PaymentMethod will transition from processing to requires_payment_method with an account_closed failure code. The mandate status will become inactive at that point.
111111116 The PaymentIntent created with the resulting PaymentMethod will transition from processing to requires_payment_method with a no_account failure code. The mandate status will become inactive at that point.
222222227 PaymentIntents created with the resulting PaymentMethod will transition from processing to requires_payment_method with a refer_to_customer failure code. The mandate status will remain active.
922222227 PaymentIntents created with the resulting PaymentMethod will transition from processing to requires_payment_method with a refer_to_customer failure code (with a three-minute delay). The mandate status will remain active.
333333335 The PaymentIntent created with the resulting PaymentMethod will transition from processing to requires_payment_method with a debit_not_authorized failure code. The mandate status will become inactive at that point.

Optional Setting the billing cycle

By default, the billing cycles for subscriptions are set automatically when they’re created. For example, if a customer subscribes to a monthly plan on September 7th, they’re billed on the 7th of every month after that. Some businesses prefer to set the billing cycle manually so that their customers are charged at the same time. The billing cycle anchor argument allows you to do this.

curl https://api.stripe.com/v1/subscriptions \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d customer=cus_4fdAW5ftNQow1a \ -d "items[0][price]"=price_CBb6IXqvTLXp3f \ -d billing_cycle_anchor=1597841789
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' subscription = Stripe::Subscription.create({ customer: 'cus_4fdAW5ftNQow1a', items: [ { price: 'price_CBb6IXqvTLXp3f', }, ], billing_cycle_anchor: 1597841789, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' subscription = stripe.Subscription.create( customer='cus_4fdAW5ftNQow1a', items=[ { 'price': 'price_CBb6IXqvTLXp3f', }, ], billing_cycle_anchor=1597841789, )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $subscription = \Stripe\Subscription::create([ 'customer' => 'cus_4fdAW5ftNQow1a', 'items' => [ [ 'price' => 'price_CBb6IXqvTLXp3f', ], ], 'billing_cycle_anchor' => 1597841789, ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; SubscriptionCreateParams params = SubscriptionCreateParams.builder() .setCustomer("cus_4fdAW5ftNQow1a") .addItem( SubscriptionCreateParams.Item.builder() .setPrice("price_CBb6IXqvTLXp3f") .build()) .setBillingCycleAnchor(1597841789L) .build(); Subscription subscription = Subscription.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const subscription = await stripe.subscriptions.create({ customer: 'cus_4fdAW5ftNQow1a', items: [ { price: 'price_CBb6IXqvTLXp3f', }, ], billing_cycle_anchor: 1597841789, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" items := []*stripe.SubscriptionItemsParams{ { Price: stripe.String("price_CBb6IXqvTLXp3f"), }, } params := &stripe.SubscriptionParams{ Customer: stripe.String("cus_4fdAW5ftNQow1a"), Items: items, BillingCycleAnchor: stripe.Int64(1597841789), } subscription, _ := sub.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var items = new List<SubscriptionItemOptions> { new SubscriptionItemOptions {Price = "price_CBb6IXqvTLXp3f"} }; var options = new SubscriptionCreateOptions { Customer = "cus_4fdAW5ftNQow1a", Items = items, BillingCycleAnchor = DateTimeOffset.FromUnixTimeSeconds(1597841789).UtcDateTime, }; var service = new SubscriptionService(); Subscription subscription = service.Create(options);

When setting the billing cycle manually, the customer is automatically charged a prorated amount for the time between the subscription being created and the billing cycle anchor. If you don’t want to charge customers for this time, you can set the prorate argument to false. You can also combine the billing cycle anchor with trial periods to give users free access to your product and then charge them a prorated amount.

Optional Subscription trials

Free trials allow customers access to your product for a period of time for free. Using free trials is different from setting prorate to false because you can customize how long the free period lasts. You can set the trial period by passing a timestamp in the trial end argument.

curl https://api.stripe.com/v1/subscriptions \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d customer=cus_4fdAW5ftNQow1a \ -d "items[0][price]"=price_CBb6IXqvTLXp3f \ -d trial_end=1597236989
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' subscription = Stripe::Subscription.create({ customer: 'cus_4fdAW5ftNQow1a', items: [ { price: 'price_CBb6IXqvTLXp3f', }, ], trial_end: 1597236989, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' subscription = stripe.Subscription.create( customer='cus_4fdAW5ftNQow1a', items=[ { 'price': 'price_CBb6IXqvTLXp3f', }, ], trial_end=1597236989, )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $subscription = \Stripe\Subscription::create([ 'customer' => 'cus_4fdAW5ftNQow1a', 'items' => [ [ 'price' => 'price_CBb6IXqvTLXp3f', ], ], 'trial_end' => 1597236989, ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; SubscriptionCreateParams params = SubscriptionCreateParams.builder() .setCustomer("cus_4fdAW5ftNQow1a") .addItem( SubscriptionCreateParams.Item.builder() .setPrice("price_CBb6IXqvTLXp3f") .build()) .setTrialEnd(1597236989L) .build(); Subscription subscription = Subscription.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const subscription = await stripe.subscriptions.create({ customer: 'cus_4fdAW5ftNQow1a', items: [ { price: 'price_CBb6IXqvTLXp3f', }, ], trial_end: 1597236989, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" items := []*stripe.SubscriptionItemsParams{ { Price: stripe.String("price_CBb6IXqvTLXp3f"), }, } params := &stripe.SubscriptionParams{ Customer: stripe.String("cus_4fdAW5ftNQow1a"), Items: items, TrialEnd: stripe.Int64(1597236989), } subscription, _ := sub.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var items = new List<SubscriptionItemOptions> { new SubscriptionItemOptions {Price = "price_CBb6IXqvTLXp3f"} }; var options = new SubscriptionCreateOptions { Customer = "cus_4fdAW5ftNQow1a", Items = items, TrialEnd = DateTimeOffset.FromUnixTimeSeconds(1597236989).UtcDateTime, }; var service = new SubscriptionService(); Subscription subscription = service.Create(options);

You can combine a billing cycle anchor with a free trial if you want. For example, let’s say it’s September 15th and you want to give your customer a free trial for seven days and then start the normal billing cycle on October 1st. You can set the free trial to end on September 22nd and the billing cycle anchor to October 1st. This gives the customer a free trial for seven days and then charges a prorated amount for the time between the trial ending and October 1st. On October 1st, the customer is charged the normal subscription amount for their first full billing cycle.

Was this page helpful?
Questions? Contact us.
Developer tutorials on YouTube.
You can unsubscribe at any time. Read our privacy policy.