Documentation

Customer Cards

Ecart Pay enables businesses to create, manage, and retrieve customer cards efficiently. This system provides flexibility in handling multiple cards per customer, setting default cards, and ensuring smooth payment operations.

Customer cards are an essential component of financial transactions. Ecart Pay allows businesses to create and assign cards to specific customers, enabling seamless transactions and financial management. This entry covers how to generate customer cards, assign them, and manage their settings through the available API endpoints.

Importance of Managing Customer Cards

Efficient management of customer cards is crucial for:

  • Streamlining Transactions: Ensures customers have access to active payment methods.
  • Personalized Financial Management: Assigns and manages multiple cards per customer.
  • Operational Flexibility: Supports setting default cards for specific payment needs.
  • Enhanced Security: Enables businesses to update and remove cards as needed.

Create Customer Card

This endpoint creates a new card for a specific customer by providing card details such as name, number, expiration date, and CVC.

Endpoint

POST {{baseURL}}/api/customers/:customer_id/cards

Headers

  • Authorization: {token}

Path Variables

  • customer_id: The unique identifier for the customer.

Request Body

{
    "name": "Roberto Alejandro de la Cruz",
    "number": "4242424242424242",
    "exp_month": "10",
    "exp_year": "2028",
    "cvc":"111"
}

Example Request

curl --location 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards' \
--header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug' \
--header 'Content-Type: application/json' \
--header 'Cookie: lang=en' \
--data '{
    "name": "Roberto Alejandro de la Cruz",
    "number": "4242424242424242",
    "exp_month": "10",
    "exp_year": "2028",
    "cvc":"111"
}'
package main

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

func main() {

  url := "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards"
  method := "POST"

  payload := strings.NewReader(`{
    "name": "Roberto Alejandro de la Cruz",
    "number": "4242424242424242",
    "exp_month": "10",
    "exp_year": "2028",
    "cvc":"111"
}`)

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

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
  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/customers/65b9520fe35ed4b1662014d1/cards HTTP/1.1
Host: sandbox.ecartpay.com
Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug
Content-Type: application/json
Cookie: lang=en
Content-Length: 144

{
    "name": "Roberto Alejandro de la Cruz",
    "number": "4242424242424242",
    "exp_month": "10",
    "exp_year": "2028",
    "cvc":"111"
}
// OkHttp

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"name\": \"Roberto Alejandro de la Cruz\",\n    \"number\": \"4242424242424242\",\n    \"exp_month\": \"10\",\n    \"exp_year\": \"2028\",\n    \"cvc\":\"111\"\n}");
Request request = new Request.Builder()
  .url("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards")
  .method("POST", body)
  .addHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
  .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/customers/65b9520fe35ed4b1662014d1/cards")
  .header("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
  .header("Content-Type", "application/json")
  .header("Cookie", "lang=en")
  .body("{\n    \"name\": \"Roberto Alejandro de la Cruz\",\n    \"number\": \"4242424242424242\",\n    \"exp_month\": \"10\",\n    \"exp_year\": \"2028\",\n    \"cvc\":\"111\"\n}")
  .asString();
// Fetch

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

const raw = JSON.stringify({
  "name": "Roberto Alejandro de la Cruz",
  "number": "4242424242424242",
  "exp_month": "10",
  "exp_year": "2028",
  "cvc": "111"
});

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

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

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

// jQuery

var settings = {
  "url": "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Authorization": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
    "Content-Type": "application/json",
    "Cookie": "lang=en"
  },
  "data": JSON.stringify({
    "name": "Roberto Alejandro de la Cruz",
    "number": "4242424242424242",
    "exp_month": "10",
    "exp_year": "2028",
    "cvc": "111"
  }),
};

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

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

// XHR

