Orders

Orders are a fundamental component in the payment process, enabling businesses to structure, track, and manage transactions effectively.

What You'll Learn:

  1. Understand what is an Order and why they are important.
  2. Learn what role orders could play in the integration flow of Ecart Pay API.
    1. Possible requests before creating an order.
    2. Steps to follow after creating an order.
  3. Detailed information to help you create an order request, including: Endpoints, Method, Headers and the Body.
    1. Key features of a Create Order response.
  4. Observe request and response examples across different technologies and programming languages.
  5. Best practices and Troubleshooting for this type of request.

What are Orders?

An order represents a structured request for payment that includes all relevant transaction details, such as customer information, items purchased, pricing, and payment statuses. Orders act as a bridge between the business and the customer, ensuring that both parties have a clear record of the transaction.

Why are Orders Important?

Transaction Tracking

Orders provide a systematic way to track payments and ensure accurate record-keeping.

Customer Experience

They offer customers transparency, showing exactly what they are paying for.

Operational Efficiency

Businesses can manage multiple transactions efficiently, using orders to automate processes like invoicing, payment confirmations, and updates.

Payment Security

Orders in EcartPay include predefined payment links and secure handling of sensitive data, ensuring safe transactions.



Orders in an integration flow

It is not strictly necessary to register the Customer , the Customer Card, and obtain the Tokenized Card before creating an Order.

💡

The following diagram shows a suggested workflow before creating an Order. Which means there are other ways a merchant could integrate orders in the backend.

Still, this is a great example to help merchants understand how Orders work in a potential backend integration workflow.

Alt text

What could I do next?

12345

1. Create Order

Use the Create Order endpoint with the necessary payload.

  • If you have a tokenized card, you can include the token in the request payload to process the order during the creation request.
  • Interest-free installments or deferred payments from the tokenized card will be applied to the order.

👍

Ecart Pay API

By leveraging the Create Order endpoint and our API, businesses can seamlessly manage transactions, ensure secure payments, and enhance customer experiences.


⚠️

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 Order

Use this endpoint to create an order.

💻

Visit our API Reference to test this endpoint.

Endpoint

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

Headers

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

Request Payload

The payload for creating an order should include:

Body

  • customer_id: The unique identifier for the customer.
  • currency: The currency for the order (e.g., MXN, USD).
  • items: An array of items with the following details for each:
    • name: Name of the item.
    • quantity: Quantity of the item.
    • price: Price per unit of the item.
  • notify_url: A URL to receive payment status updates via webhooks.
  • redirect_url: The landing page URL for order confirmation upon successful payment.
  • token: This is the Tokenized Card, which can be used for backend integration workflows like the one shown above. This token is particularly useful for configuring Interest-free/fixed installment options in a specific order from your backend.

Response Key Features

  • pay_link: A ready-to-use URL for a secure payment window. Embed this link in your GUI to allow customers to complete the payment.
  • notify_url: A webhook URL to receive order status updates. When the order status changes, EcartPay sends a POST request with the order ID to this URL.
  • redirect_url: After payment is completed, customers are redirected to this URL. Ensure this page displays order details (on success) or an error message (on failure).

Examples

Request

