Customers
Ecart Pay offers a comprehensive system to manage customer records, enabling businesses to store, track, and utilize customer information effectively. This system includes features such as transaction history, customer details, and the generation of interbank CLABE accounts.
Managing customers is a critical aspect of any business, and Ecart Pay provides tools to streamline this process. This entry explains what customers are within the context of Ecart Pay, why they are essential, and how to utilize the provided APIs to create and retrieve customer records. Furthermore, it highlights the benefits of maintaining detailed customer information for enhanced business operations.
What Are Customers in Ecart Pay?
In Ecart Pay, a "customer" refers to an individual or entity that interacts with your business through financial transactions. Customers are identified and managed via unique records that include personal details such as name, email, phone number, and user ID. These records are integral to tracking transaction history, facilitating communication, and generating interbank CLABE accounts for streamlined financial processes.
Why Are Customers Important?
Customers form the foundation of any business. In Ecart Pay, maintaining accurate customer records offers several advantages:
- Enhanced Customer Experience: Enables personalized interactions and efficient service delivery.
- Transaction Tracking: Provides insights into customer behavior and transaction history for better decision-making.
- Financial Management: Facilitates seamless payments and financial operations through features like CLABE generation.
- Data Organization: Ensures that customer information is centralized and accessible for operational efficiency.
Create a Customer
This endpoint allows the creation of new customer records in Ecart Pay by providing essential details such as name, email, phone number, and a user ID.
Endpoint
POST {{baseURL}}/api/customers
Headers
Authorization: {token}
Request Body
{
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}
{
"phone": "8114854378",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"user_id": "004"
}
Example Request
curl --location 'https://sandbox.ecartpay.com/api/customers' \
--header 'Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug' \
--header 'Content-Type: application/json' \
--header 'Cookie: lang=en' \
--data-raw '{
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}'
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.ecartpay.com/api/customers"
method := "POST"
payload := strings.NewReader(`{
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}`)
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 HTTP/1.1
Host: sandbox.ecartpay.com
Authorization: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug
Content-Type: application/json
Cookie: lang=en
Content-Length: 172
{
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}
// OkHttp
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"email\": \"[email protected]\",\n \"first_name\": \"Roberto Alejandro\",\n \"last_name\": \"de la Cruz Martinez\",\n \"phone\": \"4775619358\",\n \"user_id\": \"1234\"\n}");
Request request = new Request.Builder()
.url("https://sandbox.ecartpay.com/api/customers")
.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")
.header("Authorization", "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug")
.header("Content-Type", "application/json")
.header("Cookie", "lang=en")
.body("{\n \"email\": \"[email protected]\",\n \"first_name\": \"Roberto Alejandro\",\n \"last_name\": \"de la Cruz Martinez\",\n \"phone\": \"4775619358\",\n \"user_id\": \"1234\"\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({
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://sandbox.ecartpay.com/api/customers", 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",
"method": "POST",
"timeout": 0,
"headers": {
"Authorization": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
"Content-Type": "application/json",
"Cookie": "lang=en"
},
"data": JSON.stringify({
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
// -------------------------------------------------------------
// XHR
// WARNING: For POST requests, body is set to null by browsers.
var data = JSON.stringify({
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
});
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");
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");
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 \"email\": \"[email protected]\",\n \"first_name\": \"Roberto Alejandro\",\n \"last_name\": \"de la Cruz Martinez\",\n \"phone\": \"4775619358\",\n \"user_id\": \"1234\"\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({
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://sandbox.ecartpay.com/api/customers',
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',
'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({
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
});
req.write(postData);
req.end();
// -------------------------------------------------------------
// Request
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://sandbox.ecartpay.com/api/customers',
'headers': {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
},
body: JSON.stringify({
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
})
};
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')
.headers({
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
})
.send(JSON.stringify({
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}))
.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"]
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 \"email\": \"[email protected]\",\n \"first_name\": \"Roberto Alejandro\",\n \"last_name\": \"de la Cruz Martinez\",\n \"phone\": \"4775619358\",\n \"user_id\": \"1234\"\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 \"email\": \"[email protected]\",\n \"first_name\": \"Roberto Alejandro\",\n \"last_name\": \"de la Cruz Martinez\",\n \"phone\": \"4775619358\",\n \"user_id\": \"1234\"\n}";;
let reqBody =
let uri = Uri.of_string "https://sandbox.ecartpay.com/api/customers" 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',
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 =>'{
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}',
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 = '{
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}';
$request = new Request('POST', 'https://sandbox.ecartpay.com/api/customers', $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');
$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 "email": "[email protected]",\n "first_name": "Roberto Alejandro",\n "last_name": "de la Cruz Martinez",\n "phone": "4775619358",\n "user_id": "1234"\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');
$request->setRequestMethod('POST');
$body = new http\Message\Body;
$body->append('{
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}');
$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 = @"
{
`"email`": `"[email protected]`",
`"first_name`": `"Roberto Alejandro`",
`"last_name`": `"de la Cruz Martinez`",
`"phone`": `"4775619358`",
`"user_id`": `"1234`"
}
"@
$response = Invoke-RestMethod 'https://sandbox.ecartpay.com/api/customers' -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({
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
})
headers = {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
'Content-Type': 'application/json',
'Cookie': 'lang=en'
}
conn.request("POST", "/api/customers", 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"
payload = json.dumps({
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
})
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 = '{
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}';
res <- VERB("POST", url = "https://sandbox.ecartpay.com/api/customers", 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 = "{
\"email\": \"[email protected]\",
\"first_name\": \"Roberto Alejandro\",
\"last_name\": \"de la Cruz Martinez\",
\"phone\": \"4775619358\",
\"user_id\": \"1234\"
}"
res <- postForm("https://sandbox.ecartpay.com/api/customers", .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")
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({
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
})
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#"{
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}"#;
let json: serde_json::Value = serde_json::from_str(&data)?;
let request = client.request(reqwest::Method::POST, "https://sandbox.ecartpay.com/api/customers")
.headers(headers)
.json(&json);
let response = request.send().await?;
let body = response.text().await?;
println!("{}", body);
Ok(())
}
# Httpie
printf '{
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}'| http --follow --timeout 3600 POST 'https://sandbox.ecartpay.com/api/customers' \
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 '{
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234"
}' \
'https://sandbox.ecartpay.com/api/customers'
let parameters = "{\n \"email\": \"[email protected]\",\n \"first_name\": \"Roberto Alejandro\",\n \"last_name\": \"de la Cruz Martinez\",\n \"phone\": \"4775619358\",\n \"user_id\": \"1234\"\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://sandbox.ecartpay.com/api/customers")!,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
{
"account_id": "672a850371be0ecf554d050c",
"email": "[email protected]",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "4775619358",
"user_id": "1234",
"id": "67ab717e8aa61eda0b692fa9",
"created_at": "2025-02-11T15:49:18.334Z",
"updated_at": "2025-02-11T15:49:18.334Z"
}
{
"account_id": "5fab3b20b40b0a613e1b6f15",
"first_name": "Roberto Alejandro",
"last_name": "de la Cruz Martinez",
"phone": "8114854378",
"user_id": "004",
"id": "657b928db4c08f6f66847b09",
"created_at": "2023-12-14T23:41:01.359Z",
"updated_at": "2023-12-14T23:41:01.359Z"
}
Customer Records in Ecart Pay
Customer records in Ecart Pay are displayed in the web application as organized tables containing details such as name, email, creation date, and last updated timestamp. These records are linked to the transactions conducted by the customers, enabling businesses to:
- Store and Retrieve Customer Data: Create, update, and access detailed customer records.
- Analyze Customer Activity: Access transaction histories to understand customer behavior.
- Enhance Financial Interactions: Generate interbank CLABE accounts for customers to streamline payments.

Image 1. Customer Records
Key Details of Customer Records
- Customer Activity: A historical log of transactions performed by the customer.
- Customer Information: Personal details such as name, email, and phone number.
- CLABE Generation: Unique banking credentials for seamless financial operations.

Image 2. Key Details of Customer Records
Retrieve All Customers
This endpoint retrieves a list of all customer records stored in your Ecart Pay account. You can filter results using optional query parameters such as email, phone number, or user ID.
Endpoint
GET {{baseURL}}/api/customers
Headers
Authorization: {token}
Query Parameters
email
: Filter by customer email.phone
: Filter by customer phone number (e.g., "8114854357").user_id
: Filter by unique user ID (e.g., "001").
Example Request
curl --location 'https://sandbox.ecartpay.com/api/customers' \
--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"
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")
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))
}
GET /api/customers 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")
.method("GET", 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.get("https://sandbox.ecartpay.com/api/customers")
.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: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("https://sandbox.ecartpay.com/api/customers", 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",
"method": "GET",
"timeout": 0,
"headers": {
"Authorization": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
"Cookie": "lang=en"
},
};
$.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");
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, "GET");
curl_easy_setopt(curl, CURLOPT_URL, "https://sandbox.ecartpay.com/api/customers");
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: 'get',
maxBodyLength: Infinity,
url: 'https://sandbox.ecartpay.com/api/customers',
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': 'GET',
'hostname': 'sandbox.ecartpay.com',
'path': '/api/customers',
'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': 'GET',
'url': 'https://sandbox.ecartpay.com/api/customers',
'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('GET', 'https://sandbox.ecartpay.com/api/customers')
.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"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Authorization": @"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
@"Cookie": @"lang=en"
};
[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" 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 `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',
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',
'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('GET', 'https://sandbox.ecartpay.com/api/customers', $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');
$request->setMethod(HTTP_Request2::METHOD_GET);
$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');
$request->setRequestMethod('GET');
$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' -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',
'Cookie': 'lang=en'
}
conn.request("GET", "/api/customers", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
// -------------------------------------------------------------
# Requests
import requests
url = "https://sandbox.ecartpay.com/api/customers"
payload = {}
headers = {
'Authorization': 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
'Cookie': 'lang=en'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
# httr
library(httr)
headers = c(
'Authorization' = 'eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug',
'Cookie' = 'lang=en'
)
res <- VERB("GET", url = "https://sandbox.ecartpay.com/api/customers", add_headers(headers))
cat(content(res, 'text'))
// -------------------------------------------------------------
# RCurl
library(RCurl)
headers = c(
"Authorization" = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3MmE4NTAzNzFiZTBlY2Y1NTRkMDUxNiIsImFjY291bnRfaWQiOiI2NzJhODUwMzcxYmUwZWNmNTU0ZDA1MGMiLCJpYXQiOjE3MzkyODg3OTMsImV4cCI6MTczOTI5MjM5M30.o3bUTdpH493jiKsQncJR5F44w-uLXwvbE6DUtlLUndEof7TU4NTIQuI0CwFP5mPlibtlwSUSWitF54hvh30Nug",
"Cookie" = "lang=en"
)
res <- getURL("https://sandbox.ecartpay.com/api/customers", .opts=list(httpheader = headers, followlocation = TRUE))
cat(res)
require "uri"
require "net/http"
url = URI("https://sandbox.ecartpay.com/api/customers")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.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::GET, "https://sandbox.ecartpay.com/api/customers")
.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' \
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'
var request = URLRequest(url: URL(string: "https://sandbox.ecartpay.com/api/customers")!,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
{
"count": 2,
"docs": [
{
"id": "672a9d78e5b53c17fb897e6e",
"account_id": "672a850371be0ecf554d050c",
"email": "[email protected]",
"first_name": "Moises",
"last_name": "Garcia",
"phone": "9341000062",
"clabe": "646010142603002021",
"created_at": "2024-11-05T22:34:32.279Z",
"updated_at": "2024-11-05T22:34:32.279Z"
},
{
"id": "672a8584e5b53c17fb34b06e",
"account_id": "672a850371be0ecf554d050c",
"email": "[email protected]",
"first_name": "Ricardo",
"last_name": "Rdz",
"phone": "8110610948",
"created_at": "2024-11-05T20:52:20.690Z",
"updated_at": "2024-11-12T20:30:28.513Z"
}
],
"pages": 1
}
DISCLAIMERFor detailed instructions on how to generate a Payment Method or save a Card, please refer to the corresponding section in the Ecart Pay documentation.
Conclusion
The ability to manage customer records through Ecart Pay provides businesses with a robust platform to enhance customer interactions, streamline financial operations, and gain actionable insights. By leveraging features such as customer activity tracking, CLABE generation, and centralized data storage, businesses can operate more efficiently and provide superior service to their clients.
Updated about 2 months ago