Customers - Create
curl --request POST \
--url https://api.sandbox.pesaswap.io/customers \
--header 'Content-Type: application/json' \
--header 'api-key: <api-key>' \
--data '
{
"email": "guest@example.com",
"name": "John Doe"
}
'const options = {
method: 'POST',
headers: {'api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({email: 'guest@example.com', name: 'John Doe'})
};
fetch('https://api.sandbox.pesaswap.io/customers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.sandbox.pesaswap.io/customers"
payload = {
"email": "guest@example.com",
"name": "John Doe"
}
headers = {
"api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.pesaswap.io/customers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => 'guest@example.com',
'name' => 'John Doe'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"customer_id": "cus_y3oqhf46pyzuxjbcn2giaqnb44",
"created_at": "2023-01-18T11:04:09.922Z",
"name": "Jon Test",
"email": "JonTest@test.com",
"phone": "9123456789",
"phone_country_code": "+65",
"description": "First Customer",
"address": {
"city": "New York",
"country": "AF",
"line1": "123, King Street",
"line2": "Powelson Avenue",
"line3": "Bridgewater",
"zip": "08807",
"state": "New York",
"first_name": "John",
"last_name": "Doe"
},
"metadata": {},
"default_payment_method_id": "pm_djh2837dwduh890123"
}Customers
Customers - Create
Creates a customer object and stores the customer details to be reused for future payments. Incase the customer already exists in the system, this API will respond with the customer details.
POST
/
customers
Customers - Create
curl --request POST \
--url https://api.sandbox.pesaswap.io/customers \
--header 'Content-Type: application/json' \
--header 'api-key: <api-key>' \
--data '
{
"email": "guest@example.com",
"name": "John Doe"
}
'const options = {
method: 'POST',
headers: {'api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({email: 'guest@example.com', name: 'John Doe'})
};
fetch('https://api.sandbox.pesaswap.io/customers', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.sandbox.pesaswap.io/customers"
payload = {
"email": "guest@example.com",
"name": "John Doe"
}
headers = {
"api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.pesaswap.io/customers",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => 'guest@example.com',
'name' => 'John Doe'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"customer_id": "cus_y3oqhf46pyzuxjbcn2giaqnb44",
"created_at": "2023-01-18T11:04:09.922Z",
"name": "Jon Test",
"email": "JonTest@test.com",
"phone": "9123456789",
"phone_country_code": "+65",
"description": "First Customer",
"address": {
"city": "New York",
"country": "AF",
"line1": "123, King Street",
"line2": "Powelson Avenue",
"line3": "Bridgewater",
"zip": "08807",
"state": "New York",
"first_name": "John",
"last_name": "Doe"
},
"metadata": {},
"default_payment_method_id": "pm_djh2837dwduh890123"
}Authorizations
Body
application/json
The customer details
Response
Customer Created