curl --location 'https://sandbox.ecartpay.com/api/orders' \
--header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q' \
--header 'Content-Type: application/json' \
--header 'Cookie: lang=en' \
--data '{
   
    "customer_id": "657b928db4c08f6f66847b09",
    "currency": "MXN",
    "items": [
        {
            "name": "Brazalete religioso plateado BR3017",
            "quantity": 1,
            "price": 243.33
        }
    ],
    "notify_url": "https://example.com/customer/290",
	"send_email": false
}'
curl --location 'https://sandbox.ecartpay.com/api/orders' \
--header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q' \
--header 'Content-Type: application/json' \
--header 'Cookie: lang=en' \
--data '{
   
    "customer_id": "657b928db4c08f6f66847b09",
    "currency": "MXN",
    "items": [
        {
            "name": "Brazalete religioso plateado BR3017",
            "quantity": 1,
            "price": 243.33
        }
    ],
    "notify_url": "https://example.com/customer/290",
    "token": "{{token}}",
		"send_email": false
}'
curl --request POST \
     --url https://sandbox.ecartpay.com/api/orders \
     --header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY4YTRjMzE1MGIyOGE5NTg0MzA1YTJhYSIsImFjY291bnRfaWQiOiI2OGE0YzMxNTBiMjhhOTU4NDMwNWEyYTYiLCJhY2NvdW50Ijp7ImVtYWlsIjoiaHVnby5tb3JpbkBlY2FydHBheS5jb20iLCJmaXJzdF9uYW1lIjoiSHVnbyIsImxhc3RfbmFtZSI6Ik1vcsOtbiIsInBob25lIjoiNTI4MTE2MTI2NzY3IiwiY291bnRyeSI6Ik1YIiwiY3VycmVuY3kiOiJNWE4iLCJ2ZXJpZmllZCI6dHJ1ZSwiYWN0aXZlIjp0cnVlfSwiaWF0IjoxNzU5MTU5MTE5LCJleHAiOjE3NTkxNjI3MTl9.LicDjy2ORZZhHOzpmWvs0lWlWFhxbey0iSXV1XMnXNPBoDO4t2yJsG1wZI-hVKYRry67YYuFEgMjD1XSxoMIBA' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "shipping_address": {
    "country": {
      "code": "MX",
      "name": "Mexico"
    },
    "state": {
      "code": "TB"
    },
    "address1": "Beliario Dominguez",
    "address2": "Semillero",
    "city": "Monterrey",
    "first_name": "Moises",
    "last_name": "Garcia",
    "phone": "9341024062",
    "postal_code": "64000"
  },
  "currency": "MXN",
  "email": "[email protected]",
  "first_name": "Moises",
  "last_name": "Garcia",
  "notify_url": "https://example.com/customer/$id",
  "phone": "9341024062",
  "shipping_items": [
    {
      "amount": 160,
      "carrier": "OWN",
      "name": "Express Shipping"
    }
  ],
  "items": [
    {
      "name": "Brazalete religioso plateado BR3017",
      "price": 243.33,
      "quantity": 1
    }
  ]
}
'
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://sandbox.ecartpay.com/api/orders"
  method := "POST"

  payload := strings.NewReader(`{
   
    "customer_id": "657b928db4c08f6f66847b09",
    "currency": "MXN",
    "items": [
        {
            "name": "Brazalete religioso plateado BR3017",
            "quantity": 1,
            "price": 243.33
        }
    ],
    "notify_url": "https://example.com/customer/290"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q")
  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/orders HTTP/1.1
Host: sandbox.ecartpay.com
Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q
Content-Type: application/json
Cookie: lang=en
Content-Length: 286

{
   
    "customer_id": "657b928db4c08f6f66847b09",
    "currency": "MXN",
    "items": [
        {
            "name": "Brazalete religioso plateado BR3017",
            "quantity": 1,
            "price": 243.33
        }
    ],
    "notify_url": "https://example.com/customer/290"
}
// OkHttp

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n   \n    \"customer_id\": \"657b928db4c08f6f66847b09\",\n    \"currency\": \"MXN\",\n    \"items\": [\n        {\n            \"name\": \"Brazalete religioso plateado BR3017\",\n            \"quantity\": 1,\n            \"price\": 243.33\n        }\n    ],\n    \"notify_url\": \"https://example.com/customer/290\"\n}");
Request request = new Request.Builder()
  .url("https://sandbox.ecartpay.com/api/orders")
  .method("POST", body)
  .addHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q")
  .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/orders")
  .header("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q")
  .header("Content-Type", "application/json")
  .header("Cookie", "lang=en")
  .body("{\n   \n    \"customer_id\": \"657b928db4c08f6f66847b09\",\n    \"currency\": \"MXN\",\n    \"items\": [\n        {\n            \"name\": \"Brazalete religioso plateado BR3017\",\n            \"quantity\": 1,\n            \"price\": 243.33\n        }\n    ],\n    \"notify_url\": \"https://example.com/customer/290\"\n}")
  .asString();
// Fetch

const myHeaders = new Headers();
myHeaders.append("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Cookie", "lang=en");

const raw = JSON.stringify({
  "customer_id": "657b928db4c08f6f66847b09",
  "currency": "MXN",
  "items": [
    {
      "name": "Brazalete religioso plateado BR3017",
      "quantity": 1,
      "price": 243.33
    }
  ],
  "notify_url": "https://example.com/customer/290"
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://sandbox.ecartpay.com/api/orders", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

// -------------------------------------------------------------

// jQuery

var settings = {
  "url": "https://sandbox.ecartpay.com/api/orders",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Authorization": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q",
    "Content-Type": "application/json",
    "Cookie": "lang=en"
  },
  "data": JSON.stringify({
    "customer_id": "657b928db4c08f6f66847b09",
    "currency": "MXN",
    "items": [
      {
        "name": "Brazalete religioso plateado BR3017",
        "quantity": 1,
        "price": 243.33
      }
    ],
    "notify_url": "https://example.com/customer/290"
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});

// -------------------------------------------------------------

// XHR

// WARNING: For POST requests, body is set to null by browsers.
var data = JSON.stringify({
  "customer_id": "657b928db4c08f6f66847b09",
  "currency": "MXN",
  "items": [
    {
      "name": "Brazalete religioso plateado BR3017",
      "quantity": 1,
      "price": 243.33
    }
  ],
  "notify_url": "https://example.com/customer/290"
});

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/orders");
xhr.setRequestHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q");
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/orders");
  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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q");
  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   \n    \"customer_id\": \"657b928db4c08f6f66847b09\",\n    \"currency\": \"MXN\",\n    \"items\": [\n        {\n            \"name\": \"Brazalete religioso plateado BR3017\",\n            \"quantity\": 1,\n            \"price\": 243.33\n        }\n    ],\n    \"notify_url\": \"https://example.com/customer/290\"\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({
  "customer_id": "657b928db4c08f6f66847b09",
  "currency": "MXN",
  "items": [
    {
      "name": "Brazalete religioso plateado BR3017",
      "quantity": 1,
      "price": 243.33
    }
  ],
  "notify_url": "https://example.com/customer/290",
	"send_email": false,
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://sandbox.ecartpay.com/api/orders',
  headers: { 
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q', 
    '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/orders',
  'headers': {
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q',
    '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({
  "customer_id": "657b928db4c08f6f66847b09",
  "currency": "MXN",
  "items": [
    {
      "name": "Brazalete religioso plateado BR3017",
      "quantity": 1,
      "price": 243.33
    }
  ],
  "notify_url": "https://example.com/customer/290"
});

req.write(postData);

req.end();

// -------------------------------------------------------------

// Request

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://sandbox.ecartpay.com/api/orders',
  'headers': {
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q',
    'Content-Type': 'application/json',
    'Cookie': 'lang=en'
  },
  body: JSON.stringify({
    "customer_id": "657b928db4c08f6f66847b09",
    "currency": "MXN",
    "items": [
      {
        "name": "Brazalete religioso plateado BR3017",
        "quantity": 1,
        "price": 243.33
      }
    ],
    "notify_url": "https://example.com/customer/290"
  })

};
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/orders')
  .headers({
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q',
    'Content-Type': 'application/json',
    'Cookie': 'lang=en'
  })
  .send(JSON.stringify({
    "customer_id": "657b928db4c08f6f66847b09",
    "currency": "MXN",
    "items": [
      {
        "name": "Brazalete religioso plateado BR3017",
        "quantity": 1,
        "price": 243.33
      }
    ],
    "notify_url": "https://example.com/customer/290"
  }))
  .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/orders"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Authorization": @"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q",
  @"Content-Type": @"application/json",
  @"Cookie": @"lang=en"
};

[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n   \n    \"customer_id\": \"657b928db4c08f6f66847b09\",\n    \"currency\": \"MXN\",\n    \"items\": [\n        {\n            \"name\": \"Brazalete religioso plateado BR3017\",\n            \"quantity\": 1,\n            \"price\": 243.33\n        }\n    ],\n    \"notify_url\": \"https://example.com/customer/290\"\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   \n    \"customer_id\": \"657b928db4c08f6f66847b09\",\n    \"currency\": \"MXN\",\n    \"items\": [\n        {\n            \"name\": \"Brazalete religioso plateado BR3017\",\n            \"quantity\": 1,\n            \"price\": 243.33\n        }\n    ],\n    \"notify_url\": \"https://example.com/customer/290\"\n}";;

let reqBody = 
  let uri = Uri.of_string "https://sandbox.ecartpay.com/api/orders" in
  let headers = Header.init ()
    |> fun h -> Header.add h "Authorization" "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q"
    |> 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/orders',
  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 =>'{
   
    "customer_id": "657b928db4c08f6f66847b09",
    "currency": "MXN",
    "items": [
        {
            "name": "Brazalete religioso plateado BR3017",
            "quantity": 1,
            "price": 243.33
        }
    ],
    "notify_url": "https://example.com/customer/290",
		"send_email": fasle,
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q',
    'Content-Type: application/json',
    'Cookie: lang=en'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

// -------------------------------------------------------------

// Guzzle

<?php
$client = new Client();
$headers = [
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q',
  'Content-Type' => 'application/json',
  'Cookie' => 'lang=en'
];
$body = '{
  "customer_id": "657b928db4c08f6f66847b09",
  "currency": "MXN",
  "items": [
    {
      "name": "Brazalete religioso plateado BR3017",
      "quantity": 1,
      "price": 243.33
    }
  ],
  "notify_url": "https://example.com/customer/290"
}';
$request = new Request('POST', 'https://sandbox.ecartpay.com/api/orders', $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/orders');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q',
  'Content-Type' => 'application/json',
  'Cookie' => 'lang=en'
));
$request->setBody('{\n   \n    "customer_id": "657b928db4c08f6f66847b09",\n    "currency": "MXN",\n    "items": [\n        {\n            "name": "Brazalete religioso plateado BR3017",\n            "quantity": 1,\n            "price": 243.33\n        }\n    ],\n    "notify_url": "https://example.com/customer/290"\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/orders');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->append('{
   
    "customer_id": "657b928db4c08f6f66847b09",
    "currency": "MXN",
    "items": [
        {
            "name": "Brazalete religioso plateado BR3017",
            "quantity": 1,
            "price": 243.33
        }
    ],
    "notify_url": "https://example.com/customer/290"
}');
$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q',
  '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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q")
$headers.Add("Content-Type", "application/json")
$headers.Add("Cookie", "lang=en")

$body = @"
{
   
    `"customer_id`": `"657b928db4c08f6f66847b09`",
    `"currency`": `"MXN`",
    `"items`": [
        {
            `"name`": `"Brazalete religioso plateado BR3017`",
            `"quantity`": 1,
            `"price`": 243.33
        }
    ],
    `"notify_url`": `"https://example.com/customer/290`"
}
"@

