Payment Methods
SPEIPost
https://sandbox-api.srpago.com/v1/payment/spei
headers
AuthorizationBasic
Content-Typeapplication/json
body
{ "payment": { "reference": { "description": "Chamarra Azul" } }, "total": 102, "source": "spe_5a502b421852e" }
Importancia del monto configurado
Crea referencias para pagos SPEI, estas referencias están sujetas de forma estricta al monto configurado.
Ejemplo:
Si la referencia se genera por un monto de $ 99.00 y el usuario realiza una transferencia por un monto de $100.00, el dinero será descontado al cuentahabiente y horas después será devuelto, puesto a que no coincide con el importe de la referencia y la transacción no será exitosa, por lo que se recomienda que el pago sea al monto exacto.
Fecha de Expiración
Puedes configurar la fecha de expiración de la boleta de pago.
En caso de que no se complete la misma expirará al día siguiente de su creación.
body
{ "payment": { "reference": { "description": "Chamarra Azul" } }, "expiration_date": "2023-12-25", "total": 102, "source": "spe_5a502b421852e" }
Example Request
curl --location --request POST "https://sandbox-api.srpago.com/v1/payment/spei" \ --header "Content-Type: application/json" \ --header "Authorization: Basic " \ --data "{ \"payment\":{ \"reference\":{ \"description\":\"-\" } }, \"total\":100 }"
var settings = { "url": "https://sandbox-api.srpago.com/v1/payment/spei", "method": "POST", "timeout": 0, "headers": { "Content-Type": "application/json", "Authorization": "Basic " }, "data": "{\n\t\"payment\":{\n\t\t\"reference\":{\n\t\t\t\"description\":\"-\"\n\t\t}\n\t},\n\t\"total\":100 \n}", }; $.ajax(settings).done(function (response) { console.log(response); });
require "uri" require "net/http" url = URI("https://sandbox-api.srpago.com/v1/payment/spei") http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Post.new(url) request["Content-Type"] = "application/json" request.body = "{\n\t\"payment\":{\n\t\t\"reference\":{\n\t\t\t\"description\":\"-\"\n\t\t}\n\t},\n\t\"total\":100 \n}" response = http.request(request) puts response.read_body
import requests url = 'https://sandbox-api.srpago.com/v1/payment/spei' payload = "{\n\t\"payment\":{\n\t\t\"reference\":{\n\t\t\t\"description\":\"-\"\n\t\t}\n\t},\n\t\"total\":100 \n}" headers = { 'Content-Type': 'application/json', 'Authorization': 'Basic ' } response = requests.request('POST', url, headers = headers, data = payload, allow_redirects=False, timeout=undefined, allow_redirects=false) print(response.text)
var https = require('https'); var options = { 'method': 'POST', 'hostname': 'https://sandbox-api.srpago.com', 'path': '/v1/payment/spei', 'headers': { 'Content-Type': 'application/json', 'Authorization': 'Basic ' } }; var req = https.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function (chunk) { var body = Buffer.concat(chunks); console.log(body.toString()); }); res.on("error", function (error) { console.error(error); }); }); var postData = "{\n\t\"payment\":{\n\t\t\"reference\":{\n\t\t\t\"description\":\"-\"\n\t\t}\n\t},\n\t\"total\":100 \n}"; req.write(postData); req.end();
<?php $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "https://sandbox-api.srpago.com/v1/payment/spei", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS =>"{\n\t\"payment\":{\n\t\t\"reference\":{\n\t\t\t\"description\":\"-\"\n\t\t}\n\t},\n\t\"total\":100 \n}", CURLOPT_HTTPHEADER => array( "Content-Type: application/json", "Authorization: Basic " ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ?>
package main import ( "fmt" "strings" "os" "path/filepath" "net/http" "io/ioutil" ) func main() { url := "https://sandbox-api.srpago.com/v1/payment/spei" method := "POST" payload := strings.NewReader("{\n \"payment\":{\n \"reference\":{\n \"description\":\"-\"\n }\n },\n \"total\":100 \n}") client := &http.Client { CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }, } req, err := http.NewRequest(method, url, payload) if err != nil { fmt.Println(err) } req.Header.Add("Content-Type", "application/json") req.Header.Add("Authorization", "Basic ") res, err := client.Do(req) defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) fmt.Println(string(body)) }
Example Response
{ "success": true, "result": { "transaction": "5e2c91fb-f9a3-4c7d-a9bc-bf2c354f01aa", "store": { "name": "SPEI", "short_name": "SPEI" }, "bank_account_number": "646180125500134554", "bank_name": "STP", "payment_id": "spei_5bd201e889a02", "reference": { "description": "-" }, "total": { "amount": "100.00", "currency": "MXN" }, "url": "https://sandbox-connect.srpago.com/voucher/c3BlaV81YmQyMDeeeeFlODg5YTAy", "timestamp": "2018-10-25T12:48:24-05:00", "expiration_date": "2018-10-26T00:00:00-05:00", "status": 2, "status_code": "pending" } }