Orders

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

⚠️

WARNING

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

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?

Orders are crucial for several reasons:

  • 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 Ecart Pay integration flow

The following diagram shows a suggested flow before creating an Order.

It is not strictly necessary to first register the Customer , the Customer Card, and obtain the card token to create an Order. But it is a great example to help merchants understand how Orders work in a possible integration flow.

Alt text

What should I do next?

  1. Create Order: Use the Create Order endpoint with the necessary payload. (See below)
  2. Receive Payment: Embed the pay_link in your interface to let customers complete their payments.
  3. Webhook Notification: Monitor the notify_url for payment status updates.
  4. Confirm Payment: Use the Get Order method to retrieve the latest order details and confirm payment.
  5. Redirect Customer: Redirect the customer to the redirect_url for a confirmation page.

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


Create an Order

Endpoints

  • POST https://ecartpay.com/api/orders
  • POST https://sandbox.ecartpay.com/api/orders (Sandbox only)

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.

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, it will also show the interest-free installments or fixed installments options when enabled (See Interest-free Payments section).
  • 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
}'
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

{
    "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",
    "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"
}
{
    "id": "62558c758ce9a0398f450c32",
    "account_id": "5fab2d24f16a2000045fc047",
    "authorization_id": "6185b5d29bff2209b9d08f02",
    "number": "OR25622817",
    "status": "created",
    "email": "[email protected]",
    "first_name": "Moises",
    "last_name": "Garcia",
    "phone": "9341000062",
    "currency": "MXN",
    "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
        }
    ],
    "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,
    "confirmed": false,
    "notify_url": "https://example.com/customer/290",
    "redirect_url": "https://example.com/order/10",
    "created_at": "2022-04-12T14:28:05.967Z",
    "updated_at": "2022-04-12T14:28:05.967Z",
    "pay_link": "https://ecart-payment-dev.herokuapp.com/pay/62558c758ce9a0398f450c32"
}
{
    "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"
}


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