$response = Invoke-RestMethod 'https://sandbox.ecartpay.com/api/orders' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
import http.client
import json

conn = http.client.HTTPSConnection("sandbox.ecartpay.com")
payload = json.dumps({
  "customer_id": "657b928db4c08f6f66847b09",
  "currency": "MXN",
  "items": [
    {
      "name": "Brazalete religioso plateado BR3017",
      "quantity": 1,
      "price": 243.33
    }
  ],
  "notify_url": "https://example.com/customer/290",
	"send_email": false,
})
headers = {
  'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q',
  'Content-Type': 'application/json',
  'Cookie': 'lang=en'
}
conn.request("POST", "/api/orders", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

// -------------------------------------------------------------

# Requests

import requests
import json

url = "https://sandbox.ecartpay.com/api/orders"

payload = json.dumps({
  "customer_id": "657b928db4c08f6f66847b09",
  "currency": "MXN",
  "items": [
    {
      "name": "Brazalete religioso plateado BR3017",
      "quantity": 1,
      "price": 243.33
    }
  ],
  "notify_url": "https://example.com/customer/290"
})
headers = {
  'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q',
  '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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q',
  'Content-Type' = 'application/json',
  'Cookie' = 'lang=en'
)

body = '{
  "customer_id": "657b928db4c08f6f66847b09",
  "currency": "MXN",
  "items": [
    {
      "name": "Brazalete religioso plateado BR3017",
      "quantity": 1,
      "price": 243.33
    }
  ],
  "notify_url": "https://example.com/customer/290"
}';

