Payment Methods

Payment with cardPost

https://sandbox-api.srpago.com/v1/payment/card

Para realizar un cobro a una tarjeta de débito o crédito es necesario que la petición viaje cifrada con las siguientes características:

  1. Genera una llave de 32 caracteres única por petición.
  2. Cifrar la llave única generada con el algoritmo RSA utilizando las llaves SRPAGO_RSA_PUBLIC_KEY que viene incluida en el código de los SDK’s. (Este valor generado se enviará en el parámetro KEY).
  3. Cifrar el JSON del request con el algoritmo AES256 utilizando la llave de 32 caracteres generada en el paso 1. (este valor generado se enviará en el parámetro DATA).

Nota: Al enviar el KEY y DATA deben codificarse en base64 para su correcto envío.

Más información sobre el Metadata 

headers

AuthorizationBasic

Content-Typeapplication/json

Parameters

Key*<String>Llave RSA usada para encriptar el mensaje

data**<String> Mensaje encriptado con AES 256

Metadata (Obligatorio)<Metadata object>Metadata para aplicar reglas antifraude

body

{"key":"","data":"","metadata":{}}
 

Charge object

recurrent (Obligatorio)<String> Token de Sr. Pago

payment::external::transaction (Optional)<String> Identificador de transacción

payment::external::application_key (Obligatorio)<String>Llave de la aplicación

payment::total::amount (Obligatorio)<Double> Monto

payment::total::currency (Obligatorio)<String> MXN

payment::total::months (Optional)<Double>Número de MSI

payment::tip::amount (Optional)<Double> Monto de propina

payment::reference::number (Obligatorio)<String> Número de transferencia

payment::reference::description (Obligatorio)<String> Descripción de la transferencia

payment::affiliated::user (Optional)<String> Usuario de modalidad connect/join

payment::affiliated::total_fee (Optional)<String> Monto total para usuario de connect/join

 

Example Request

  
curl -X POST \
  https://sandbox-api.srpago.com/v1/payment/card \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Basic ' \

  -H 'cache-control: no-cache' \
  -d '{"key":"","data":"","metadata":{}}'
  
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://sandbox-api.srpago.com/v1/payment/card",
  "method": "POST",
  "headers": {
    "Content-Type": "application/json",
    "Authorization": "Basic "
  },
  "data": "{\"key\":\"\",\"data\":\"\",\"metadata\":{}}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
  require 'uri'
require 'net/http'

url = URI("https://sandbox-api.srpago.com/v1/payment/card")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request["Authorization"] = 'Basic '
request.body = "{\"key\":\"\",\"data\":\"\",\"metadata\":{}}"

response = http.request(request)
puts response.read_body
  import requests

url = "https://sandbox-api.srpago.com/v1/payment/card"

payload = "{\"key\":\"\",\"data\":\"\",\"metadata\":{}}"
headers = {
    'Content-Type': "application/json",
    
    'Authorization': "Basic "
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
var http = require("https");

var options = {
  "method": "POST",
  "hostname": [
    "sandbox-api",
    "srpago",
    "com"
  ],
  "path": [
    "v1",
    "payment",
    "card"
  ],
  "headers": {
    "Content-Type": "application/json",
    
    "Authorization": "Basic "
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.write("{\"key\":\"\",\"data\":\"\",\"metadata\":{}}");
req.end();
<?php

$request = new HttpRequest();
$request->setUrl('https://sandbox-api.srpago.com/v1/payment/card');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
  'Authorization' => 'Basic ',

  'Content-Type' => 'application/json'
));

$request->setBody('{"key":"","data":"","metadata":{}}');

try {
  $response = $request->send();

  echo $response->getBody();
} catch (HttpException $ex) {
  echo $ex;
}

Example Response

{
  "success": true,
  "result": {
    "total": 842,
    "sales": "707305.04",
    "transferences": "401.49",
    "commissions": {
      "amount": 162.54,
      "currency": "MXN"
    },
    "operations": [
      {
        "transaction": "MjY2MzYyNQ==",
        "timestamp": "2018-10-25T12:48:37-05:00",
        "payment_method": "OXX",
        "authorization_code": "4174B14B",
        "status": "N",
        "reference": {
          "description": "-"
        },
        "card": {
          "holder_name": "Banco pruebas",
          "type": "OXXO",
          "number": "0000",
          "label": "",
          "raw": "0000"
        },
        "total": {
          "amount": "100.00",
          "currency": "MXN"
        },
        "tip": {
          "amount": "0.00",
          "currency": "MXN"
        },
        "fee": {
          "amount": "54.18",
          "currency": "MXN"
        },
        "fee_details": [
          {
            "type": "fee",
            "percentage": 3.6,
            "amount": 4.18,
            "description": ""
          },
          {
            "type": "application_fee",
            "percentage": 20,
            "amount": 20,
            "description": "CONTRACARGO DE 50mil"
          },
          {
            "type": "application_fee",
            "percentage": 30,
            "amount": 30,
            "description": "FINANCIAMIENTO 2"
          }
        ],
        "origin": {
          "location": {
            "latitude": "0.000000",
            "longitude": "0.000000"
          }
        },
        "affiliation": "0",
        "url": "https://sandbox-connect.srpago.com/recipe/OTUzYjg4MmUtYzYyNS00YTEzLTg3NjQtOGRmZWY3N",
        "hasDevolution": false,
        "commission": {
          "amount": "54.18",
          "currency": "MXN"
        }
      },
      {
        "transaction": "MjY2MzYyNA==",
        "timestamp": "2018-10-25T12:32:15-05:00",
        "payment_method": "OXX",
        "authorization_code": "417478AD",
        "status": "N",
        "reference": {
          "description": "-"
        },
        "card": {
          "holder_name": "Banco pruebas",
          "type": "OXXO",
          "number": "0000",
          "label": "",
          "raw": "0000"
        },
        "total": {
          "amount": "100.00",
          "currency": "MXN"
        },
        "tip": {
          "amount": "0.00",
          "currency": "MXN"
        },
        "fee": {
          "amount": "54.18",
          "currency": "MXN"
        },
        "fee_details": [
          {
            "type": "fee",
            "percentage": 3.6,
            "amount": 4.18,
            "description": ""
          },
          {
            "type": "application_fee",
            "percentage": 20,
            "amount": 20,
            "description": "CONTRACARGO DE 50mil"
          },
          {
            "type": "application_fee",
            "percentage": 30,
            "amount": 30,
            "description": "FINANCIAMIENTO 2"
          }
        ],
        "origin": {
          "location": {
            "latitude": "0.000000",
            "longitude": "0.000000"
          }
        },
        "affiliation": "0",
        "url": "https://sandbox-connect.srpago.com/recipe/ZDE4MTY3MDgtZjgxOC00ZmY1LTlkOGUtYTI1MDcwZGZhZjVl",
        "hasDevolution": false,
        "commission": {
          "amount": "54.18",
          "currency": "MXN"
        }
      }
    ]
  }
}