Custom Payment Page Tools
Custom Payment Page Tools is a collection of tools designed to minimise effort in building your own payments UI powered by GoCardless billing APIs. They can be effortlessly utilised when developing a custom web UI with different JS frameworks or in mobile development with WebViews.
At the moment the following tools are available:
compliance.js
Compliance.js
It adds elements to the HTML layout of custom payment pages to make the UI compliant. For example, for bank authorisation, you must append the GoCardless legal note with Payer Terms of Use and Privacy Notice links before starting the bank authorisation process for Instant Bank Pay or Variable Recurring Payments in the UK.
Getting started
Include compliance.js
with a script tag in the head section of your index.html
:
<head>
...
<script src="https://custom-payment-page-tools.gocardless.com/compliance.js"></script>
</head>
Once the script is loaded, your application can use the GoCardlessCompliance
client, as it is added globally in window
. Let's now call render
:
window.GoCardlessCompliance.render("BRQ123", "bank-authorisation");
The render
method requires the following parameters:
A valid
Billing Request Id
to display elements and content dependent on the bank scheme.namespace
to display elements and content relevant to a particular step in the flow. Available options:"bank_authorisation"
.
Testing
To test the integration with GoCardless Sandbox before going live, include compliance.js
with the sandbox
value in the environment
attribute. If nothing is passed, the production environment will be used.
<script src="https://custom-payment-page-tools.gocardless.com/compliance.js" environment="sandbox"></script>
Render options
You can pass the options
object to define the position of the compliance elements in your layout or change basic styles for the light/dark mode.
Name | Type | Default | Description |
---|---|---|---|
parentId | string | The component will be attached as the last child of | Id of an existing HTML element in the document to render the component in. |
theme |
|
| The colour theme |
const options = {
parentId: "my-element-id",
theme: "dark"
};
window.GoCardlessCompliance.render(
"BRQ123",
"bank-authorisation",
options
);
Using with JS frameworks
We suggest separating the GoCardlessCompliance.render
call into an independent component to be used across your application. We also recommend generating unique identifiers for the containers where compliance elements are supposed to be rendered for each instance.
Error Handling
Error | Reasons |
---|---|
A valid billingRequestId is required | You haven't passed a Billing Request Id in the |
Namespace must be one of ... | You haven't passed a valid namespace in the |
The parent element doesn't exist in the document | We haven't found any element in your |
GoCardless API returned an error when trying to get payment flow details | We weren't able to get payment flow details to show relevant elements: very likely you have used an invalid Billing Request Id or a valid one but for the wrong environment. |