res <- VERB("POST", url = "https://sandbox.ecartpay.com/api/orders", body = body, add_headers(headers))

cat(content(res, 'text'))

// -------------------------------------------------------------

# RCurl

library(RCurl)
headers = c(
  "Authorization" = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q",
  "Content-Type" = "application/json",
  "Cookie" = "lang=en"
)
params = "{
  \"customer_id\": \"657b928db4c08f6f66847b09\",
  \"currency\": \"MXN\",
  \"items\": [
    {
      \"name\": \"Brazalete religioso plateado BR3017\",
      \"quantity\": 1,
      \"price\": 243.33
    }
  ],
  \"notify_url\": \"https://example.com/customer/290\"
}"
res <- postForm("https://sandbox.ecartpay.com/api/orders", .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/orders")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q"
request["Content-Type"] = "application/json"
request["Cookie"] = "lang=en"
request.body = JSON.dump({
  "customer_id": "657b928db4c08f6f66847b09",
  "currency": "MXN",
  "items": [
    {
      "name": "Brazalete religioso plateado BR3017",
      "quantity": 1,
      "price": 243.33
    }
  ],
  "notify_url": "https://example.com/customer/290",
	"send_email": false,
})

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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q".parse()?);
    headers.insert("Content-Type", "application/json".parse()?);
    headers.insert("Cookie", "lang=en".parse()?);

    let data = r#"{
    "customer_id": "657b928db4c08f6f66847b09",
    "currency": "MXN",
    "items": [
        {
            "name": "Brazalete religioso plateado BR3017",
            "quantity": 1,
            "price": 243.33
        }
    ],
    "notify_url": "https://example.com/customer/290"
}"#;

    let json: serde_json::Value = serde_json::from_str(&data)?;

    let request = client.request(reqwest::Method::POST, "https://sandbox.ecartpay.com/api/orders")
        .headers(headers)
        .json(&json);

    let response = request.send().await?;
    let body = response.text().await?;

    println!("{}", body);

    Ok(())
}
# Httpie

