Checkouts
Ecart Pay simplifies the payment process by providing tools to create custom checkouts, enabling businesses to offer personalized and seamless transaction experiences. This feature enhances the user journey while catering to diverse financial preferences and needs.
In today’s competitive digital landscape, delivering efficient and secure payment experiences is crucial. Ecart Pay’s custom checkout feature allows businesses to design tailored payment solutions. By integrating customer details, transaction specifics, and flexible options, this functionality empowers businesses to streamline their payment workflows, enhance customer satisfaction, and drive operational efficiency.
Custom checkouts provide more than just a payment gateway; they allow businesses to offer personalized user experiences aligned with brand identity. Through detailed configurations and automation, businesses can reduce friction and build trust with their customers.

Image 1. Checkout Template
Why Use Ecart Pay’s Custom Checkouts?
Having a proprietary checkout process through Ecart Pay offers numerous advantages:
- Enhanced User Experience: Tailored checkouts reduce complexities, making the transaction process smooth and intuitive for customers.
- Brand Alignment: Businesses can customize elements such as titles, subtitles, and images to align with their branding.
- Transaction Flexibility: Support for multiple currencies and adjustable amounts ensures compatibility with diverse customer preferences.
- Operational Efficiency: Automated notifications and references streamline tracking and reconciliation processes.
How to Create a Checkout
This endpoint is used to create custom checkouts in the Ecart Pay system. By providing customer and transaction details, businesses can generate a unique checkout link for seamless payments.
Endpoint
POST {{baseURL}}/api/checkouts
Headers
Authorization: {token}
Request Body
Parameter | Type | Description |
---|---|---|
customer_id | string | The ID of the customer. |
title | string | Title of the checkout. |
subtitle | string | Subtitle of the checkout. |
image_url | string | URL of the associated image. |
currency | string | Currency for the transaction. |
amounts | array of numbers | Array of amounts available for selection. |
concept | string | Description of the checkout concept. |
notify_url | string | URL for receiving transaction notifications. |
reference_id | string | Unique reference ID for the checkout. |
reference | string | Description of the reference. |
Example Request
curl --location 'https://sandbox.ecartpay.com/api/checkouts' \
--header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw' \
--header 'Content-Type: application/json' \
--header 'Cookie: lang=en' \
--data '{
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [100, 200, 500, 1000, 1500, 3000],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
}'
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.ecartpay.com/api/checkouts"
method := "POST"
payload := strings.NewReader(`{
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [100, 200, 500, 1000, 1500, 3000],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw")
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))
}
POST /api/checkouts HTTP/1.1
Host: sandbox.ecartpay.com
Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw
Content-Type: application/json
Cookie: lang=en
Content-Length: 385
{
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [100, 200, 500, 1000, 1500, 3000],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
}
// OkHttp
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"title\": \"Ecart Pay\",\n \"subtitle\": \"The best payment solution\",\n \"image_url\": \"https://ecartpay.com/img/landing/integraciones/ecart-16.svg\",\n \"currency\": \"MXN\",\n \"amounts\": [100, 200, 500, 1000, 1500, 3000],\n \"concept\": \"Recharge\",\n \"notify_url\": \"https://example.com/webhooks/checkout?user_id=1\",\n \"reference_id\": \"001\",\n \"reference\": \"Custom recharge\"\n}");
Request request = new Request.Builder()
.url("https://sandbox.ecartpay.com/api/checkouts")
.method("POST", body)
.addHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw")
.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.post("https://sandbox.ecartpay.com/api/checkouts")
.header("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw")
.header("Content-Type", "application/json")
.header("Cookie", "lang=en")
.body("{\n \"title\": \"Ecart Pay\",\n \"subtitle\": \"The best payment solution\",\n \"image_url\": \"https://ecartpay.com/img/landing/integraciones/ecart-16.svg\",\n \"currency\": \"MXN\",\n \"amounts\": [100, 200, 500, 1000, 1500, 3000],\n \"concept\": \"Recharge\",\n \"notify_url\": \"https://example.com/webhooks/checkout?user_id=1\",\n \"reference_id\": \"001\",\n \"reference\": \"Custom recharge\"\n}")
.asString();
// Fetch
const myHeaders = new Headers();
myHeaders.append("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "lang=en");
const raw = JSON.stringify({
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://sandbox.ecartpay.com/api/checkouts", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
// -------------------------------------------------------------
// jQuery
var settings = {
"url": "https://sandbox.ecartpay.com/api/checkouts",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw",
"Content-Type": "application/json",
"Cookie": "lang=en"
},
"data": JSON.stringify({
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
// -------------------------------------------------------------
// XHR
// WARNING: For POST requests, body is set to null by browsers.
var data = JSON.stringify({
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://sandbox.ecartpay.com/api/checkouts");
xhr.setRequestHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw");
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, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox.ecartpay.com/api/checkouts");
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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw");
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 = "{\n \"title\": \"Ecart Pay\",\n \"subtitle\": \"The best payment solution\",\n \"image_url\": \"https://ecartpay.com/img/landing/integraciones/ecart-16.svg\",\n \"currency\": \"MXN\",\n \"amounts\": [100, 200, 500, 1000, 1500, 3000],\n \"concept\": \"Recharge\",\n \"notify_url\": \"https://example.com/webhooks/checkout?user_id=1\",\n \"reference_id\": \"001\",\n \"reference\": \"Custom recharge\"\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({
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://sandbox.ecartpay.com/api/checkouts',
headers: {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw',
'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': 'POST',
'hostname': 'sandbox.ecartpay.com',
'path': '/api/checkouts',
'headers': {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw',
'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({
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
});
req.write(postData);
req.end();
// -------------------------------------------------------------
// Request
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://sandbox.ecartpay.com/api/checkouts',
'headers': {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
},
body: JSON.stringify({
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
// -------------------------------------------------------------
// Unirest
var unirest = require('unirest');
var req = unirest('POST', 'https://sandbox.ecartpay.com/api/checkouts')
.headers({
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
})
.send(JSON.stringify({
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
}))
.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/checkouts"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Authorization": @"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw",
@"Content-Type": @"application/json",
@"Cookie": @"lang=en"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n \"title\": \"Ecart Pay\",\n \"subtitle\": \"The best payment solution\",\n \"image_url\": \"https://ecartpay.com/img/landing/integraciones/ecart-16.svg\",\n \"currency\": \"MXN\",\n \"amounts\": [100, 200, 500, 1000, 1500, 3000],\n \"concept\": \"Recharge\",\n \"notify_url\": \"https://example.com/webhooks/checkout?user_id=1\",\n \"reference_id\": \"001\",\n \"reference\": \"Custom recharge\"\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
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 "{\n \"title\": \"Ecart Pay\",\n \"subtitle\": \"The best payment solution\",\n \"image_url\": \"https://ecartpay.com/img/landing/integraciones/ecart-16.svg\",\n \"currency\": \"MXN\",\n \"amounts\": [100, 200, 500, 1000, 1500, 3000],\n \"concept\": \"Recharge\",\n \"notify_url\": \"https://example.com/webhooks/checkout?user_id=1\",\n \"reference_id\": \"001\",\n \"reference\": \"Custom recharge\"\n}";;
let reqBody =
let uri = Uri.of_string "https://sandbox.ecartpay.com/api/checkouts" in
let headers = Header.init ()
|> fun h -> Header.add h "Authorization" "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw"
|> 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 `POST 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/checkouts',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [100, 200, 500, 1000, 1500, 3000],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
}',
CURLOPT_HTTPHEADER => array(
'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw',
'Content-Type: application/json',
'Cookie: lang=en'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
// -------------------------------------------------------------
// Guzzle
<?php
$client = new Client();
$headers = [
'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw',
'Content-Type' => 'application/json',
'Cookie' => 'lang=en'
];
$body = '{
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
}';
$request = new Request('POST', 'https://sandbox.ecartpay.com/api/checkouts', $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/checkouts');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw',
'Content-Type' => 'application/json',
'Cookie' => 'lang=en'
));
$request->setBody('{\n "title": "Ecart Pay",\n "subtitle": "The best payment solution",\n "image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",\n "currency": "MXN",\n "amounts": [100, 200, 500, 1000, 1500, 3000],\n "concept": "Recharge",\n "notify_url": "https://example.com/webhooks/checkout?user_id=1",\n "reference_id": "001",\n "reference": "Custom recharge"\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/checkouts');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->append('{
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [100, 200, 500, 1000, 1500, 3000],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
}');
$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw',
'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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw")
$headers.Add("Content-Type", "application/json")
$headers.Add("Cookie", "lang=en")
$body = @"
{
`"title`": `"Ecart Pay`",
`"subtitle`": `"The best payment solution`",
`"image_url`": `"https://ecartpay.com/img/landing/integraciones/ecart-16.svg`",
`"currency`": `"MXN`",
`"amounts`": [100, 200, 500, 1000, 1500, 3000],
`"concept`": `"Recharge`",
`"notify_url`": `"https://example.com/webhooks/checkout?user_id=1`",
`"reference_id`": `"001`",
`"reference`": `"Custom recharge`"
}
"@
$response = Invoke-RestMethod 'https://sandbox.ecartpay.com/api/checkouts' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
# http.client
import http.client
import json
conn = http.client.HTTPSConnection("sandbox.ecartpay.com")
payload = json.dumps({
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
})
headers = {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
}
conn.request("POST", "/api/checkouts", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
// -------------------------------------------------------------
# Requests
import requests
import json
url = "https://sandbox.ecartpay.com/api/checkouts"
payload = json.dumps({
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
})
headers = {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
# httr
library(httr)
headers = c(
'Authorization' = 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw',
'Content-Type' = 'application/json',
'Cookie' = 'lang=en'
)
body = '{
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
}';
res <- VERB("POST", url = "https://sandbox.ecartpay.com/api/checkouts", body = body, add_headers(headers))
cat(content(res, 'text'))
// -------------------------------------------------------------
# RCurl
library(RCurl)
headers = c(
"Authorization" = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw",
"Content-Type" = "application/json",
"Cookie" = "lang=en"
)
params = "{
\"title\": \"Ecart Pay\",
\"subtitle\": \"The best payment solution\",
\"image_url\": \"https://ecartpay.com/img/landing/integraciones/ecart-16.svg\",
\"currency\": \"MXN\",
\"amounts\": [
100,
200,
500,
1000,
1500,
3000
],
\"concept\": \"Recharge\",
\"notify_url\": \"https://example.com/webhooks/checkout?user_id=1\",
\"reference_id\": \"001\",
\"reference\": \"Custom recharge\"
}"
res <- postForm("https://sandbox.ecartpay.com/api/checkouts", .opts=list(postfields = params, httpheader = headers, followlocation = TRUE), style = "httppost")
cat(res)
require "uri"
require "json"
require "net/http"
url = URI("https://sandbox.ecartpay.com/api/checkouts")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw"
request["Content-Type"] = "application/json"
request["Cookie"] = "lang=en"
request.body = JSON.dump({
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
})
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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw".parse()?);
headers.insert("Content-Type", "application/json".parse()?);
headers.insert("Cookie", "lang=en".parse()?);
let data = r#"{
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [
100,
200,
500,
1000,
1500,
3000
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
}"#;
let json: serde_json::Value = serde_json::from_str(&data)?;
let request = client.request(reqwest::Method::POST, "https://sandbox.ecartpay.com/api/checkouts")
.headers(headers)
.json(&json);
let response = request.send().await?;
let body = response.text().await?;
println!("{}", body);
Ok(())
}
# Httpie
printf '{
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [100, 200, 500, 1000, 1500, 3000],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
}'| http --follow --timeout 3600 POST 'https://sandbox.ecartpay.com/api/checkouts' \
Authorization:'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw' \
Content-Type:'application/json' \
Cookie:'lang=en'
// -------------------------------------------------------------
# wget
wget --no-check-certificate --quiet \
--method POST \
--timeout=0 \
--header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw' \
--header 'Content-Type: application/json' \
--header 'Cookie: lang=en' \
--body-data '{
"title": "Ecart Pay",
"subtitle": "The best payment solution",
"image_url": "https://ecartpay.com/img/landing/integraciones/ecart-16.svg",
"currency": "MXN",
"amounts": [100, 200, 500, 1000, 1500, 3000],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"reference_id": "001",
"reference": "Custom recharge"
}' \
'https://sandbox.ecartpay.com/api/checkouts'
let parameters = "{\n \"title\": \"Ecart Pay\",\n \"subtitle\": \"The best payment solution\",\n \"image_url\": \"https://ecartpay.com/img/landing/integraciones/ecart-16.svg\",\n \"currency\": \"MXN\",\n \"amounts\": [100, 200, 500, 1000, 1500, 3000],\n \"concept\": \"Recharge\",\n \"notify_url\": \"https://example.com/webhooks/checkout?user_id=1\",\n \"reference_id\": \"001\",\n \"reference\": \"Custom recharge\"\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://sandbox.ecartpay.com/api/checkouts")!,timeoutInterval: Double.infinity)
request.addValue("eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgzNDE4MDIsImV4cCI6MTczODM0NTQwMn0.oljOZCifmNBdKJMc9J34kWNH6m6UzhOZUWc7L-_WlUdCZy0faONwwfn9SZaFBlAUs9KgStJGFc9PuW5zWcN7Jw", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("lang=en", forHTTPHeaderField: "Cookie")
request.httpMethod = "POST"
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
{
"account_id": "5fab3b20b40b0a613e1b6f15",
"amounts": [
100,
200,
500,
100
],
"concept": "Recharge",
"notify_url": "https://example.com/webhooks/checkout?user_id=1",
"id": "65a8022fb3d93442ccf4f207",
"items": [],
"created_at": "2024-01-17T16:37:03.012Z",
"updated_at": "2024-01-17T16:37:03.012Z"
}
Parameter | Type | Description |
---|---|---|
account_id | string | The ID of the customer. |
items | array of objects | Details of the items included in the checkout:
|
customer_id | string | ID of the customer. |
token | string | Token associated with the checkout for secure access. |
public_id | string | Public ID of the checkout for external references. |
link | string | Link to the checkout interface. |
id | string | Unique identifier of the checkout. |
created_at | string | Timestamp indicating the creation time of the checkout. |
updated_at | string | Timestamp indicating the last update time of the checkout. |
Applications of Custom Checkouts
Ecart Pay’s custom checkout feature can be leveraged for a variety of purposes:
- Processing Payments: Facilitate quick and secure transactions by offering a user-friendly payment interface.
- Account Recharges: Allow customers to recharge their accounts seamlessly with predefined or flexible amounts.
- Event Registrations: Enable payment collection for events or services with personalized checkout details.
Example Use Case Flow
- Customer Selection: A customer selects a product or service on the business’s platform.
- Checkout Generation: The business backend calls the Ecart Pay API to generate a checkout link with the selected details.
- Customer Payment: The customer is redirected to the custom checkout link to complete the transaction.
- Payment Confirmation: The system processes the payment and sends a notification to the provided notify_url.
- Service Delivery: The business confirms the payment and delivers the product or service.
Conclusion
Ecart Pay’s custom checkout functionality empowers businesses to create tailored payment solutions that enhance user experiences and operational efficiency. By leveraging this tool, businesses can provide secure, flexible, and branded transaction processes, meeting diverse customer needs and strengthening their market presence.
Updated about 2 months ago