Payment method tokenization
Tokenization is the process by which confidential payment data of customers can be securely stored by creating a token. To create a token, the following steps must be followed:
- Obtain the UUID of the customer;
- Purchase through checkout using the registered customer id.
1. Obtain the UUID of the customer
The first step is to obtain the UUID of the customer who wants to register his/her payment method. This can be done through:
2. Complete payment through checkout
For the payment method to be available a successful payment must be completed.
POST /checkouts
- Request
- Response
{
"payment": {
"amount": 100,
"recurring": {
"amountQualifier": "ESTM" // <== Montante váriável
},
"customer": {
"uuid": "e2343605-cf46-43de-b20b-9b7d1c95a9b2" // <== ID do customer registado
},
"paymentMethod": {
"code": "CC",
"details": {
"createRegistration": true // <== Indicar que é para criar token
}
}
},
"page": {
"language": "PT"
}
}
{
"apiVersion": "1.0",
"date": "2021-10-20T11:34:48+01:00",
"success": true,
"data": {
"id": "Qldt1DlonfiF4HthdiCfB1DRmgM31LzmVrFjU6jk",
"createdAt": "2021-10-20 11:34:48",
"checkoutUrl": "http://paypay.acin.pt/paypaybeta/checkout/v2/form/Qldt1DlonfiF4HthdiCfB1DRmgM31LzmVrFjU6jk",
"paymentId": "42380",
"stateDetails": {
"state": "PaymentReady",
"timestamp": "2021-10-20T11:34:48+01:00"
}
}
}
3. View customer payment methods
Once the payment has been successfully completed, the payment method is added to the payment methods of the customer.
GET /customers/{uuid}/paymentMethods
{
"apiVersion": "1.0",
"date": "2021-09-24T17:57:42+01:00",
"success": true,
"data": [
{
"type": "CC",
"uuid": "90068f83-7623-4de5-91c7-ac447c504ebf",
"brand": "VISA",
"last4Digitis": "0809",
"holder": "Luís Gonçalves",
"expireMonth": "05",
"expireYear": "2026"
},
{
"type": "MW",
"uuid": "45668f83-7623-4de5-91c7-ac447c504ebf",
"countryCode": "351",
"last3Digitis": "263"
}
]
}