printf '{
   
    "customer_id": "657b928db4c08f6f66847b09",
    "currency": "MXN",
    "items": [
        {
            "name": "Brazalete religioso plateado BR3017",
            "quantity": 1,
            "price": 243.33
        }
    ],
    "notify_url": "https://example.com/customer/290"
}'| http  --follow --timeout 3600 POST 'https://sandbox.ecartpay.com/api/orders' \
 Authorization:'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q' \
 Content-Type:'application/json' \
 Cookie:'lang=en'

// -------------------------------------------------------------

# wget

wget --no-check-certificate --quiet \
  --method POST \
  --timeout=0 \
  --header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q' \
  --header 'Content-Type: application/json' \
  --header 'Cookie: lang=en' \
  --body-data '{
   
    "customer_id": "657b928db4c08f6f66847b09",
    "currency": "MXN",
    "items": [
        {
            "name": "Brazalete religioso plateado BR3017",
            "quantity": 1,
            "price": 243.33
        }
    ],
    "notify_url": "https://example.com/customer/290"
}' \
   'https://sandbox.ecartpay.com/api/orders'
let parameters = "{\n   \n    \"customer_id\": \"657b928db4c08f6f66847b09\",\n    \"currency\": \"MXN\",\n    \"items\": [\n        {\n            \"name\": \"Brazalete religioso plateado BR3017\",\n            \"quantity\": 1,\n            \"price\": 243.33\n        }\n    ],\n    \"notify_url\": \"https://example.com/customer/290\"\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://sandbox.ecartpay.com/api/orders")!,timeoutInterval: Double.infinity)
request.addValue("eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzgwODE0NjAsImV4cCI6MTczODA4NTA2MH0.nbg0d9HM3OMYplMvk_qwYU07V2rnpmBaum4zqWdfzrzjpSbqtzk2DT9w33t2j52o3PFaND9JsRKzz2gtEDBI7Q", 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",
    "customer_id": "657b928db4c08f6f66847b09",
    "type": "order",
    "number": "OR0000029624",
    "status": "created",
    "first_name": "Rob",
    "last_name":  "Schneider",
    "phone": "8111234567",
    "currency": "MXN",
    "country": "MX",
    "items": [
        {
            "name": "Brazalete religioso plateado BR3017",
            "quantity": 1,
            "price": 243.33,
            "discount": 0,
            "total": 243.33,
            "tax": 0,
            "is_service": false,
            "taxes": []
        }
    ],
    "shipping_items": [],
    "discounts": [],
    "totals": {
        "subtotal": 243.33,
        "total": 243.33,
        "tax": 0,
        "discount": 0,
        "shipping": 0
    },
    "risk_score": 0,
    "risk_notes": [],
    "fee": 0,
    "fee_details": {
        "fixed": 0,
        "percent": 0,
        "tax": 0,
        "percent_amount": 0,
        "msi_percent": 0,
        "msi_amount": 0,
        "fixed_installments_amount": 0,
        "fixed_installments_percent": 0,
        "installments_fee": 0
    },
    "available_installments": [],
    "fixed_installments": false,
    "confirmed": false,
    "confirm": false,
    "notify_url": "https://example.com/customer/290",
    "auto_billing": false,
    "available_payment_methods": [],
    "send_email": false,
    "id": "68d43bdcc075d4996e153523",
    "installments_information": [],
    "created_at": "2025-09-24T18:43:40.827Z",
    "updated_at": "2025-09-24T18:43:40.827Z",
    "pay_link": "https://sandbox.ecartpay.com/checkout?id=68d43bdcc075d4996e153523"
}
{
  "account_id": "68a4c3150b28a9584305a2a6",
  "type": "order",
  "number": "OR0000029986",
  "status": "created",
  "email": "[email protected]",
  "first_name": "Moises",
  "last_name": "Garcia",
  "phone": "9341024062",
  "currency": "MXN",
  "country": "MX",
  "shipping_address": {
    "first_name": "Moises",
    "last_name": "Garcia",
    "address1": "Beliario Dominguez",
    "address2": "Semillero",
    "country": {
      "code": "MX",
      "name": "Mexico"
    },
    "state": {
      "code": "TB"
    },
    "city": "Monterrey",
    "postal_code": "64000",
    "phone": "9341024062"
  },
  "items": [
    {
      "name": "Brazalete religioso plateado BR3017",
      "quantity": 1,
      "price": 243.33,
      "discount": 0,
      "total": 243.33,
      "tax": 0,
      "is_service": false,
      "taxes": []
    }
  ],
  "shipping_items": [
    {
      "name": "Express Shipping",
      "amount": 160,
      "carrier": "OWN"
    }
  ],
  "discounts": [],
  "totals": {
    "subtotal": 243.33,
    "total": 403.33,
    "tax": 0,
    "discount": 0,
    "shipping": 160
  },
  "risk_score": 0,
  "risk_notes": [],
  "fee": 0,
  "fee_details": {
    "fixed": 0,
    "percent": 0,
    "tax": 0,
    "percent_amount": 0,
    "msi_percent": 0,
    "msi_amount": 0,
    "fixed_installments_amount": 0,
    "fixed_installments_percent": 0,
    "installments_fee": 0
  },
  "available_installments": [],
  "fixed_installments": false,
  "confirmed": false,
  "confirm": false,
  "notify_url": "https://example.com/customer/$id",
  "auto_billing": false,
  "available_payment_methods": [],
  "send_email": false,
  "id": "68daa3b554802cf804a3374f",
  "installments_information": [],
  "created_at": "2025-09-29T15:20:21.953Z",
  "updated_at": "2025-09-29T15:20:21.953Z",
  "pay_link": "https://sandbox.ecartpay.com/checkout?id=68daa3b554802cf804a3374f"
}
{
    "id": "6255c337c589a8c8e20f865e",
    "account_id": "62559ba8085afe001606a916",
    "authorization_id": "62559c4712b432a003e92361",
    "number": "OR01667152",
    "status": "created",
    "email": "[email protected]",
    "first_name": "Moises",
    "last_name": "Garcia",
    "phone": "9341000062",
  	"currency": "MXN",
		"available_payment_methods": ['card', 'cash', 'transfer'],
    "items": [
        {
            "name": "Brazalete religioso plateado BR3017",
            "quantity": 1,
            "price": 243.33,
            "discount": 0,
            "total": 243.33,
            "tax": 0
        }
    ],
    "shipping_items": [],
    "discounts": [],
    "totals": {
        "subtotal": 243.33,
        "total": 243.33,
        "tax": 0,
        "discount": 0,
        "shipping": 0
    },
    "risk_score": 0,
    "risk_notes": [],
    "fee": 0,
    "confirmed": false,
    "notify_url": "https://example.com/customer/290",
    "redirect_url": "https://example.com/order/10",
    "created_at": "2022-04-12T18:21:43.721Z",
    "updated_at": "2022-04-12T18:21:43.721Z",
    "pay_link": "https://sandbox.ecartpay.com/pay/6255c337c589a8c8e20f865e"
}

