GoCardlessDeveloper Docs
Create a sandbox account

Billing Request Component#

View as Markdown

The Billing Request component guides the payer through a Billing Request — the GoCardless object that brings together the customer, their authorisation, and their bank details into a single, manageable object (see the Billing Requests overview for more). Depending on the Billing Request, it can:

This page covers what both have in common. Before you start, complete the general setup (access token and session token endpoint) and configure the library.

1. Mount the component#

Create a <div> where you want the component to appear:

<div id="gc-billing"></div>

Then create the component and mount it. The options you pass depend on the flow, see Setting up mandates and Pay By Bank.

const brComponent = gc.createComponent("billing-request", {
  // options, see below
  onError: (error) => console.error("Error: ", error),
});
 
brComponent.mount("#gc-billing");

2. Options#

These options work the same in every flow:

PropertyDescriptionRequired
prefilledCustomerPrefills the customer/billing details form (see Prefilled customer details)No
appearanceCustom appearance configuration, merged on top of the top-level appearanceNo
onError(error: GoCardlessError) => void — called on error, in addition to the event busNo

The remaining options depend on the flow, see the options of Setting up mandates and Pay By Bank.

3. Prefilled customer details#

Pass prefilledCustomer when creating the component to pre-populate the customer details form, in both mandate and Pay By Bank flows. It also pre-populates the Direct Debit form shown if a Pay By Bank payment falls back. Bank details cannot be prefilled for security reasons.

const gc = GcComponents.init({
  environment: "sandbox",
  sessionToken: fetchSessionToken,
});
 
const brComponent = gc.createComponent("billing-request", {
  prefilledCustomer: {
    firstName: "Components",
    lastName: "Tester",
    email: "components-tester@example.com",
    addressLine1: "65 Goswell Road",
    addressLine2: "",
    city: "London",
    postalCode: "EC1V 7EN",
  },
});
 
brComponent.mount("#gc-billing");

Prefilled form

4. Remember Me#

Remember Me lets returning payers skip re-entering their details: when a payer enters an email address GoCardless has seen before, they verify their identity and their saved details are pre-filled. New payers can opt in to have their details saved for next time.

Remember Me is built into the Billing Request component and appears automatically, so there is nothing extra to install or configure. It currently supports the Bacs scheme only.

If you are building a custom checkout and want to use Remember Me without the Billing Request component, see Remember Me Components for the standalone components.

What's next?#