API
Skip to main content

Payment Method Tokenization

Tokenization is the process that allows sensitive customer payment data to be securely stored by creating a token.

information

Payment method storage is only available for pagamentos with Cartão de Crédito/Débito e MBWay and in the layout basic and default.

To create a token, the following steps must be followed:

  1. Obtain the customer's UUID;
  2. Purchase via checkout using the registered customer ID.

1. Obtain the customer's UUID

The first step is to obtain the UUID of the customer whose payment method you want to register. This can be done through:

2. Complete payment via checkout

For the payment method to be available, it is necessary to successfully complete a payment.

POST /checkouts
{
"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"
}
}

3. Query Customer Payment Methods

After a successful payment, the payment method is added to the customer's payment methods.

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"
}
]
}

Tokenization with Customer Consent

{
"payment": {
"amount": 500,
"code": "REFPRODUTO_1",
"summary": "Computador",
"customer": {
"uuid": "e2343605-cf46-43de-b20b-9b7d1c95a9b2" // <== Indicar o uuid do cliente
},
"billingAddress": {
"country": "PT",
"city": "Lisboa",
"street1": "Rua Domingos Monteiro nº 7 A",
"postCode": "1050-074"
},
"paymentMethod": {
"code": "CC",
"details": {
"allowRegistration": true // <== Indicar a possibilidade de armazenar o método de pagamento
}
}
},
"page": {
"language": "PT",
"layout": "basic" // <== Indicar o layout que permite armazenar o método de pagamento
}
}
The response returns the id that identifies the checkout to the API.
The checkoutUrl is the link to access the page and make the payment.
The paymentId is the payment identifier.

When accessing checkoutUrl the following page is displayed:

Checkout registration