Get Order

💻

Visit our API Reference to test this endpoint.

Endpoint

  • GET https://ecartpay.com/api/orders/{id}
  • GET https://sandbox.ecartpay.com/api/orders/{id}

Headers

  • Authorization: {{token}}

Path Parameters

  • id

Examples

Request

curl --request GET \
     --url https://sandbox.ecartpay.com/api/orders/68daaaac54802cf804a338ce \
     --header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9...' \
     --header 'accept: application/json'

Response

{
  "id": "68daaaac54802cf804a338ce",
  "account_id": "68a4c3150b28a9584305a2a6",
  "customer_id": "68cdcfa92ebbd864ef059453",
  "type": "order",
  "number": "OR0000029992",
  "status": "refunded",
  "currency": "MXN",
  "email": "[email protected]",
  "first_name": "Prime",
  "last_name": "NueveCinco",
  "phone": "9117111234",
  "items": [
    {
      "name": "Brazalete religioso plateado BR3017",
      "quantity": 1,
      "price": 2200,
      "discount": 0,
      "total": 2200,
      "tax": 0,
      "is_service": false,
      "taxes": []
    }
  ],
  "shipping_items": [],
  "discounts": [],
  "totals": {
    "subtotal": 2200,
    "total": 2200,
    "tax": 0,
    "discount": 0,
    "shipping": 0
  },
  "confirm": false,
  "auto_billing": false,
  "custom_keys": false,
  "notify_url": "https://example.com/customer/290",
  "activity": [
    {
      "id": "68daaaac54802cf804a338d9",
      "status": "paid",
      "message": "Success!",
      "customer": {
        "first_name": "Prime",
        "last_name": "NueveCinco",
        "phone": "9117111234",
        "email": "[email protected]"
      },
      "device": {
        "ip": "44.212.69.82",
        "timezone": "America/New_York",
        "country": "US",
        "region": "VA",
        "city": "Ashburn",
        "latitude": "39.0481",
        "longitude": "-77.4728"
      },
      "method": {
        "name": "Mastercard Test",
        "exp_month": 1,
        "exp_year": 2050,
        "last4": "2235",
        "brand": "mastercard"
      },
      "risk_level": "highest",
      "risk_notes": [
        {
          "count": 3,
          "score": 7,
          "base": 5,
          "message": "The customer has blocked activity.",
          "values": [
            "68d1c548c7ae70c7985d7314",
            "68d316bd4c232f69744d70d1",
            "68daaa7054802cf804a3387a"
          ],
          "name": "has_bloked"
        },
        {
          "count": 1,
          "score": 20,
          "base": 20,
          "message": "The customer has too many emails.",
          "values": [
            "[email protected]"
          ],
          "name": "too_many_email"
        },
        {
          "count": 2,
          "score": 20,
          "base": 10,
          "message": "The customer has to many cards.",
          "values": [
            "342558******3998",
            "424242******4136"
          ],
          "name": "too_many_cards"
        },
        {
          "count": 15,
          "score": 75,
          "base": 5,
          "message": "The customer has too many successful transactions.",
          "values": [
            "68d1c549c7ae70c7985d732e",
            "68d6b16330eea526a98d659a",
            "68d6c31130eea526a98d676c",
            "68d6d62730eea526a98d6f35",
            "68d6da5f30eea526a98d710e",
            "68d6db0930eea526a98d71c2",
            "68d6dbf830eea526a98d72da",
            "68d6dc9330eea526a98d7336",
            "68d6dd8e30eea526a98d741e",
            "68d6ddef30eea526a98d74f7",
            "68d6deb630eea526a98d7574",
            "68d6df1f30eea526a98d75de",
            "68d6e5e80b3c1f1abcd7d3e3",
            "68d6f70a8991465692643881",
            "68d6f87189914656926439e9"
          ],
          "name": "success_velocity"
        },
        {
          "count": 1,
          "score": 1,
          "base": 1,
          "message": "Detected activity with rounded amounts.",
          "values": [
            2200
          ],
          "name": "round_amount"
        }
      ],
      "risk_score": 123
    }
  ],
  "payments": [
    {
      "id": "17cafada",
      "folio": "3170e9ca",
      "reference": "dda85052",
      "status": "paid",
      "type": "card",
      "currency": "MXN",
      "amount": 220000,
      "gateway": "ecartpay",
      "method": {
        "name": "Mastercard Test",
        "exp_month": "01",
        "exp_year": "2050",
        "type": "credit",
        "last4": "2235",
        "brand": "mastercard",
        "bankname": "ecartpay",
        "domestic": true
      },
      "affiliation_number": "SANDBOX-10-12-17"
    }
  ],
  "transactions": [
    {
      "id": "68daaaac54802cf804a338f6",
      "account_id": "68a4c3150b28a9584305a2a6",
      "transaction_id": "TR0000010814",
      "status": "paid",
      "amount": 2121.82,
      "fee": 78.18,
      "currency": "MXN",
      "gateway": "ecartpay",
      "created_at": "2025-09-29T15:50:04.591Z",
      "updated_at": "2025-09-29T15:51:01.149Z"
    }
  ],
  "refunds": [
    {
      "id": "68daaae454802cf804a33952",
      "account_id": "68a4c3150b28a9584305a2a6",
      "type": "full",
      "reason": "requested",
      "status": "paid",
      "amount": 2200,
      "currency": "MXN",
      "gateway": "ecartpay",
      "created_at": "2025-09-29T15:51:00.571Z",
      "updated_at": "2025-09-29T15:51:01.149Z"
    }
  ],
  "chargebacks": [],
  "created_at": "2025-09-29T15:50:04.051Z",
  "updated_at": "2025-09-29T15:51:01.149Z",
  "fixed_installments": false,
  "fee_details": {
    "percent": 2.9,
    "fixed": 3.6,
    "tax": 10.78,
    "percent_amount": 63.8,
    "msi_amount": 0,
    "msi_percent": 0,
    "fixed_installments_amount": 0,
    "fixed_installments_percent": 0,
    "installments_fee": 0
  },
  "fixed_installments_rate": 0
}


Best Practices

  • Set Proper Headers: Always include Content-Type (e.g., application/json) to define your request body format and Authorization for your API key or token.
  • Validate Data Before Sending: Ensure your payload is correctly formatted (e.g., valid JSON) and contains all required fields to avoid unnecessary errors.
  • Keep It Secure: Always use HTTPS. Never expose secret keys or tokens in client-side code.

Troubleshooting

  • Inspect the HTTP Status Code: This is your most important clue.
  • Validate the Request Body and Headers: Use a JSON validator to ensure your payload is perfectly formatted.
  • Double-check that all required headers, like Content-Type and Authorization, are present and correctly spelled.
  • Review the Error Message: Read the full response body from the API. It often contains a specific error message (e.g., "Field 'amount' is required") that tells you exactly what's wrong.

What’s Next

TESTING