Billing Requests: PayTo Agreements and Payments
PayTo Agreements and Payments
PayTo is a new, efficient way to initiate real-time payments from customers’ bank accounts in Australia. GoCardless has implemented PayTo within Billing Requests to enable two key payments use cases:
Setting up an open mandate with your customer
Taking one-off real-time payments
A note on definitions: PayTo uses the term “agreement” to refer to the contract between the GoCardless customer and the end-customer. This concept matches that of the “mandate” so, for consistency, we use this term in the API and documentation instead. Please be aware that the terms are synonymous and that the end-customer will see the term “agreement” in the payment flow.
Goal - Create a PayTo mandate
Engineering complexity - Easy
Time taken - 15 minutes
As mentioned before, PayTo supports two key use cases:
Setting up an open mandate with your customer
Taking one-off real-time payments
To set up a mandate (the first use case) use the mandate_request field when creating your Billing Request. To create a real-time payment (the second use case) use the payment_request field when creating your Billing Request.
Most integrators will use Billing Requests to create a mandate alongside a new customer, so we’ll use that as our example.
Please keep in mind that the requirements below should be met to create a PayTo mandate successfully:
the scheme is stated as
pay_to
the
purpose_code
attribute is setthe
description
attribute is providedthe
constraints
object is optionally passed
Purpose Code
This attribute is required to create a PayTo mandate.
It specifies the high-level purpose of a mandate and/or payment using a set of pre-defined categories; mortgage
, utility
, loan
, dependant_support
, gambling
, retail
, salary
, personal
, government
, pension
, tax
and other
.
Constraints
constraints specify the limits on recurring payments. We can continue to take payments without the payer needing to provide consent every time as long as they are within the constraints stated during the set up of the PayTo mandate.
You can set the following parameters:
start_date
- the date from which the consent will be valid. It will be shown to a payer to confirm and hence should be considered in the payer timezone. This date cannot be older than the date when the payer authorises the consent. Therefore if you want to specify it, make sure that it is not in the past and that the payer has enough time to complete the flow before the date will come.end_date
- the date after which we will not be able to collect payments, as the consent stops being valid. It will be shown to a payer to confirm and hence should be considered in the payer timezone. This date cannot be in the past or older than the start date.max_amount_per_payment
- maximum amount that can be charged for a single payment.periodic_limits
- frequency configurationperiod
- repeating time frame presented as "year", "month", "week" or "day".max_payments
- maximum amount of payments that can be taken within a period
Use the Create a Billing Request endpoint:
1POST https://api.gocardless.com/billing_requests HTTP/1.1
2{
3 "billing_requests": {
4 "purpose_code": "mortgage",
5 "mandate_request": {
6 "currency": "AUD",
7 "scheme": "pay_to",
8 "constraints": {
9 "start_date": "2030-06-27",
10 "end_date": "2020-12-30",
11 "max_amount_per_payment": 100,
12 "periodic_limits": [{
13 "period": "month",
14 "max_payments": 2
15 }]
16 }
17 }
18 }
19}
You’ll receive a full Billing Request object, including things like actions and resources.
It will look like this:
1{
2 "billing_requests": {
3 "id": "BR123",
4 "status": "pending",
5 "mandate_request": {
6 "currency": "AUD",
7 "scheme": "pay_to",
8 "constraints": {
9 "start_date": "2030-06-27",
10 "end_date": "2020-12-30",
11 "max_amount_per_payment": 100,
12 "periodic_limits": [{
13 "period": "month",
14 "max_payments": 2
15 }]
16 }
17 },
18 "payment_request": null,
19 "metadata": null,
20 "links": {
21 "customer": "CU123",
22 "customer_billing_detail": "CBD123",
23 "creditor": "CR123",
24 "organisation": "OR123",
25 "mandate_request": "MRQ123"
26 },
27 "purpose_code": "mortgage",
28 "creditor_name": "Hotel Park Grand",
29 "actions": [
30 {
31 "type": "collect_customer_details",
32 "required": true,
33 "status": "pending",
34 },
35 {
36 "type": "collect_bank_account",
37 "required": true,
38 "status": "pending"
39 },
40 {
41 "type": "bank_authorisation",
42 "required": true,
43 "status": "pending",
44 }
45 ],
46
47 }
48}
The Billing Request is currently pending
, meaning we need to complete the outstanding actions before it can be fulfilled. We can use Billing Request Flows to generate a checkout flow that guides the payer through these actions.
Goal - Create a Billing Request Flow that can be used for your customer to authorise payments
Engineering complexity - Easy
Time taken - 15 minutes
Billing Request Flows can be created against Billing Requests, and provide an entry into a hosted GoCardless flow that completes whatever actions remain against the request.
Create a Billing Request Flow to retrieve a link that can be provided to your customer to complete the request:
1$client = new \GoCardlessPro\Client(array(
2 'access_token' => 'your_access_token_here',
3 'environment' => \GoCardlessPro\Environment::SANDBOX
4));
5
6$client->billingRequestFlows()->create([
7 "params" => [
8 "redirect_uri" => "https://my-company.com/landing",
9 "exit_uri" => "https://my-company.com/exit",
10 "links" => [
11 "billing_request" => "BRQ000010NMDMH2"
12 ]
13 ]
14]);
This returns a new flow, which has an authorisation_url
you should send to your customer:
1{
2 "billing_request_flows": {
3 "authorisation_url": "https://pay.gocardless.com/billing/static/flow?id=<brf_id>",
4 "lock_customer_details": false,
5 "lock_bank_account": false,
6 "auto_fulfil": true,
7 "created_at": "2021-03-30T16:23:10.679Z",
8 "expires_at": "2021-04-06T16:23:10.679Z",
9 "redirect_uri": "https://my-company.com/completed",
10 "links": {
11 "billing_request": "BRQ123"
12 }
13 }
14}
15
Share your authorisation link from the response in Step 02, via a button on your website, SMS, email, or any other way you like.
Preview what your customer will see by following the steps below.
Goal - Retain your customers with an Exit URI
Engineering complexity - Easy
Time taken - 5 minutes
Some customers may not be able to authorise the PayTo transaction through the Billing Request Flow. Their bank may not support PayTo yet, for instance.
To retain these customers and let them pay another way, you may pass an Exit URI which will send them wherever you choose in order to complete the transaction. It’s as simple as providing the address you’d like us to return the customer to.
Provide an Exit URI when creating the Billing Request Flow
You may pass a exit_uri
when creating the Billing Request Flow, the same way you pass the redirect_uri
.
Note: We recommend that you return customers to your checkout page, at the point of choosing a payment method.
1$client = new \GoCardlessPro\Client(array(
2 'access_token' => 'your_access_token_here',
3 'environment' => \GoCardlessPro\Environment::SANDBOX
4));
5
6$client->billingRequestFlows()->create([
7 "params" => [
8 "redirect_uri" => "https://my-company.com/landing",
9 "exit_uri" => "https://my-company.com/exit",
10 "links" => [
11 "billing_request" => "BRQ000010NMDMH2"
12 ]
13 ]
14]);
This returns a new flow which includes the exit_uri being passed:
1{
2 "billing_request_flows": {
3 "authorisation_url": "https://pay.gocardless.com/billing/static/flow?id=<brf_id>",
4 "lock_customer_details": false,
5 "lock_bank_account": false,
6 "auto_fulfil": true,
7 "created_at": "2021-03-30T16:23:10.679Z",
8 "expires_at": "2021-04-06T16:23:10.679Z",
9 "redirect_uri": "https://my-company.com/completed",
10 "links": {
11 "billing_request": "BRQ123"
12 }
13 }
14}
15
Customers will be sent to this URI when they click on the Exit URI in the Billing Request Flow.
Customer uses the Exit URL to return to your checkout
The Exit URL is shown if the customer’s PayID or bank details match to a bank that isn’t supported for PayTo
If you are creating a new mandate or real-time payment for an existing customer, you may let the customer skip some steps.
If you’ve seen this customer before, you may specify the customer ID in links.customer
field of the Billing Request. This will result in the CollectCustomerDetails page being skipped. The user may be allowed to edit these details unless the customer has been locked (see locking components below).
A Bank account already exists- in this case, we do not show the CollectBankAccount page however the user may be allowed to create a new bank account and use that for the payment unless the bank account has been locked (see locking components)
Existing customers or banks can be attached to the Billing Request when it is created, an example of this might be when creating a “top-up” single payment for a customer you already have a relationship with.
Along with knowing the customer's details and the bank account you may wish to “lock” the request to only allow the customer to use those details. This allows you to ensure the payment is taken using details you have already collected for this customer in your own systems.
You can lock the customer, the bank account or both. This is done when creating the Billing Request Flow by setting lock_customer_details
or lock_bank_account
to true.
If a linked resource is locked the following happens:
Customer locked - The CollectCustomerDetails page is not shown and the customer cannot open them for editing
Bank account locked - The CollectBankAccount page is not shown and the customer cannot add another bank account to use instead
If both are locked then we skip almost every page and go directly to the confirmation page within the BankHandoff component. All the payer needs to do is confirm and possibly authenticate with the bank if it is required.
For mandate only requests, you may also "lock" the currency and scheme that the customer pays in. By default, mandate only requests have the currency/scheme "unlocked" so that the customer can set up their mandate in any of your available schemes. If you lock the currency, however, they will only be able to pay with the scheme you specified when creating the Billing Request. This can be useful if you only want to allow a customer to pay in one specific scheme.
This can be achieved by setting lock_currency
to true on the Billing Request Flow. In this case a currency selector will not show in the payment page UI for the payer, and they will be unable to change currency.
What the customer will see
The customer provides their personal details in the first screen.
Note: this screen is skipped if the details already exist, or the customer details have been locked.
The customer provides their PayID or bank details in order to complete this step.
Note: this screen is skipped if the details already exist or the bank account is locked.
The customer has provided enough information for the transaction to be initiated with their bank. They are prompted to complete the process in their banking application. Depending on the bank they are with, they may also get a push notification to their device or an SMS.
Once the payer has completed the authorisation process, there is a confirmation page. All the required actions have been completed and the Billing Request is fulfilled.
Done!
The PayTo agreement/mandate has now been created and is ready to create payments against. The Billing Request is fulfilled, and cannot be modified.
What’s next?
Responding to Billing Requests events
Get started
First instant payment with mandate Direct Debit set up
For partners
Go to Partner PortalTo learn more about technical and UX requirements