Updates
The ability to update payout details is a crucial feature in Ecart Pay’s API, offering unmatched flexibility to businesses and users.
Whether adjustments are required due to changes in the transaction, corrections in the item list, or modifications in charges, the Ecart Pay API ensures that these updates can be handled seamlessly. It offers multiple benefits, among which are the following:
- Real-Time Adjustments: Businesses often encounter scenarios where transaction details need adjustments. The payout update feature ensures that such changes are handled efficiently without canceling and restarting the payout process.
- Error Correction: Quickly fix discrepancies in amounts, items, or charges without disrupting the payout flow.
- Enhanced Flexibility: Businesses can modify itemized data, add or remove charges, or adjust order details, making the payout process highly adaptable to real-world scenarios.
- Improved Transparency: Keeping records accurate and up-to-date ensures a clear and transparent payout process for both senders and recipients.
How to Update Payout Items
The Ecart Pay API provides a request endpoint to update payout details. This allows you to modify payout amounts, item details, and charges, ensuring the payout reflects the latest transaction data.
Endpoint
PUT {{baseURL}}/api/payouts/{{payout_id}}
Headers
Authorization: {token}
Required Payload
amount
: The updated total amount of the payout.order_id
: The order identifier associated with the payout.items
: An array of updated item details, including:name
: The name of the item.quantity
: The quantity of the item.price
: The price per unit of the item.
discount
: Any applicable discount on the item.charges
: An array of additional charges, including:name
: The name of the charge.amount
: The amount of the charge.
Example Request
curl --location --globoff --request PUT 'https://sandbox.ecartpay.com/api/payouts/{{payout_id}}' \
--header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A' \
--header 'Content-Type: application/json' \
--header 'Cookie: lang=en' \
--data '{
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}],
"charges": [{
"name": "Tarifa",
"amount": 0.5
}]
}'
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.ecartpay.com/api/payouts/{{payout_id}}"
method := "PUT"
payload := strings.NewReader(`{`+"
"+`
"amount": 10,`+"
"+`
"order_id": "625cb5aa8541531b52506de8",`+"
"+`
"items": [{`+"
"+`
"name": "Collar Oro Z320",`+"
"+`
"quantity": 1,`+"
"+`
"price": 5,`+"
"+`
"discount": 0.5`+"
"+`
}],`+"
"+`
"charges": [{`+"
"+`
"name": "Tarifa",`+"
"+`
"amount": 0.5`+"
"+`
}]`+"
"+`
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A")
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Cookie", "lang=en")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
PUT /api/payouts/{{payout_id}} HTTP/1.1
Host: sandbox.ecartpay.com
Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A
Content-Type: application/json
Cookie: lang=en
Content-Length: 261
{
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}],
"charges": [{
"name": "Tarifa",
"amount": 0.5
}]
}
// OkHttp
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"amount\": 10,\r\n \"order_id\": \"625cb5aa8541531b52506de8\",\r\n \"items\": [{\r\n \"name\": \"Collar Oro Z320\",\r\n \"quantity\": 1,\r\n \"price\": 5,\r\n \"discount\": 0.5\r\n }],\r\n \"charges\": [{\r\n \"name\": \"Tarifa\",\r\n \"amount\": 0.5\r\n }]\r\n}");
Request request = new Request.Builder()
.url("https://sandbox.ecartpay.com/api/payouts/{{payout_id}}")
.method("PUT", body)
.addHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A")
.addHeader("Content-Type", "application/json")
.addHeader("Cookie", "lang=en")
.build();
Response response = client.newCall(request).execute();
// -------------------------------------------------------------
// Unirest
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.put("https://sandbox.ecartpay.com/api/payouts/{{payout_id}}")
.header("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A")
.header("Content-Type", "application/json")
.header("Cookie", "lang=en")
.body("{\r\n \"amount\": 10,\r\n \"order_id\": \"625cb5aa8541531b52506de8\",\r\n \"items\": [{\r\n \"name\": \"Collar Oro Z320\",\r\n \"quantity\": 1,\r\n \"price\": 5,\r\n \"discount\": 0.5\r\n }],\r\n \"charges\": [{\r\n \"name\": \"Tarifa\",\r\n \"amount\": 0.5\r\n }]\r\n}")
.asString();
// Fetch
const myHeaders = new Headers();
myHeaders.append("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "lang=en");
const raw = JSON.stringify({
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
});
const requestOptions = {
method: "PUT",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://sandbox.ecartpay.com/api/payouts/{{payout_id}}", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
// -------------------------------------------------------------
// jQuery
var settings = {
"url": "https://sandbox.ecartpay.com/api/payouts/{{payout_id}}",
"method": "PUT",
"timeout": 0,
"headers": {
"Authorization": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A",
"Content-Type": "application/json",
"Cookie": "lang=en"
},
"data": JSON.stringify({
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
// -------------------------------------------------------------
// XHR
var data = JSON.stringify({
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("PUT", "https://sandbox.ecartpay.com/api/payouts/{{payout_id}}");
xhr.setRequestHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A");
xhr.setRequestHeader("Content-Type", "application/json");
// WARNING: Cookies will be stripped away by the browser before sending the request.
xhr.setRequestHeader("Cookie", "lang=en");
xhr.send(data);
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox.ecartpay.com/api/payouts/{{payout_id}}");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Cookie: lang=en");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{\r\n \"amount\": 10,\r\n \"order_id\": \"625cb5aa8541531b52506de8\",\r\n \"items\": [{\r\n \"name\": \"Collar Oro Z320\",\r\n \"quantity\": 1,\r\n \"price\": 5,\r\n \"discount\": 0.5\r\n }],\r\n \"charges\": [{\r\n \"name\": \"Tarifa\",\r\n \"amount\": 0.5\r\n }]\r\n}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
curl_slist_free_all(headers);
}
curl_easy_cleanup(curl);
// Axios
const axios = require('axios');
let data = JSON.stringify({
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
});
let config = {
method: 'put',
maxBodyLength: Infinity,
url: 'https://sandbox.ecartpay.com/api/payouts/{{payout_id}}',
headers: {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
// -------------------------------------------------------------
// Native
var https = require('follow-redirects').https;
var fs = require('fs');
var options = {
'method': 'PUT',
'hostname': 'sandbox.ecartpay.com',
'path': '/api/payouts/{{payout_id}}',
'headers': {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
},
'maxRedirects': 20
};
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 = JSON.stringify({
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
});
req.write(postData);
req.end();
// -------------------------------------------------------------
// Request
var request = require('request');
var options = {
'method': 'PUT',
'url': 'https://sandbox.ecartpay.com/api/payouts/{{payout_id}}',
'headers': {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
},
body: JSON.stringify({
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
// -------------------------------------------------------------
// Unirest
var unirest = require('unirest');
var req = unirest('PUT', 'https://sandbox.ecartpay.com/api/payouts/{{payout_id}}')
.headers({
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
})
.send(JSON.stringify({
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
}))
.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.raw_body);
});
#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://sandbox.ecartpay.com/api/payouts/%7B%7Bpayout_id%7D%7D"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Authorization": @"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A",
@"Content-Type": @"application/json",
@"Cookie": @"lang=en"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\r\n \"amount\": 10,\r\n \"order_id\": \"625cb5aa8541531b52506de8\",\r\n \"items\": [{\r\n \"name\": \"Collar Oro Z320\",\r\n \"quantity\": 1,\r\n \"price\": 5,\r\n \"discount\": 0.5\r\n }],\r\n \"charges\": [{\r\n \"name\": \"Tarifa\",\r\n \"amount\": 0.5\r\n }]\r\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"PUT"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
open Lwt
open Cohttp
open Cohttp_lwt_unix
let postData = ref "{\r\n \"amount\": 10,\r\n \"order_id\": \"625cb5aa8541531b52506de8\",\r\n \"items\": [{\r\n \"name\": \"Collar Oro Z320\",\r\n \"quantity\": 1,\r\n \"price\": 5,\r\n \"discount\": 0.5\r\n }],\r\n \"charges\": [{\r\n \"name\": \"Tarifa\",\r\n \"amount\": 0.5\r\n }]\r\n}";;
let reqBody =
let uri = Uri.of_string "https://sandbox.ecartpay.com/api/payouts/{{payout_id}}" in
let headers = Header.init ()
|> fun h -> Header.add h "Authorization" "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A"
|> fun h -> Header.add h "Content-Type" "application/json"
|> fun h -> Header.add h "Cookie" "lang=en"
in
let body = Cohttp_lwt.Body.of_string !postData in
Client.call ~headers ~body `PUT uri >>= fun (_resp, body) ->
body |> Cohttp_lwt.Body.to_string >|= fun body -> body
let () =
let respBody = Lwt_main.run reqBody in
print_endline (respBody)
// cURL
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sandbox.ecartpay.com/api/payouts/{{payout_id}}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS =>'{
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}],
"charges": [{
"name": "Tarifa",
"amount": 0.5
}]
}',
CURLOPT_HTTPHEADER => array(
'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A',
'Content-Type: application/json',
'Cookie: lang=en'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
// -------------------------------------------------------------
// Guzzle
<?php
$client = new Client();
$headers = [
'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A',
'Content-Type' => 'application/json',
'Cookie' => 'lang=en'
];
$body = '{
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
}';
$request = new Request('PUT', 'https://sandbox.ecartpay.com/api/payouts/{{payout_id}}', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
// -------------------------------------------------------------
// HTTP_Request2
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://sandbox.ecartpay.com/api/payouts/{{payout_id}}');
$request->setMethod(HTTP_Request2::METHOD_PUT);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A',
'Content-Type' => 'application/json',
'Cookie' => 'lang=en'
));
$request->setBody('{
\n "amount": 10,
\n "order_id": "625cb5aa8541531b52506de8",
\n "items": [{
\n "name": "Collar Oro Z320",
\n "quantity": 1,
\n "price": 5,
\n "discount": 0.5
\n }],
\n "charges": [{
\n "name": "Tarifa",
\n "amount": 0.5
\n }]
\n}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
// -------------------------------------------------------------
// pecl_http
<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl('https://sandbox.ecartpay.com/api/payouts/{{payout_id}}');
$request->setRequestMethod('PUT');
$body = new http\Message\Body;
$body->append('{
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}],
"charges": [{
"name": "Tarifa",
"amount": 0.5
}]
}');
$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A',
'Content-Type' => 'application/json',
'Cookie' => 'lang=en'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A")
$headers.Add("Content-Type", "application/json")
$headers.Add("Cookie", "lang=en")
$body = @"
{
`"amount`": 10,
`"order_id`": `"625cb5aa8541531b52506de8`",
`"items`": [{
`"name`": `"Collar Oro Z320`",
`"quantity`": 1,
`"price`": 5,
`"discount`": 0.5
}],
`"charges`": [{
`"name`": `"Tarifa`",
`"amount`": 0.5
}]
}
"@
$response = Invoke-RestMethod 'https://sandbox.ecartpay.com/api/payouts/{{payout_id}}' -Method 'PUT' -Headers $headers -Body $body
$response | ConvertTo-Json
# http.client
import http.client
import json
conn = http.client.HTTPSConnection("sandbox.ecartpay.com")
payload = json.dumps({
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
})
headers = {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
}
conn.request("PUT", "/api/payouts/{{payout_id}}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
// -------------------------------------------------------------
# Requests
import requests
import json
url = "https://sandbox.ecartpay.com/api/payouts/{{payout_id}}"
payload = json.dumps({
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
})
headers = {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
# httr
library(httr)
headers = c(
'Authorization' = 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A',
'Content-Type' = 'application/json',
'Cookie' = 'lang=en'
)
body = '{
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
}';
res <- VERB("PUT", url = "https://sandbox.ecartpay.com/api/payouts/{{payout_id}}", body = body, add_headers(headers))
cat(content(res, 'text'))
// -------------------------------------------------------------
# RCurl
library(RCurl)
headers = c(
"Authorization" = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A",
"Content-Type" = "application/json",
"Cookie" = "lang=en"
)
params = "{
\"amount\": 10,
\"order_id\": \"625cb5aa8541531b52506de8\",
\"items\": [
{
\"name\": \"Collar Oro Z320\",
\"quantity\": 1,
\"price\": 5,
\"discount\": 0.5
}
],
\"charges\": [
{
\"name\": \"Tarifa\",
\"amount\": 0.5
}
]
}"
res <- httpPUT("https://sandbox.ecartpay.com/api/payouts/{{payout_id}}", params, httpheader = headers, followlocation = TRUE)
cat(res)
require "uri"
require "json"
require "net/http"
url = URI("https://sandbox.ecartpay.com/api/payouts/{{payout_id}}")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A"
request["Content-Type"] = "application/json"
request["Cookie"] = "lang=en"
request.body = JSON.dump({
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
})
response = https.request(request)
puts response.read_body
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::builder()
.build()?;
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A".parse()?);
headers.insert("Content-Type", "application/json".parse()?);
headers.insert("Cookie", "lang=en".parse()?);
let data = r#"{
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
]
}"#;
let json: serde_json::Value = serde_json::from_str(&data)?;
let request = client.request(reqwest::Method::PUT, "https://sandbox.ecartpay.com/api/payouts/{{payout_id}}")
.headers(headers)
.json(&json);
let response = request.send().await?;
let body = response.text().await?;
println!("{}", body);
Ok(())
}
# Httpie
printf '{
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}],
"charges": [{
"name": "Tarifa",
"amount": 0.5
}]
}'| http --follow --timeout 3600 PUT 'https://sandbox.ecartpay.com/api/payouts/{{payout_id}}' \
Authorization:'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A' \
Content-Type:'application/json' \
Cookie:'lang=en'
// -------------------------------------------------------------
# wget
wget --no-check-certificate --quiet \
--method PUT \
--timeout=0 \
--header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A' \
--header 'Content-Type: application/json' \
--header 'Cookie: lang=en' \
--body-data '{
"amount": 10,
"order_id": "625cb5aa8541531b52506de8",
"items": [{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}],
"charges": [{
"name": "Tarifa",
"amount": 0.5
}]
}' \
'https://sandbox.ecartpay.com/api/payouts/{{payout_id}}'
let parameters = "{\r\n \"amount\": 10,\r\n \"order_id\": \"625cb5aa8541531b52506de8\",\r\n \"items\": [{\r\n \"name\": \"Collar Oro Z320\",\r\n \"quantity\": 1,\r\n \"price\": 5,\r\n \"discount\": 0.5\r\n }],\r\n \"charges\": [{\r\n \"name\": \"Tarifa\",\r\n \"amount\": 0.5\r\n }]\r\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://sandbox.ecartpay.com/api/payouts/{{payout_id}}")!,timeoutInterval: Double.infinity)
request.addValue("eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3Mzg2OTA5NDQsImV4cCI6MTczODY5NDU0NH0.eJ7LOLmSwZBVcdol6_7trjeNQBQKjF0IGnJnWrqwpi80Fm5OlezbV2V0rhKmrFA5kW8o7REniUSWEVCIQcrb4A", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("lang=en", forHTTPHeaderField: "Cookie")
request.httpMethod = "PUT"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
}
task.resume()
Example Response
{
"id": "625cb5aa8541531b52506de8",
"order_id": "625cb5aa8541531b52506de8",
"status": "updated",
"currency": "MXN",
"amount": 10,
"items": [
{
"name": "Collar Oro Z320",
"quantity": 1,
"price": 5,
"discount": 0.5
}
],
"charges": [
{
"name": "Tarifa",
"amount": 0.5
}
],
"updated_at": "2025-01-08T12:00:00.000Z"
}
By utilizing the payout update feature, businesses gain the flexibility and control needed to handle complex transactions with ease and efficiency.
Updated about 2 months ago