API Developmentrecurring-payments

Draft Setup Billing Agreement Approval

A billing agreement is a contract between the merchant and the customer. Clearpay sets the agreement that authorises the merchant to create and pay for orders. This step sets up the Billing Agreement ready for it to be created.

The process starts with the following POST:

POST /v2/billing-agreements/approvals

This offers billing agreement terms to the customer for them to accept or reject. Assuming they accept the billing agreement terms, the flow continues. A sample request is:

1POST https://api-sandbox.afterpay.com/v2/billing-agreements/approvals HTTP/1.1
2Host: api-sandbox.afterpay.com
3Content-Type: application/json
4Accept: application/json

Request Parameters

NameInTypeRequiredDescription
bodybodyBillingAgreementApprovalRequestNo

Example Request Body

1{
2 "consumer": {
3 "phoneNumber": "0400 000 000",
4 "givenNames": "Joe",
5 "surname": "Customer",
6 "email": "test@example.com"
7 },
8 "agreements": [
9 {
10 "type": "BILLING",
11 "merchantReference": "merchant-billing-agreement-1234",
12 "pageUrl": "https://merchant.com/payment-methods"
13 }
14 ],
15 "merchantReference": "merchant-payment-method-registration-1234",
16 "merchant": {
17 "redirectConfirmUrl": "http://merchant.com/confirm",
18 "redirectCancelUrl": "http://merchant.com/cancel"
19 }
20}

Responses

StatusMeaningDescriptionSchema
200OKSucessfulCheckoutTokenResponse

Example Responses

200 Response

1{
2 "expires": "2019-08-24T14:15:22Z",
3 "token": "003._7IgXzApNiRoxpEb04LbAFQShsvdE_H3",
4 "redirectCheckoutUrl": "https://afterpay.com/checkout"
5}
Warning - tokens

Recurring Payments needs two tokens. The token above is the Billing Agreement token. There is also a Checkout token. Do not confuse the two tokens.

Note

To handle the response, you must be authenticated by MerchantAuthentication.

Now the Billing Agreement is setup, you must create the Billing Agreement itself. See the Create Billing Agreement topic for that information.

Recurring Payments - More Information