1. Home
  2. Library
  3. SDK PHP
  4. Credit Card Charge – PHP

Credit Card Charge – PHP

The point of implementing sr pago is to be able to charge credit cards. In this module we will study the easiest way to accomplish this task.

Once you have the token as a result of the tokenization process you can do several processes, the must important one is charging the Credit Card that was tokenized.


To have end the tokenization process and have a valid token.

End the SDK installation and configuration


1. Import the SrPago.php class

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

2. Hand on the charge data:

  • Amount to be charged
  • Description
  • Reference (just in case the transaction has a reference)
  • Source: the token you’ll be using
  • IP: IP address of the device making the request
  • Metadata: Additional transaction info.
$chargeParams = array(
    "description" => 'Test',
    "reference"=> 'test',
    "ip"=> /*Agregar IP del cliente*/,
   "source"=>$_POST['tokenInput'] //En el proceso de tokenización se definió este nombre y el método post
$metadata = array();
$response = '';
try {
    $srPago = new SrPago();
    $response =  $srPago->chargesCreateCharge($chargeParams, $metadata);
}catch (Exception $e){
  echo 'Error ' . $e->getMessage() . ' ' . $e->getFile();

3. The service will answer with a json, to know more about this answer and the possible error codes please refer to the API documentation

NOTE: It is important to fill all the fields and send accurate metadata in order to prevent possible fraud threats.

Was this article helpful to you? Yes 1 No 11