// WARNING: For POST requests, body is set to null by browsers.
var data = JSON.stringify({
  "name": "Roberto Alejandro de la Cruz",
  "number": "4242424242424242",
  "exp_month": "10",
  "exp_year": "2028",
  "cvc": "111"
});

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/customers/65b9520fe35ed4b1662014d1/cards");
xhr.setRequestHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug");
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/customers/65b9520fe35ed4b1662014d1/cards");
  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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug");
  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    \"name\": \"Roberto Alejandro de la Cruz\",\n    \"number\": \"4242424242424242\",\n    \"exp_month\": \"10\",\n    \"exp_year\": \"2028\",\n    \"cvc\":\"111\"\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({
  "name": "Roberto Alejandro de la Cruz",
  "number": "4242424242424242",
  "exp_month": "10",
  "exp_year": "2028",
  "cvc": "111"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards',
  headers: { 
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug', 
    '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/customers/65b9520fe35ed4b1662014d1/cards',
  'headers': {
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
    '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({
  "name": "Roberto Alejandro de la Cruz",
  "number": "4242424242424242",
  "exp_month": "10",
  "exp_year": "2028",
  "cvc": "111"
});

req.write(postData);

req.end();

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

// Request

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards',
  'headers': {
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
    'Content-Type': 'application/json',
    'Cookie': 'lang=en'
  },
  body: JSON.stringify({
    "name": "Roberto Alejandro de la Cruz",
    "number": "4242424242424242",
    "exp_month": "10",
    "exp_year": "2028",
    "cvc": "111"
  })

};
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/customers/65b9520fe35ed4b1662014d1/cards')
  .headers({
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
    'Content-Type': 'application/json',
    'Cookie': 'lang=en'
  })
  .send(JSON.stringify({
    "name": "Roberto Alejandro de la Cruz",
    "number": "4242424242424242",
    "exp_month": "10",
    "exp_year": "2028",
    "cvc": "111"
  }))
  .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/customers/65b9520fe35ed4b1662014d1/cards"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Authorization": @"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
  @"Content-Type": @"application/json",
  @"Cookie": @"lang=en"
};

