Billing Request (PayTo feature)
Billing Request actions
In order to access the following endpoints and complete the required actions integrators will need the custom payment pages upgrade enabled on their account.
Billing Request Actions
Whenever you create a Billing Request, it will have a list of actions
that require completion before it’s possible to fulfil the request.
The possible actions are:
collect_customer_details
, collect customer details required for the schemescollect_bank_account
, create the bank account for the mandate/paymentbank_authorisation
, have the payer authorise the billing request via their bank if requiredconfirm_payer_details
, confirm customer and bank account details provided by the payer
Once all required actions have been completed, the Billing Request will fulfil
automatically.
Which actions should I implement?
Even if integrators complete a selection of actions themselves, Billing Request Flows can be used to complete the remaining actions.
Our recommendations for whether integrators should implement each action are:
collect_customer_details
, implement this if you want a white label flow to collect customer details or have already collected the details (prefilling, etc)collect_bank_account
, as with customer details, but be aware that Billing Request Flows can avoid this step for certain schemes which can improve conversion by reducing the number of details a payer has to manually inputconfirm_payer_details
, this action is not required for PayTo.bank_authorisation
, implement this as the final step
The actions presented on a Billing Request are unordered, but each action may have dependencies, or have other actions depending on it.
These are specified in the fields completes_actions
and requires_actions
.
Taking a bank_authorisation
as an example:
1{
2 "type": "bank_authorisation",
3 "status": "completed",
4 "required": true,
5 "completes_actions": [
6 "collect_customer_details"
7 ],
8 "requires_actions": [
9 "collect_bank_account"
10 ]
11}
Action status
is either pending
or completed
.
requires_actions:
Actions can only be executed if the actions listed in requires_action
have been completed- in this example, we can’t complete the bank authorisation until we’ve collected the bank.
completes_actions:
Actions can complete other actions, which can help streamline checkout flows. The example shows how a bank authorisation might collect customer details, completing that action as a side effect.
For most integrators, we suggest building flows that process actions in the order of:
collect_customer_details
, so customer contact details are prioritisedcollect_bank_account
, if it is required and another action won’t complete itbank_authorisation
, as the penultimate step before completing the checkout flowconfirm_payer_details
, only applicable if it is amandate_request
The hosted checkout flow provided by Billing Request Flows is built to optimise conversion, and will follow the minimum number of steps to fulfil the Billing Request. Most integrators should lean on the flow to complete anything beyond collection of customer details.
Action: collect_customer_details
Billing Requests aim to create billing resources against a customer, either a mandate (PayTo or Direct Debit), an Instant Bank Payment, or both.
Payment schemes vary in what customer details you are required to collect. The collect_customer_details
action is about collecting all the details required by either the mandate or the payment scheme, to ensure we meet regulatory needs.
As an example, we can create a Billing Request for a AUD mandate:
1POST /billing_requests
2{
3 "billing_requests": {
4 "mandate_request": {
5 "currency": "AUD"
6 }
7 }
8}
This returns a Billing Request that looks like this:
1{
2 "billing_requests": {
3 "id": "BRQ000010NMDMH2",
4 "status": "pending",
5 "mandate_request": {
6 "scheme": "pay_to",
7 "currency": "AUD"
8 },
9 "links": {
10 "customer": "CU00016WDAM7BS",
11 "customer_billing_detail": "CBD000010P52VRF",
12 "organisation": "OR123"
13 },
14 "actions": [
15 {
16 "type": "collect_customer_details",
17 "required": true,
18 "completes_actions": [],
19 "requires_actions": [
20 "choose_currency"
21 ],
22 "status": "pending",
23 "collect_customer_details": {
24 "incomplete_fields": {
25 "customer": [
26 "email",
27 "given_name",
28 "family_name"
29 ],
30 "customer_billing_detail": [
31 "address_line1",
32 "city",
33 "postal_code",
34 "country_code"
35 ]
36 }
37 }
38 },
39 ...,
40 ],
41 "resources": {
42 "customer": {
43 "id": "CU00016WDAM7BS",
44 "created_at": "2021-04-08T14:06:30.977Z",
45 "email": null,
46 "given_name": null,
47 "family_name": null,
48 "company_name": null,
49 "language": "en",
50 "phone_number": null,
51 "metadata": {}
52 },
53 "customer_billing_detail": {
54 "id": "CBD000010P52VRF",
55 "created_at": "2021-04-08T14:06:30.997Z",
56 "address_line1": null,
57 "address_line2": null,
58 "address_line3": null,
59 "city": null,
60 "region": null,
61 "postal_code": null,
62 "country_code": null,
63 "swedish_identity_number": null,
64 "danish_identity_number": null
65 }
66 }
67 }
68}
Note that:
There is a
collect_customer_details
action, which ispending
A new customer has been created for us, as the Billing Request wasn’t attached to an existing customer
The
customer
resource is presented back to us, and they have no filled fieldsThe
collect_customer_details
action is designed to help us collect the required information from our customers.
Taking a closer look at the action:
1{
2 "type": "collect_customer_details",
3 "required": true,
4 "completes_actions": [],
5 "requires_actions": [
6 "choose_currency"
7 ],
8 "status": "pending",
9 "collect_customer_details": {
10 "incomplete_fields": {
11 "customer": [
12 "email",
13 "given_name",
14 "family_name"
15 ],
16 "customer_billing_detail": [
17 "address_line1",
18 "city",
19 "postal_code",
20 "country_code"
21 ]
22 }
23 }
24}
The collect_customer_details.incomplete_fields
object tells us what fields we need to collect, for both resources. Which fields are required changes depending on the schemes of the mandate (or payment).
We can complete this action by POST’ing to the Collect customer details for the billing request endpoint:
1$client = new \GoCardlessPro\Client(array(
2 'access_token' => 'your_access_token_here',
3 'environment' => \GoCardlessPro\Environment::SANDBOX
4));
5
6$client->billingRequests()->collectCustomerDetails("BR123", [
7 "params" => [
8 "customer" => [
9 "given_name" => "Alice",
10 "family_name" => "Smith"
11 ],
12 "customer_billing_detail" => [
13 "address_line1" => "1 Somewhere Lane"
14 ]
15 ]
16]);
As with all action endpoints, the response is the Billing Request. What we get back is:
1{
2 "billing_requests": {
3 "id": "BRQ000010NMDMH2",
4 "status": "pending",
5 "mandate_request": {
6 "scheme": "pay_to",
7 "currency": "AUD",
8 },
9 "links": {
10 "customer": "CU00016WDAM7BS",
11 "customer_billing_detail": "CBD000010P52VRF",
12 "organisation": "OR123"
13 },
14 "actions": [
15 {
16 "type": "collect_customer_details",
17 "required": true,
18 "completes_actions": [],
19 "requires_actions": [
20 "choose_currency"
21 ],
22 "status": "completed",
23 "collect_customer_details": {
24 "incomplete_fields": {
25 "customer": [],
26 "customer_billing_detail": []
27 }
28 }
29 },
30 ...,
31 ],
32 "resources": {
33 "customer": {
34 "id": "CU00016WDAM7BS",
35 "created_at": "2021-04-08T14:06:30.977Z",
36 "email": "paddington@bearthings.com",
37 "given_name": "Paddington",
38 "family_name": "Bear",
39 "company_name": null,
40 "language": "en",
41 "phone_number": null,
42 "metadata": {}
43 },
44 "customer_billing_detail": {
45 "id": "CBD000010P52VRF",
46 "created_at": "2021-04-08T14:06:30.997Z",
47 "address_line1": "32 Windsor Gardens",
48 "address_line2": null,
49 "address_line3": null,
50 "city": "London",
51 "region": null,
52 "postal_code": "W9 3RG",
53 "country_code": "GB",
54 "swedish_identity_number": null,
55 "danish_identity_number": null
56 }
57 }
58 }
59}
Note that:
The
collect_customer_details
action is nowcompleted
, meaning we can move on to other actionsAs a result of us collecting the details, our
customer
andcustomer_billing_detail
has been populated with the details we collected
Most integrators will collect these details via web forms, filled by their payers. Integrators are expected to build forms that can collect all possible customer
and customer_billing_detail
fields (see the Collect customer details schema) but only display the inputs required, as per incomplete_fields
.
Depending on the scheme, we might need to collect bank account details before fulfilling the Billing Request. An example is a PayTo mandate, where we need to capture the payer’s bank in order to create payments against them.
As an example, we can create a Billing Request for a PayTo mandate:
1POST /billing_requests
2{
3 "billing_requests": {
4 "mandate_request": {
5 "currency": "AUD"
6 }
7 }
8}
This returns a Billing Request that looks like this:
1{
2 "billing_requests": {
3 "id": "BRQ000010NMDMH2",
4 "status": "pending",
5 "mandate_request": {
6 "currency": "AUD",
7 "scheme": "pay_to",
8 },
9 "links": {
10 "customer": "CU00016WDAM7BS",
11 "customer_billing_detail": "CBD000010PAJ810",
12 "organisation": "OR123"
13 },
14 "actions": [
15 {
16 "type": "collect_bank_account",
17 "required": true,
18 "completes_actions": [
19 "choose_currency"
20 ],
21 "requires_actions": [],
22 "status": "pending"
23 },
24 ...,
25 ],
26 }
27}
Note that:
There is a
collect_bank_account
action that ispending
We have no
links.customer_bank_account
, confirming no bank account is attached
We can complete this action by POST’ing to the Collect bank account for the billing request endpoint:
1POST /billing_requests/BRQ000010NMDMH2/actions/collect_bank_account HTTP/1.1
2{
3 "data": {
4 "pay_id": "12345678900",
5 "country_code": "AU"
6 }
7}
As with all action endpoints, the response is the Billing Request. What we get back is:
1{
2 "billing_requests": {
3 "id": "BRQ000010NMDMH2",
4 "status": "ready_to_fulfil",
5 "mandate_request": {
6 "scheme": "pay_to",
7 "currency": "AUD"
8 },
9 "links": {
10 "customer": "CU00016WDAM7BS",
11 "customer_billing_detail": "CBD000010P52VRF",
12 "customer_bank_account": "BA0000QDWEEAFB",
13 "organisation": "OR123"
14 },
15 "actions": [
16 {
17 "type": "collect_bank_account",
18 "required": true,
19 "completes_actions": [
20 "choose_currency"
21 ],
22 "requires_actions": [],
23 "status": "completed"
24 },
25 ...,
26 ],
27 "resources": {
28 "customer_bank_account": {
29 "id": "BA0000QDWEEAFB",
30 "created_at": "2021-04-08T15:30:36.019Z",
31 "account_number_ending": "70",
32 "account_holder_name": "PADDINGTON BEAR",
33 "account_type": null,
34 "bank_name": "NATIONAL AUSTRALIA BANK",
35 "currency": "AUD",
36 "country_code": "AU",
37 "metadata": {},
38 "enabled": true,
39 "links": {
40 "customer": "CU00016WDAM7BS"
41 }
42 }
43 }
44 }
45}
Note that:
The
collect_bank_account
action is nowcompleted
, meaning we can move on to other actionsAs a result of us collecting the bank account, we have created a
customer_bank_account
resource and you can see thelinks.customer_bank_account
ID has been set
We advise most integrators use Billing Request Flows to complete this action, as the hosted flows will try skipping this action if it can be fulfilled by another (such as bank authorisation).
To authorise the PayTo mandate, the payer needs to log in to their bank. This is initiated by the bank_authorisation.
In other words, hitting the bank_authorisation endpoint will trigger the creation of the PayTo mandate which is the final action required. The rest is up to the payer. As an example, we can create a Billing Request for PayTo:
1POST /billing_requests
2{
3 "billing_requests": {
4 "mandate_request": {
5 "currency": "AUD"
6 }
7 }
8}
This returns a Billing Request that looks like this:
1{
2 "billing_requests": {
3 "id": "BRQ000010NVSP5H",
4 "status": "pending",
5 "mandate_request": {
6 "currency": "AUD",
7 "scheme": "pay_to",
8 },
9 "actions": [
10 {
11 "type": "bank_authorisation",
12 "required": true,
13 "completes_actions": [],
14 "requires_actions": [
15 "collect_bank_account"
16 ],
17 "status": "pending"
18 },
19 ...,
20 ]
21 }
22}
Preventing Breaking changes
In order to automatically receive new features and always remain scheme compliant without having to change your integration, GoCardless will need to adjust actions by adding new actions or making optional actions required. This means it will break your integration if you don’t fall back to Billing Request Flow. Therefore if you are building custom payment pages you needs to Implement the actions you are aware of and want to process.
If you reach the last action and the Billing Request is still pending
(as opposed to ready_to_fulfil
or fulfilled
), then you need to create a Billing Request Flow and send the payers through that flow.
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