Note: You should be fully PCI compliant if you wish to perform tokenization requests Server-to-Server (as it requires that you collect the card data). If you are NOT fully PCI compliant, you can use the COPYandPAY tokenization tutorial to collect the payment data securely.
Tokenization allows you to store payment data for later use. This can be useful for recurring payment scenarios.
Note: The token (registrationId )will be valid during 13 months if there is no transaction based on the token. Validity will extend by 13 months for each reference transaction (Debit or Preauthorization + Capture using the token).
This guide describes how you can store the data using our Server-to-Server API, how you can subsequently use the stored card details and how to delete stored data.
A payment's data can be stored at the same time as the payment by sending the createRegistrationparameter with a value of true. This is done by sending a POST request to the /v1/payments endpoint.
{"id":"8ac7a4a06a00f56b016a094665b76129","registrationId":"8ac7a49f6a012230016a0946634c58e2","paymentType":"DB","paymentBrand":"VISA","amount":"1.00","currency":"BRL","descriptor":"123 Usage","merchantTransactionId":"Order Number 123","result":{"code":"000.100.112","description":"Request successfully processed in 'Merchant in Connector Test Mode'" }, },"card":{"bin":"411111","last4Digits":"1111","holder":"Jose da Silva","expiryMonth":"05","expiryYear":"2025" },"customer":{"givenName":"Jose","surname":"da Silva","merchantCustomerId":"12345678909","email":" info@provider.com","ip":"123.123.123.123" },"billing":{"street1":"Rua Itapeva 547","city":"Sao Paulo","state":"SP","postcode":"01332000","country":"BR" },"customParameters":{"merchant_website":"www.store.com","product":"1 month membership","OPP_card.bin":"411111" },"risk":{"score":"0" },"buildNumber":"9530bc5348dcf347df44e234fa57653109617938@2019-04-09 04:42:22 +0000","timestamp":"2019-04-10 22:02:52+0000","ndc":"8a8294174e918ca6014e9c6f5ae12a9c_9ab8516d2e574e8b93a632c0f62646c1"}
Store the data as stand-alone
A registration (RG) can also be made by calling the /v1/registrations endpoint as a stand-alone request (i.e. without requesting a payment).
Contrary to the registration as part of a payment, you directly receive a registration object in your response. Therefore the id to reference this data during later payments is the value of field id
{"id":"8ac7a4a26a116ede016a132ae2b35a5c","merchantTransactionId":"Order Number 123","result":{"code":"000.100.112","description":"Request successfully processed in 'Merchant in Connector Test Mode'" },"card":{"bin":"411111","last4Digits":"1111","holder":"Jose da Silva","expiryMonth":"05","expiryYear":"2025" },"customer":{"merchantCustomerId":"12345678909" },"customParameters":{"merchant_website":"www.store.com","product":"1 month membership" },"risk":{"score":"0" },"buildNumber":"9530bc5348dcf347df44e234fa57653109617938@2019-04-09 04:42:22 +0000","timestamp":"2019-04-12 20:08:58+0000","ndc":"8a8294174e918ca6014e9c6f5ae12a9c_efb7aaecef424e20956bc368bfa9b1fd"}
Using the stored payment data
Recurring Payment
Based on the stored account details, recurring payments become very simple to achieve. All you need to do is to add the parameter recurringTypeto your request. (see Recurring Payments):
For the initial payment request you should send the recurringType parameter with value INITIAL.
For any subsequent payment you should send the recurringType parameter with value REPEATED.
Deleting the stored payment data
Once stored, a token can be deleted using the HTTP DELETE method against the registrationId
{"id":"8ac7a49f6a116c56016a1388ba211bc9","referencedId":"8ac7a4a26a116ede016a132ae2b35a5c","merchantTransactionId":"Order Number 123","result":{"code":"000.100.112","description":"Request successfully processed in 'Merchant in Connector Test Mode'" },"customer":{"merchantCustomerId":"12345678909" },"buildNumber":"9530bc5348dcf347df44e234fa57653109617938@2019-04-09 04:42:22 +0000","timestamp":"2019-04-12 21:51:28+0000","ndc":"8a8294174e918ca6014e9c6f5ae12a9c_ab503607ad0b4045b5e2773f07e3890a"}