1. Home
  2. Library
  3. SDK PHP
  4. On-Demand Tokenization – PHP

On-Demand Tokenization – PHP

On-Demand tokenization brings the ability to enter a credit card just once and be able to use it again several times.

As we have mentioned in past sections, tokens tok_xxxx can only be used once, in order to be able to use them multiple times it is necessary to use this token to generate a token crd_xxxxx

Pre-requisites

Creation and retrieve of a client

Process

1. Create a token tok_xxxxx to do this task you can refer to the javascript tokenization guide.

2. Retrieve the token cus_xxxx from the client to which you are going to assign the on-demand token

3. Import Sr Pago.php class

include_once ‘./vendor/SrPago_php/SrPago.php';

4. Call the method addCardToCustomer

$srPago = new SrPago();
$srPago->setup();
try{
    $result = $srPago->addCardToCustomer($_POST['clientToken'],$_POST['tokenInput']);
    //$result = $srPago->addCardToCustomer(null,null);
}catch (Exception $e){
    echo 'Error ' . $e->getMessage() . ' ' . $e->getFile();
}

This method will return an array with a token crd_xxxxxx, this token can be used multiple times to make a better user experience.

 

Was this article helpful to you? Yes No