[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n    \"name\": \"Roberto Alejandro de la Cruz\",\n    \"number\": \"4242424242424242\",\n    \"exp_month\": \"10\",\n    \"exp_year\": \"2028\",\n    \"cvc\":\"111\"\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    \"name\": \"Roberto Alejandro de la Cruz\",\n    \"number\": \"4242424242424242\",\n    \"exp_month\": \"10\",\n    \"exp_year\": \"2028\",\n    \"cvc\":\"111\"\n}";;

let reqBody = 
  let uri = Uri.of_string "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards" in
  let headers = Header.init ()
    |> fun h -> Header.add h "Authorization" "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug"
    |> 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/customers/65b9520fe35ed4b1662014d1/cards',
  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 =>'{
    "name": "Roberto Alejandro de la Cruz",
    "number": "4242424242424242",
    "exp_month": "10",
    "exp_year": "2028",
    "cvc":"111"
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
    'Content-Type: application/json',
    'Cookie: lang=en'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

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

// Guzzle

<?php
$client = new Client();
$headers = [
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Content-Type' => 'application/json',
  'Cookie' => 'lang=en'
];
$body = '{
  "name": "Roberto Alejandro de la Cruz",
  "number": "4242424242424242",
  "exp_month": "10",
  "exp_year": "2028",
  "cvc": "111"
}';
$request = new Request('POST', 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards', $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/customers/65b9520fe35ed4b1662014d1/cards');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Content-Type' => 'application/json',
  'Cookie' => 'lang=en'
));
$request->setBody('{\n    "name": "Roberto Alejandro de la Cruz",\n    "number": "4242424242424242",\n    "exp_month": "10",\n    "exp_year": "2028",\n    "cvc":"111"\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/customers/65b9520fe35ed4b1662014d1/cards');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->append('{
    "name": "Roberto Alejandro de la Cruz",
    "number": "4242424242424242",
    "exp_month": "10",
    "exp_year": "2028",
    "cvc":"111"
}');
$request->setBody($body);
$request->setOptions(array());
$request->setHeaders(array(
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  '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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
$headers.Add("Content-Type", "application/json")
$headers.Add("Cookie", "lang=en")

$body = @"
{
    `"name`": `"Roberto Alejandro de la Cruz`",
    `"number`": `"4242424242424242`",
    `"exp_month`": `"10`",
    `"exp_year`": `"2028`",
    `"cvc`":`"111`"
}
"@

$response = Invoke-RestMethod 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards' -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({
  "name": "Roberto Alejandro de la Cruz",
  "number": "4242424242424242",
  "exp_month": "10",
  "exp_year": "2028",
  "cvc": "111"
})
headers = {
  'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Content-Type': 'application/json',
  'Cookie': 'lang=en'
}
conn.request("POST", "/api/customers/65b9520fe35ed4b1662014d1/cards", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

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

# Requests

import requests
import json

url = "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards"

payload = json.dumps({
  "name": "Roberto Alejandro de la Cruz",
  "number": "4242424242424242",
  "exp_month": "10",
  "exp_year": "2028",
  "cvc": "111"
})
headers = {
  'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  '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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Content-Type' = 'application/json',
  'Cookie' = 'lang=en'
)

body = '{
  "name": "Roberto Alejandro de la Cruz",
  "number": "4242424242424242",
  "exp_month": "10",
  "exp_year": "2028",
  "cvc": "111"
}';

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

cat(content(res, 'text'))

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

# RCurl

library(RCurl)
headers = c(
  "Authorization" = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
  "Content-Type" = "application/json",
  "Cookie" = "lang=en"
)
params = "{
  \"name\": \"Roberto Alejandro de la Cruz\",
  \"number\": \"4242424242424242\",
  \"exp_month\": \"10\",
  \"exp_year\": \"2028\",
  \"cvc\": \"111\"
}"
res <- postForm("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards", .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/customers/65b9520fe35ed4b1662014d1/cards")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug"
request["Content-Type"] = "application/json"
request["Cookie"] = "lang=en"
request.body = JSON.dump({
  "name": "Roberto Alejandro de la Cruz",
  "number": "4242424242424242",
  "exp_month": "10",
  "exp_year": "2028",
  "cvc": "111"
})

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

    let data = r#"{
    "name": "Roberto Alejandro de la Cruz",
    "number": "4242424242424242",
    "exp_month": "10",
    "exp_year": "2028",
    "cvc": "111"
}"#;

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

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

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

    println!("{}", body);

    Ok(())
}
# Httpie

printf '{
    "name": "Roberto Alejandro de la Cruz",
    "number": "4242424242424242",
    "exp_month": "10",
    "exp_year": "2028",
    "cvc":"111"
}'| http  --follow --timeout 3600 POST 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards' \
 Authorization:'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug' \
 Content-Type:'application/json' \
 Cookie:'lang=en'

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

# wget

wget --no-check-certificate --quiet \
  --method POST \
  --timeout=0 \
  --header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug' \
  --header 'Content-Type: application/json' \
  --header 'Cookie: lang=en' \
  --body-data '{
    "name": "Roberto Alejandro de la Cruz",
    "number": "4242424242424242",
    "exp_month": "10",
    "exp_year": "2028",
    "cvc":"111"
}' \
   'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards'
let parameters = "{\n    \"name\": \"Roberto Alejandro de la Cruz\",\n    \"number\": \"4242424242424242\",\n    \"exp_month\": \"10\",\n    \"exp_year\": \"2028\",\n    \"cvc\":\"111\"\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards")!,timeoutInterval: Double.infinity)
request.addValue("eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("lang=en", forHTTPHeaderField: "Cookie")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()

Example Response

{
  "id": "65b954d5e35ed4b1662014ef",
  "brand": "visa",
  "name": "Roberto Alejandro de la Cruz",
  "last": "4242",
  "default": false
}

Managing Multiple Cards per Customer

Ecart Pay supports assigning multiple cards to a single customer. This is beneficial for customers who use different cards for various transactions. Businesses can retrieve, update, or delete these cards as needed, ensuring flexibility and control over payment options.

Retrieve Customer Cards

This endpoint retrieves all cards associated with a specific customer.

Endpoint

GET https://sandbox.ecartpay.com/api/customers/:customer_id/cards/:id/default

Headers

  • Authorization

Path Variables

  • customer_id: Unique identifier of the customer.

Example Request

curl --location 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards' \
--header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug'
package main

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

func main() {

  url := "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards"
  method := "GET"

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

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")

  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))
}
GET /api/customers/65b9520fe35ed4b1662014d1/cards HTTP/1.1
Host: sandbox.ecartpay.com
Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug
// OkHttp

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards")
  .method("GET", body)
  .addHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
  .build();
Response response = client.newCall(request).execute();

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

// Unirest

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.get("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards")
  .header("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
  .asString();
// Fetch

const myHeaders = new Headers();
myHeaders.append("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug");

const requestOptions = {
  method: "GET",
  headers: myHeaders,
  redirect: "follow"
};

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

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

// jQuery

var settings = {
  "url": "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards",
  "method": "GET",
  "timeout": 0,
  "headers": {
    "Authorization": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug"
  },
};

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

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

// XHR

// WARNING: For GET requests, body is set to null by browsers.

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards");
xhr.setRequestHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug");

xhr.send();
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
  curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards");
  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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  res = curl_easy_perform(curl);
  curl_slist_free_all(headers);
}
curl_easy_cleanup(curl);
// Axios

const axios = require('axios');

let config = {
  method: 'get',
  maxBodyLength: Infinity,
  url: 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards',
  headers: { 
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug'
  }
};

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': 'GET',
  'hostname': 'sandbox.ecartpay.com',
  'path': '/api/customers/65b9520fe35ed4b1662014d1/cards',
  'headers': {
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug'
  },
  '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);
  });
});

req.end();

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

// Request

var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards',
  'headers': {
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

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

// Unirest

var unirest = require('unirest');
var req = unirest('GET', 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards')
  .headers({
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug'
  })
  .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/customers/65b9520fe35ed4b1662014d1/cards"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Authorization": @"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug"
};

[request setAllHTTPHeaderFields:headers];

[request setHTTPMethod:@"GET"];

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 reqBody = 
  let uri = Uri.of_string "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards" in
  let headers = Header.init ()
    |> fun h -> Header.add h "Authorization" "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug"
  in
  Client.call ~headers `GET 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/customers/65b9520fe35ed4b1662014d1/cards',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => array(
    'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

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

// Guzzle

<?php
$client = new Client();
$headers = [
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug'
];
$request = new Request('GET', 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards', $headers);
$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/customers/65b9520fe35ed4b1662014d1/cards');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug'
));
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/customers/65b9520fe35ed4b1662014d1/cards');
$request->setRequestMethod('GET');
$request->setOptions(array());
$request->setHeaders(array(
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")

$response = Invoke-RestMethod 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
# http.client

import http.client

conn = http.client.HTTPSConnection("sandbox.ecartpay.com")
payload = ''
headers = {
  'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug'
}
conn.request("GET", "/api/customers/65b9520fe35ed4b1662014d1/cards", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

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

# Requests

import requests

url = "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards"

payload = {}
headers = {
  'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
# httr

library(httr)

headers = c(
  'Authorization' = 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug'
)

res <- VERB("GET", url = "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards", add_headers(headers))

cat(content(res, 'text'))

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

# RCurl

library(RCurl)
headers = c(
  "Authorization" = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug"
)
res <- getURL("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards", .opts=list(httpheader = headers, followlocation = TRUE))
cat(res)
require "uri"
require "net/http"

url = URI("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug"

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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug".parse()?);

    let request = client.request(reqwest::Method::GET, "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards")
        .headers(headers);

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

    println!("{}", body);

    Ok(())
}
# Httpie

http --follow --timeout 3600 GET 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards' \
 Authorization:'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug' \
 Cookie:'lang=en'
 
// -------------------------------------------------------------

# wget

wget --no-check-certificate --quiet \
  --method GET \
  --timeout=0 \
  --header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug' \
  --header 'Cookie: lang=en' \
   'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards'
var request = URLRequest(url: URL(string: "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards")!,timeoutInterval: Double.infinity)
request.addValue("eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug", forHTTPHeaderField: "Authorization")
request.addValue("lang=en", forHTTPHeaderField: "Cookie")

request.httpMethod = "GET"

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()

Example Response

[
  {
    "id": "65b9522be35ed4b1662014d8",
    "brand": "visa",
    "name": "Roberto Alejandro de la Cruz",
    "last": "4242",
    "default": true
  },
  {
    "id": "65b955dbe35ed4b166201500",
    "brand": "visa",
    "name": "Roberto Alejandro de la Cruz",
    "last": "4242",
    "default": false
  }
]

Update Customer Card as Default

This endpoint updates a specific card to be the default for a customer.

Endpoint

PUT {{baseURL}}/api/customers/:customer_id/cards/:id/default

Headers

  • Authorization: {token}

Path Variables

  • customer_id: Unique identifier of the customer.
  • id: Unique identifier of the card.

Example Request

curl --location --request PUT 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default' \
--header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug' \
--header 'Cookie: lang=en'
package main

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

func main() {

  url := "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default"
  method := "PUT"

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

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
  req.Header.Add("Cookie", "lang=en")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
PUT /api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default HTTP/1.1
Host: sandbox.ecartpay.com
Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug
Cookie: lang=en
// OkHttp

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default")
  .method("PUT", body)
  .addHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
  .addHeader("Cookie", "lang=en")
  .build();
Response response = client.newCall(request).execute();

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

// Unirest

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.put("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default")
  .header("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
  .header("Cookie", "lang=en")
  .asString();
// Fetch

const myHeaders = new Headers();
myHeaders.append("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug");
myHeaders.append("Cookie", "lang=en");

const requestOptions = {
  method: "PUT",
  headers: myHeaders,
  redirect: "follow"
};

fetch("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));

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

// jQuery

var settings = {
  "url": "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default",
  "method": "PUT",
  "timeout": 0,
  "headers": {
    "Authorization": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
    "Cookie": "lang=en"
  },
};

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

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

// XHR

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default");
xhr.setRequestHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug");
// WARNING: Cookies will be stripped away by the browser before sending the request.
xhr.setRequestHeader("Cookie", "lang=en");

xhr.send();
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default");
  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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug");
  headers = curl_slist_append(headers, "Cookie: lang=en");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  res = curl_easy_perform(curl);
  curl_slist_free_all(headers);
}
curl_easy_cleanup(curl);
// Axios

const axios = require('axios');

let config = {
  method: 'put',
  maxBodyLength: Infinity,
  url: 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default',
  headers: { 
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug', 
    'Cookie': 'lang=en'
  }
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

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

// Native

var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'PUT',
  'hostname': 'sandbox.ecartpay.com',
  'path': '/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default',
  'headers': {
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
    '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);
  });
});

req.end();

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

// Request

var request = require('request');
var options = {
  'method': 'PUT',
  'url': 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default',
  'headers': {
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
    'Cookie': 'lang=en'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

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

// Unirest

var unirest = require('unirest');
var req = unirest('PUT', 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default')
  .headers({
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
    'Cookie': 'lang=en'
  })
  .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/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Authorization": @"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
  @"Cookie": @"lang=en"
};

[request setAllHTTPHeaderFields:headers];

[request setHTTPMethod:@"PUT"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
open Lwt
open Cohttp
open Cohttp_lwt_unix

let reqBody = 
  let uri = Uri.of_string "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default" in
  let headers = Header.init ()
    |> fun h -> Header.add h "Authorization" "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug"
    |> fun h -> Header.add h "Cookie" "lang=en"
  in
  Client.call ~headers `PUT uri >>= fun (_resp, body) ->
  body |> Cohttp_lwt.Body.to_string >|= fun body -> body

let () =
  let respBody = Lwt_main.run reqBody in
  print_endline (respBody)
// cURL

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_HTTPHEADER => array(
    'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
    'Cookie: lang=en'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

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

// Guzzle

<?php
$client = new Client();
$headers = [
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Cookie' => 'lang=en'
];
$request = new Request('PUT', 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default', $headers);
$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/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default');
$request->setMethod(HTTP_Request2::METHOD_PUT);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Cookie' => 'lang=en'
));
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/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default');
$request->setRequestMethod('PUT');
$request->setOptions(array());
$request->setHeaders(array(
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  '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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
$headers.Add("Cookie", "lang=en")

$response = Invoke-RestMethod 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default' -Method 'PUT' -Headers $headers
$response | ConvertTo-Json
# http.client

import http.client

conn = http.client.HTTPSConnection("sandbox.ecartpay.com")
payload = ''
headers = {
  'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Cookie': 'lang=en'
}
conn.request("PUT", "/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

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

# Requests

import requests

url = "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default"

payload = {}
headers = {
  'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Cookie': 'lang=en'
}

response = requests.request("PUT", url, headers=headers, data=payload)

print(response.text)
# httr

library(httr)

headers = c(
  'Authorization' = 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Cookie' = 'lang=en'
)

res <- VERB("PUT", url = "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default", add_headers(headers))

cat(content(res, 'text'))

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

# RCurl

library(RCurl)
headers = c(
  "Authorization" = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
  "Cookie" = "lang=en"
)
res <- httpPUT("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default", httpheader = headers, followlocation = TRUE)
cat(res)
require "uri"
require "net/http"

url = URI("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug"
request["Cookie"] = "lang=en"

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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug".parse()?);
    headers.insert("Cookie", "lang=en".parse()?);

    let request = client.request(reqwest::Method::PUT, "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default")
        .headers(headers);

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

    println!("{}", body);

    Ok(())
}
# Httpie

http --follow --timeout 3600 PUT 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default' \
 Authorization:'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug' \
 Cookie:'lang=en'
 
// -------------------------------------------------------------

# wget

wget --no-check-certificate --quiet \
  --method PUT \
  --timeout=0 \
  --header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug' \
  --header 'Cookie: lang=en' \
   'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default'
var request = URLRequest(url: URL(string: "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b9533fe35ed4b1662014e7/default")!,timeoutInterval: Double.infinity)
request.addValue("eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug", forHTTPHeaderField: "Authorization")
request.addValue("lang=en", forHTTPHeaderField: "Cookie")

request.httpMethod = "PUT"

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()

Example Response

{
  "id": "65b9533fe35ed4b1662014e7",
  "name": "Roberto Alejandro de la Cruz",
  "last": "4242",
  "default": true
}

Delete Customer Card

This endpoint deletes a specific card associated with a customer.

Endpoint

DELETE {{baseURL}}/api/customers/:customer_id/cards/:id

Headers

  • Authorization: {token}

Path Variables

  • customer_id: Unique identifier of the customer.
  • id: Unique identifier of the card.

Example Request

curl --location --request DELETE 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0' \
--header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug' \
--header 'Cookie: lang=en'
package main

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

func main() {

  url := "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0"
  method := "DELETE"

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

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
  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))
}
DELETE /api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0 HTTP/1.1
Host: sandbox.ecartpay.com
Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug
Cookie: lang=en
// OkHttp

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0")
  .method("DELETE", body)
  .addHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
  .addHeader("Cookie", "lang=en")
  .build();
Response response = client.newCall(request).execute();

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

// Unirest

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.delete("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0")
  .header("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
  .header("Cookie", "lang=en")
  .asString();
// Fetch

const myHeaders = new Headers();
myHeaders.append("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug");
myHeaders.append("Cookie", "lang=en");

const requestOptions = {
  method: "DELETE",
  headers: myHeaders,
  redirect: "follow"
};

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

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

// jQuery

var settings = {
  "url": "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0",
  "method": "DELETE",
  "timeout": 0,
  "headers": {
    "Authorization": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
    "Cookie": "lang=en"
  },
};

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

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

// XHR

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("DELETE", "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0");
xhr.setRequestHeader("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug");
// WARNING: Cookies will be stripped away by the browser before sending the request.
xhr.setRequestHeader("Cookie", "lang=en");

xhr.send();
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
  curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0");
  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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug");
  headers = curl_slist_append(headers, "Cookie: lang=en");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  res = curl_easy_perform(curl);
  curl_slist_free_all(headers);
}
curl_easy_cleanup(curl);
// Axios

const axios = require('axios');

let config = {
  method: 'delete',
  maxBodyLength: Infinity,
  url: 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0',
  headers: { 
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug', 
    'Cookie': 'lang=en'
  }
};

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': 'DELETE',
  'hostname': 'sandbox.ecartpay.com',
  'path': '/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0',
  'headers': {
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
    '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);
  });
});

req.end();

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

// Request

var request = require('request');
var options = {
  'method': 'DELETE',
  'url': 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0',
  'headers': {
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
    'Cookie': 'lang=en'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

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

// Unirest

var unirest = require('unirest');
var req = unirest('DELETE', 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0')
  .headers({
    'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
    'Cookie': 'lang=en'
  })
  .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/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Authorization": @"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
  @"Cookie": @"lang=en"
};

[request setAllHTTPHeaderFields:headers];

[request setHTTPMethod:@"DELETE"];

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 reqBody = 
  let uri = Uri.of_string "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0" in
  let headers = Header.init ()
    |> fun h -> Header.add h "Authorization" "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug"
    |> fun h -> Header.add h "Cookie" "lang=en"
  in
  Client.call ~headers `DELETE 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/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  CURLOPT_HTTPHEADER => array(
    'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
    'Cookie: lang=en'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

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

// Guzzle

<?php
$client = new Client();
$headers = [
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Cookie' => 'lang=en'
];
$request = new Request('DELETE', 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0', $headers);
$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/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0');
$request->setMethod(HTTP_Request2::METHOD_DELETE);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Cookie' => 'lang=en'
));
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/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0');
$request->setRequestMethod('DELETE');
$request->setOptions(array());
$request->setHeaders(array(
  'Authorization' => 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  '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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
$headers.Add("Cookie", "lang=en")

$response = Invoke-RestMethod 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0' -Method 'DELETE' -Headers $headers
$response | ConvertTo-Json
# http.client

import http.client

conn = http.client.HTTPSConnection("sandbox.ecartpay.com")
payload = ''
headers = {
  'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Cookie': 'lang=en'
}
conn.request("DELETE", "/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

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

# Requests

import requests

url = "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0"

payload = {}
headers = {
  'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Cookie': 'lang=en'
}

response = requests.request("DELETE", url, headers=headers, data=payload)

print(response.text)
# httr

library(httr)

headers = c(
  'Authorization' = 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
  'Cookie' = 'lang=en'
)

res <- VERB("DELETE", url = "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0", add_headers(headers))

cat(content(res, 'text'))

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

# RCurl

library(RCurl)
headers = c(
  "Authorization" = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
  "Cookie" = "lang=en"
)
res <- httpDELETE("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0", httpheader = headers, followlocation = TRUE)
cat(res)
require "uri"
require "net/http"

url = URI("https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0")

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

request = Net::HTTP::Delete.new(url)
request["Authorization"] = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug"
request["Cookie"] = "lang=en"

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.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug".parse()?);
    headers.insert("Cookie", "lang=en".parse()?);

    let request = client.request(reqwest::Method::DELETE, "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0")
        .headers(headers);

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

    println!("{}", body);

    Ok(())
}
# Httpie

http --follow --timeout 3600 DELETE 'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0' \
 Authorization:'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug' \
 Cookie:'lang=en'
 
// -------------------------------------------------------------

# wget

wget --no-check-certificate --quiet \
  --method DELETE \
  --timeout=0 \
  --header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug' \
  --header 'Cookie: lang=en' \
   'https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0'
var request = URLRequest(url: URL(string: "https://sandbox.ecartpay.com/api/customers/65b9520fe35ed4b1662014d1/cards/65b952fae35ed4b1662014e0")!,timeoutInterval: Double.infinity)
request.addValue("eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug", forHTTPHeaderField: "Authorization")
request.addValue("lang=en", forHTTPHeaderField: "Cookie")

request.httpMethod = "DELETE"

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()

Example Response

{
  "success": true
}

Conclusion

Ecart Pay provides a versatile and secure system for managing customer cards. From creating and retrieving cards to setting defaults and removing outdated cards, the platform ensures businesses can handle customer payment methods efficiently. This functionality not only enhances customer satisfaction but also supports seamless financial operations.