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.

What You'll Learn:

  1. Understand what is a Checkout and why customization makes them so convenient.
  2. Reasons to use custom Checkouts.
  3. Detailed information to help you create a Checkout request, including: Endpoints, Method, Headers and the Body.

What are Checkouts?

You can think of them as a tailor-made final step for clients to complete a payment.

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.

Why is customization so convenient?

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.

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.



⚠️

IMPORTANT

To follow the steps below, it is essential to have the corresponding Authorization Token. For more information, please refer to the following documentation page: Authorization Token

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.

💻

Visit our API Reference to test this endpoint.

Endpoint

  • POST https://ecartpay.com/api/checkouts
  • POST https://sandbox.ecartpay.com/api/checkouts

Headers

  • Authorization: {token}
  • Content-Type: application/json

Request Body

  • customer_id: The ID of the customer.
  • title: Title of the checkout.
  • subtitle: Subtitle of the checkout.
  • image_url: URL of the associated image.
  • currency: Currency for the transaction.
  • amounts: Array of amounts available for selection.
  • concept: Description of the checkout concept.
  • notify_url: URL for receiving transaction notifications.
  • reference_id: Unique reference ID for the checkout.
  • reference: Description of the reference.

Response

  • account_id (string): ID of the account associated with the checkout.
  • title (string): Title of the checkout.
  • subtitle (string): Subtitle of the checkout.
  • image_url (string): URL of the image associated with the checkout.
  • currency (string): Currency for the transaction.
  • amounts (array of numbers): Array of amounts.
  • concept (string): Description of the checkout concept.
  • items (array of objects): Details of the items included in the checkout.
    • name (string): Name of the item.
    • quantity (number): Quantity of the item.
    • price (number): Price of the item.
    • discount (number): Discount on the item.
    • is_service (boolean): Indicates if the item is a service.
    • id (string): ID of the item.
  • customer_id (string): ID of the customer.
  • notify_url (string): URL for receiving notifications.
  • reference_id (string): Reference ID for the checkout.
  • reference (string): Reference for the checkout.
  • token (string): Token associated with the checkout.
  • public_id (string): Public ID of the checkout.
  • link (string): Link to the checkout.
  • id (string): ID of the checkout.
  • created_at (string): Timestamp indicating the creation time.
  • updated_at (string): Timestamp indicating the last update time.

Examples

Request

curl --request POST \
     --url https://sandbox.ecartpay.com/api/checkouts \
     --header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY4YTRjMzE1MGIyOGE5NTg0MzA1YTJhYSIsImFjY291bnRfaWQiOiI2OGE0YzMxNTBiMjhhOTU4NDMwNWEyYTYiLCJhY2NvdW50Ijp7ImVtYWlsIjoiaHVnby5tb3JpbkBlY2FydHBheS5jb20iLCJmaXJzdF9uYW1lIjoiSHVnbyIsImxhc3RfbmFtZSI6Ik1vcsOtbiIsInBob25lIjoiNTI4MTE2MTI2NzY3IiwiY291bnRyeSI6Ik1YIiwiY3VycmVuY3kiOiJNWE4iLCJ2ZXJpZmllZCI6dHJ1ZSwiYWN0aXZlIjp0cnVlfSwiaWF0IjoxNzU5MTY2ODIyLCJleHAiOjE3NTkxNzA0MjJ9.Tkr46XFFaVoBw5oH04uljBCl32N8G2yNvDkT_a8PH3C75FZ1flf7o70T3hQ6yiuy6-dvL8kcJeyTtu5u12gynw' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "concept": "Recharge",
  "currency": "MXN",
  "notify_url": "https://example.com/webhooks/checkout?user_id=1",
  "amounts": [
    100,
    200,
    500,
    1000
  ]
}
'
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()

Response

{
  "account_id": "68a4c3150b28a9584305a2a6",
  "currency": "MXN",
  "amounts": [
    100,
    200,
    500,
    1000
  ],
  "concept": "Recharge",
  "items": [
    {
      "name": "Recharge",
      "quantity": 1,
      "price": 100,
      "discount": 0,
      "is_service": false,
      "id": "68dac627ff8f016d8e168c8b"
    }
  ],
  "notify_url": "https://example.com/webhooks/checkout?user_id=1",
  "token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY4YTRjMzE1MGIyOGE5NTg0MzA1YTJhYSIsImFjY291bnRfaWQiOiJ1bmRlZmluZWQiLCJzY29wZXMiOiJ3cml0ZV9jaGVja291dHMiLCJpYXQiOjE3NTkxNjgwMzksImV4cCI6MTc1OTE2OTgzOSwiYXVkIjoiaHR0cHM6Ly9zYW5kYm94LmVjYXJ0cGF5LmNvbSIsInN1YiI6ImNoZWNrb3V0cyJ9.5V6U88mnqDydNE9rWROxrzOsDbhodaXMA427p_kfY3h6XmCdO0Z1eitD0xHQoTS6hwCJDArVe2sp3N3RjnesVA",
  "public_id": "pub68a4c3150b28a9584305a2a8",
  "link": "https://sandbox.ecartpay.com/v2/checkout?id=68dac627ff8f016d8e168c89",
  "id": "68dac627ff8f016d8e168c89",
  "created_at": "2025-09-29T17:47:19.661Z",
  "updated_at": "2025-09-29T17:47:19.661Z"
}

Parameter

Type

Description

account_id

string

The ID of the customer.

items

array of objects

Details of the items included in the checkout:

  • name (string): Name of the item.
  • quantity (number): Quantity of the item.
  • price (number): Price of the item.
  • discount (number): Discount on the item.
  • is_service (boolean): Indicates if the item is a service.
  • id (string): ID of the item.

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 steps

12345

Customer Selection

A customer selects a product or service on the business’s platform.


💡

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.