Update
Only orders with a pending status can be modified.
Update
PATCH
https://api.payvalida.com/api/v3/porders
Sandbox URL: https://api-test.payvalida.com/api/v3/
porders
Allows the modification of an existing order, for example, extending its life (expiration date), amount, description, reference, etc.
Path Parameters
merchant
string
ID of the commerce in Payvalida. Max. 50 characters
string
Customer's email. It's used to send notification of the billing. Max. 100 characters.
country
number
Country code. 3 characters.
order
string
Order ID, generated by the commerce. Max. 20 characters.
reference
number
Reference number used by the customer to pay the order.
money
string
Currency's code of the order. 3 characters.
amount
number
Order's amount.
description
string
Short description of the order. Max. 500 characters.
method
string
Payment method selected by the customer. Max. 25 characters.
language
string
Language of the messages and responses. 2 characters.
recurrent
boolean
Indicated whether the order is recurrent.
expiration
string
Expiration date in format DD/MM/YYYY. Fecha de expiración de la orden en formato DD/MM/AAAA. It can't neither surpass 30 days nor be from a date before the registration of the order.
iva
number
Percentage amount of VAT/IVA of the order.
checksum
string
Checksum encoded in SHA512 (email+country+order+money+amount+FIXED_HASH). Max. 512 caracteres.
{
"CODE":"0000",
"DATA":{
"OrdenID":"p0000201",
"Monto":"55000.0",
"PVordenID":"95601",
"Referencia":"989898101",
"Operacion":"ACTUALIZADO",
"checkout":"checkout.payvalida.com/?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNRVJDSEFOVF9DRUwiOiIzMTc2ODI3MzQxIiwiT1JERVJfTUVUSE9EIjoiZWZlY3R5IiwiTUVSQ0hBTlRfQ09ERSI6MjU0LCJNRVJDSEFOVF9FTUFJTCI6ImhyZXN0cmVwb0BwYXl2YWxpZGEuY29tIiwiaXNzIjoiYXV0aDAiLCJNRVJDSEFOVF9MT0dPIjoiaHR0cHM6Ly9zMy5hbWF6b25hd3MuY29tL3ZhbGlkZGF3ZWIvZXZlbnRvcy9mZW5hbGNvYnJhLnBuZyIsIk1FUkNIQU5UX1VSTF9SRVRVUk4iOiJ3d3cucGludmFsaWRkYS5jb20uY28iLCJNRVJDSEFOVF9OQU1FIjoiSGVybmFuIFJwbyAoQ09MKSIsIk9SREVSX0JSSUVGIjoiVGVzdCBSRVNUZnVsbCBQdXJjaGFzZSBPcmRlciBQT1NUIiwiTUVSQ0hBTlRfVEVMIjoiMjg4MDUzOSIsIk9SREVSX0NVUlJFTkNZIjoiQ09QIiwiT1JERVJfQU1PVVQiOiIxMCwwMDAuMDAiLCJleHAiOjE1MzA0MDE1MzgsIk9SREVSX1JFRkVSRU5DRSI6IjQyMzEzIn0.QVsZwm-2BIkK-5RgrAX2NuwGqmHSNHD_zw91i1hcSc8"
},
"DESC":"OK"
}
The commerce (merchant) id and the FIXED_HASH are provided when you create an account in our platform.
Sent data is verified and updated if the parameter is different to the original order's.
In order to update an order, it is required to be in PENDING (PENDIENTE) status, otherwise you won't be able to modify it.
Examples
Request
curl --location --request PATCH 'https://api-test.payvalida.com/api/v3/porders' \
--header 'Content-Type: application/json' \
--data-raw '{
"merchant": "kuanto",
"email": "[email protected]",
"country": 343,
"order": "999999991",
"reference": "46534512",
"money": "COP",
"amount": "9500",
"description": "Orden de prueba",
"method": "",
"language": "es",
"recurrent": true,
"expiration": "27/12/2020",
"iva": "0",
"checksum": "1AC89E7089355B5069222C01779431A192FC4D459C25584D69B64ABBF605FE7CB54A015296A39D234CA9B94FF9F068423AC1E00F5A319EB18F2167B97C8A0BB1",
"user_di": "94320444",
"user_type_di": "CC",
"user_name": "NombreUsuario",
"redirect_timeout": "300000"
}'
Go
package main
import (
"bytes"
"crypto/sha512"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"time"
)
type Request struct {
Country int `json:"country,omitempty"`
Email string `json:"email,omitempty"`
Merchant string `json:"merchant,omitempty"`
Order string `json:"order,omitempty"`
Reference string `json:"reference,omitempty"`
Money string `json:"money,omitempty"`
Amount string `json:"amount,omitempty"`
Description string `json:"description,omitempty"`
Language string `json:"language,omitempty"`
Recurrent bool `json:"recurrent,omitempty"`
Expiration string `json:"expiration,omitempty"`
Method string `json:"method,omitempty"`
Iva string `json:"iva,omitempty"`
Checksum string `json:"checksum,omitempty"`
UserDI string `json:"user_di,omitempty"`
UserTypeDI string `json:"user_type_di,omitempty"`
RedirectTimeout string `json:"redirect_timeout,omitempty"`
UserName string `json:"user_name,omitempty"`
}
func main() {
url := "https://api-test.payvalida.com/api/v3/porders"
method := "PATCH"
email := "[email protected]"
country := "343"
order := "test" + fmt.Sprint(rand.Intn(999999999))
money := "COP"
amount := "20000"
fixedHash := "xxccc_b0b20707cca2b283b5844e77cadf2b5813bd923362b91583c95b736c8763937c0e0df27e9b730c404eeac6484666430f6042c043089135e8d3e76f2e86a82c38"
Paysha512 := sha512.Sum512([]byte(email + country + order + money + amount + fixedHash))
checksum := hex.EncodeToString(Paysha512[:])
date := time.Now()
expiration := date.AddDate(0, 0, 2)
request := Request{
Country: 343,
Email: email,
Merchant: "kuanto",
Order: order,
Reference: "",
Money: money,
Amount: amount,
Description: "Test pruebas unitarias",
Language: "es",
Recurrent: false,
Expiration: expiration.Format("02/01/2006"),
Method: "",
Iva: "0",
Checksum: checksum,
UserDI: "90000000",
UserTypeDI: "CC",
RedirectTimeout: "150000",
UserName: "devPayvalida",
}
json, err := json.Marshal(request)
if err != nil {
fmt.Println(err)
return
}
client := &http.Client{}
req, err := http.NewRequest(method, url, bytes.NewBuffer(json))
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-test.payvalida.com/api/v3/porders",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS =>"{\n \"merchant\": \"kuanto\",\n \"email\": \"[email protected]\",\n \"country\": 343,\n \"order\": \"999999991\",\n \"reference\": \"46534512\",\n \"money\": \"COP\",\n \"amount\": \"9500\",\n \"description\": \"Orden de prueba\",\n \"method\": \"\",\n \"language\": \"es\",\n \"recurrent\": true,\n \"expiration\": \"27/12/2020\",\n \"iva\": \"0\",\n \"checksum\": \"1AC89E7089355B5069222C01779431A192FC4D459C25584D69B64ABBF605FE7CB54A015296A39D234CA9B94FF9F068423AC1E00F5A319EB18F2167B97C8A0BB1\",\n \"user_di\": \"94320444\",\n \"user_type_di\": \"CC\",\n \"user_name\": \"NombreUsuario\",\n \"redirect_timeout\": \"300000\"\n}",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Java
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.patch("https://api-test.payvalida.com/api/v3/porders")
.header("Content-Type", "application/json")
.body("{\n \"merchant\": \"kuanto\",\n \"email\": \"[email protected]\",\n \"country\": 343,\n \"order\": \"999999991\",\n \"reference\": \"46534512\",\n \"money\": \"COP\",\n \"amount\": \"9500\",\n \"description\": \"Orden de prueba\",\n \"method\": \"\",\n \"language\": \"es\",\n \"recurrent\": true,\n \"expiration\": \"27/12/2020\",\n \"iva\": \"0\",\n \"checksum\": \"1AC89E7089355B5069222C01779431A192FC4D459C25584D69B64ABBF605FE7CB54A015296A39D234CA9B94FF9F068423AC1E00F5A319EB18F2167B97C8A0BB1\",\n \"user_di\": \"94320444\",\n \"user_type_di\": \"CC\",\n \"user_name\": \"NombreUsuario\",\n \"redirect_timeout\": \"300000\"\n}")
.asString();
JavaScript
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({"merchant":"kuanto","email":"[email protected]","country":343,"order":"999999991","reference":"46534512","money":"COP","amount":"9500","description":"Orden de prueba","method":"","language":"es","recurrent":true,"expiration":"27/12/2020","iva":"0","checksum":"1AC89E7089355B5069222C01779431A192FC4D459C25584D69B64ABBF605FE7CB54A015296A39D234CA9B94FF9F068423AC1E00F5A319EB18F2167B97C8A0BB1","user_di":"94320444","user_type_di":"CC","user_name":"NombreUsuario","redirect_timeout":"300000"});
var requestOptions = {
method: 'PATCH',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api-test.payvalida.com/api/v3/porders", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Última actualización
¿Te fue útil?