Make a payment recurrent
In this guide you will make recurring payments. To ease the subsequent payments event, an initial checkout is authenticated according to 3DS checks. All following checkouts refer to the initial one in terms of 3DS authentication.
You will go through the following steps:
- Create a checkout with customer identification
- Process checkout and indicate payment type in request
- Process future subsequent payments with token
Steps
1. Create a checkout with customer identification
The flow is initiated with the create a checkout
endpoint. It is important to pass the customer_id
parameter in this step, for future linking to a payment instrument, ideal for quickly creating and processing later payments. Additionally, a purpose
parameter is passed to indicate the payment type as recurrent and process an authorisation charge of the checkout amount indicated, which is instantly reimbursed.
{
...
"purpose": "setup_recurring_payment"
...
}
The initial checkout may be subject to the 3DS challenge, depending on multiple factors described briefly here.
Sample request available in our API Reference.
{
"checkout_reference": "CO746453",
"amount": 5,
"currency": "EUR",
"merchant_code": "ME7RMQN3",
"pay_to_email": "user@example.com",
"description": "Sample request",
"return_url": "http://example.com",
"customer_id": "DC000101"
}
2. Process checkout and indicate payment type in request
Next, at checkout processing you must pass a mandate
object that consists of key data for initiating recurrent payments. The mandate
object will indicate to store the identified card for recurrent payments and that it contains customer approval of such. The result is a newly created token, tied to the customer_id
you've initiated at the checkout creation step.
{
"payment_type": "card",
"installments": 1,
"card":
{
"name": "FIRSTNAME LASTNAME",
"number": "4111111111111111",
"expiry_year": "2023",
"expiry_month": "01",
"cvv": "123",
"zip_code": "12345"
},
"mandate": {
"type" : "recurrent",
"user_agent": "Chrome: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36.",
"user_ip" : "2001:0db8:85a3:0000:0a00:8a2e:0370:7300"
}
}
3. Process future subsequent payments with a token
After following the above requests you can list your checkouts to retrieve a customer's token and process recurring payments by referencing it.
{
"id": "cd36780e-f43d-4f22-1i9e-e32a1a1bafc8",
"checkout_reference": "0BYNWLYC7KV",
"amount": 3.51,
"currency": "EUR",
...
"payment_instrument": {
"token": "2fa27578-e765-5dbh-aa97-d45d3d6cdfbb"
}
}