2020-05-19
Customer Object
Example Customer Object
{
"id": "239c16f4-866d-43e8-9341-7badafbc019f",
"reference_id": "demo_1475801962607",
"email": "customer@website.com",
"mobile_number": null,
"given_names": "John",
"description": null,
"middle_name": null,
"surname": "Doe",
"phone_number": "+6285300000000",
"hashed_phone_number": null,
"nationality": "ID",
"addresses": [{
"country": "ID",
"street_line1": "Jalan Makan",
"street_line2": "Kecematan Kebayoran Baru",
"city": "Jakarta Selatan",
"province": "Daerah Khusus Ibukota Jakarta",
"state": null,
"postal_code": "12160"
}],
"date_of_birth": "2000-01-01",
"metadata": null
}
Version
You are currently viewing API version 2020-05-19. New version is available! Click here to view newer versions.
Parameter | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
string Unique ID generated by Xendit for the particular customer |
||||||||||||||||
reference_id |
string Identifer you provided during request |
||||||||||||||||
mobile_number |
string Mobile number of the customer |
||||||||||||||||
string Email address of the customer |
|||||||||||||||||
given_names |
string Primary of first name/s of the customer |
||||||||||||||||
middle_name |
string Middle name of the customer |
||||||||||||||||
surname |
string Surname of the customer |
||||||||||||||||
description |
string Description you provided for the customer object |
||||||||||||||||
phone_number |
string Alternate or landline phone number |
||||||||||||||||
hashed_phone_number |
string Hashed phone number |
||||||||||||||||
nationality |
string Country code for the customer's nationality |
||||||||||||||||
addresses |
object array Array of objects containing the specific customer's address information
|
||||||||||||||||
date_of_birth |
string Date of birth of the customer in YYYY-MM-DD format |
||||||||||||||||
metadata |
object A free-format JSON for additional information that you provded during request. |
Create Customer
A customer object is required in order to link a payment method for direct debit. This allows you to easily link and track payment methods and transactions.
Endpoint: Create Customer
POST https://api.xendit.co/customers
Version
You are currently viewing API version 2020-05-19. New version is available! Click here to view newer versions.
Create Customer - Request
Example Create Customer Request
curl https://api.xendit.co/customers -X POST \
-u xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==: \
-H 'Content-Type: application/json' \
-H 'API-VERSION: 2020-05-19'
-d reference_id=demo_1475801962607 \
-d given_names="John" \
-d mobile_number="+6287774441111" \
-d email="customer@website.com" \
<?php
use Xendit\Xendit;
require 'vendor/autoload.php';
Xendit::setApiKey('xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==');
$customerParams = [
'reference_id' => '' . time(),
'given_names' => 'customer 1',
'email' => 'customer@website.com',
'mobile_number' => '+6281212345678',
'description' => 'dummy customer',
'middle_name' => 'middle',
'surname' => 'surname',
'addresses' => [
[
'country' => 'ID',
'street_line1' => 'Jl. 123',
'street_line2' => 'Jl. 456',
'city' => 'Jakarta Selatan',
'province' => 'DKI Jakarta',
'state' => '-',
'postal_code' => '12345'
]
],
'metadata' => [
'meta' => 'data'
]
];
$createCustomer = \Xendit\Customers::createCustomer($customerParams);
var_dump($createCustomer);
?>
const x = new require("xendit-node")({
secretKey:
"xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==",
});
const { Customer } = x;
const customerSpecificOptions = {};
const c = new Customer(customerSpecificOptions);
const resp = await c.createCustomer({
referenceID:'demo_1475801962607',
givenNames: 'John',
mobileNumber: '+6287774441111',
email: 'customer@website.com',
});
console.log(resp);
xendit.Opt.SecretKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw=="
customerAddress := xendit.CustomerAddress{
Country: "ID",
StreetLine1: "Jl. 123",
StreetLine2: "Jl. 456",
City: "Jakarta Selatan",
Province: "DKI Jakarta",
State: "-",
PostalCode: "12345",
}
data := customer.CreateCustomerParams{
ReferenceID: "test-reference-id-003",
Email: "tes@tes.com",
GivenNames: "Given Names",
Nationality: "ID",
DateOfBirth: "1995-12-30",
Addresses: []xendit.CustomerAddress{customerAddress},
Metadata: map[string]interface{}{
"meta": "data",
},
}
resp, err := customer.CreateCustomer(&data)
if err != nil {
log.Fatal(err)
}
fmt.Printf("created payment: %+v\n", resp)
try {
Xendit.apiKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==";
CustomerAddress customerAddress = CustomerAddress.builder()
.country("ID")
.streetLine1("Jl. 123")
.streetLine2("Jl. 456")
.city("Jakarta Selatan")
.province("DKI Jakarta")
.state("-")
.postalCode("12345")
.category("None")
.isPreferred(true)
.build();
CustomerAddress[] customerAddressArray = new CustomerAddress[]{customerAddress};
Map<String, Object> metadata = new HashMap<>();
metadata.put("halo", "hello");
metadata.put("tes", "123");
Map<String, Object> params = new HashMap<>();
params.put("reference_id", "test-reference-id");
params.put("email", "tes@tes.com");
params.put("given_names", "Given Names");
params.put("nationality", "ID");
params.put("date_of_birth", "1995-12-30");
params.put("addresses", customerAddressArray);
params.put("metadata", metadata);
Customer customer = Customer.createCustomer(params);
} catch (XenditException e) {
e.printStackTrace();
}
from xendit import Xendit
api_key = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw=="
xendit_instance = Xendit(api_key=api_key)
DirectDebit = xendit_instance.DirectDebit
customer = DirectDebit.create_customer(
reference_id="merc-1594279037",
email="t@x.co",
given_names="Adyaksa",
)
print(customer)
string apiKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==";
XenditClient xendit = new XenditClient(apiKey);
CustomerClient customer = xendit.Customer;
CustomerParameter individualParameterVersion20200519 = new CustomerParameter
{
ReferenceId = "demo_11212162",
Email = "john@email.com",
GivenNames = "John",
Addresses = new Address[] { new Address { Country = Country.Indonesia } }
};
CustomerResponse individualCustomerVersion20200519 = await customer.Create(individualParameterVersion20200519, version: ApiVersion.Version20200519);
Header | Description |
---|---|
for-user-id optional |
string The sub-account user-id that you want to make this transaction for. This header is only used if you have access to xenPlatform. See xenPlatform for more information |
Request Body Parameter | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
reference_id required |
string Merchant-provided identifier for the customer.
|
||||||||||||||||
mobile_number either mobile_number or email is required |
string Mobile number of the customer in E.164 international standard. Format: +(country code)(subscriber number)
|
||||||||||||||||
email either mobile_number or email is required |
string Email address of the customer |
||||||||||||||||
given_names required |
string Primary of first name/s of the customer.
|
||||||||||||||||
middle_name optional |
string Middle name of the customer.
|
||||||||||||||||
surname optional |
string Surname of the customer.
|
||||||||||||||||
description optional |
string Merchant-provided description for the customer object.
|
||||||||||||||||
phone_number optional |
string Alternate or landline phone number in E.164 international standard. Format: +(country code)(subscriber number)
|
||||||||||||||||
hashed_phone_number optional |
string Hashed phone number |
||||||||||||||||
nationality optional |
string
2-letter ISO 3166-2 country code for the customer's nationality |
||||||||||||||||
addresses optional |
array of object Array of objects containing the specific customer's address informationEach object may have the following properties:
|
||||||||||||||||
date_of_birth optional |
string Date of birth of the customer in YYYY-MM-DD format |
||||||||||||||||
metadata optional |
object A free-format JSON for additional information that you may use. |
Create Customer - Response
Example Create Customer Success Response
{
"id": "239c16f4-866d-43e8-9341-7badafbc019f",
"reference_id": "demo_1475801962607",
"email": "customer@website.com",
"mobile_number": null,
"given_names": "John",
"description": null,
"middle_name": null,
"surname": null,
"phone_number": null,
"nationality": null,
"addresses": null,
"date_of_birth": null,
"metadata": null
}
Parameter | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id |
string Unique ID generated by Xendit for the particular customer |
||||||||||||||||
reference_id |
string Identifer you provided during request |
||||||||||||||||
mobile_number |
string Mobile number of the customer |
||||||||||||||||
string Email address of the customer |
|||||||||||||||||
given_names |
string Primary of first name/s of the customer |
||||||||||||||||
middle_name |
string Middle name of the customer |
||||||||||||||||
surname |
string Surname of the customer |
||||||||||||||||
description |
string Description you provided for the customer object |
||||||||||||||||
phone_number |
string Alternate or landline phone number |
||||||||||||||||
nationality |
string Country code for the customer's nationality |
||||||||||||||||
addresses |
object array Array of objects containing the specific customer's address information
|
||||||||||||||||
date_of_birth |
string Date of birth of the customer in YYYY-MM-DD format |
||||||||||||||||
metadata |
object A free-format JSON for additional information that you provded during request. |
Create Customer - Errors
See other common errors here.
Error Code | Description |
---|---|
DUPLICATE_ERROR 409
|
The provided reference_id has been used before. Please enter a unique reference_id and try again. |
Get Customer
Retrieves a single customer object
Endpoint: Get Customer
GET https://api.xendit.co/customers/:id
Version
You are currently viewing API version 2020-05-19. New version is available! Click here to view newer versions.
Request Parameters
Example Get Customer Request
curl https://api.xendit.co/customers/239c16f4-866d-43e8-9341-7badafbc019f -X GET \
-u xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==: \
-H 'API-VERSION: 2020-05-19'
<?php
$url = "https://api.xendit.co/customers/239c16f4-866d-43e8-9341-7badafbc019f";
$apiKey = "xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==:";
$headers = [];
$headers[] = "Content-Type: application/json";
$headers[] = "API-VERSION: 2020-05-19";
$curl = curl_init();
$payload = json_encode($data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_USERPWD, $apiKey.":");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
echo $result;
let apiKey = "xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==:";
let url = "https://api.xendit.co/customers/239c16f4-866d-43e8-9341-7badafbc019f";
var headers = new Headers();
headers.append("Authorization", "Basic " + btoa(apiKey + ":"));
headers.append("Content-Type", "application/json");
headers.append("API-VERSION", "2020-05-19");
var requestOptions = {
method: 'GET',
headers: headers,
redirect: 'follow'
};
fetch(url, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
xendit.Opt.SecretKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw=="
data := customer.getCustomer{
id: 'cust-239c16f4-866d-43e8-9341-7badafbc019f'
}
resp, err := customer.getCustomer(&getCustomerByReferenceIDData)
if err != nil {
log.Fatal(err)
}
fmt.Printf("retrieved customer: %+v\n", resp)
try {
Xendit.apiKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==";
Customer[] customers = Customer.getCustomer("cust-239c16f4-866d-43e8-9341-7badafbc019f");
} catch (XenditException e) {
e.printStackTrace();
}
import requests
import base64
api_key = "xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==:"
url = "https://api.xendit.co/customers/239c16f4-866d-43e8-9341-7badafbc019f"
api_key_bytes = api_key.encode('ascii')
base64_bytes = base64.b64encode(api_key_bytes)
base64_token = base64_bytes.decode('ascii')
auth_token = 'Basic ' + base64_token
headers = {
'Authorization': auth_token,
'API-VERSION': '2020-05-19'
}
response = requests.request("GET", url, headers=headers)
print(response.text)
Header Parameter | Type | Description |
---|---|---|
API-VERSIONoptional |
string |
API version in date semantic (e.g. 2020-05-19). Attach this parameter when calling a specific API version. List of API versions can be found here. |
for-user-idoptional |
string |
The sub-account user-id that you want to make this transaction for. This header is only used if you have access to xenPlatform. See xenPlatform for more information |
Parameter | Type | Description |
---|---|---|
id | string |
Xendit-generated Customer ID. Will start with cust-... |
Response Parameters
Success responses will contain a single Customer Object
Error Codes
See other common errors here.
Error Code | Description |
---|---|
DATA_NOT_FOUND404 |
The provided id does not exist. Please review the id and try again |
Update Customer
Make a PATCH request to this endpoint to update the details on a customer. Only fields present in the request will be updated. Any changes to fields on the customer object will replace that item in its entirety. If you wish to append to an array, your PATCH request should contain the desired end state array (i.e., both the current content and the new array element to append to it). Pass a NULL value to remove the existing content.
Endpoint: Update Customer
PATCH https://api.xendit.co/customers/:id
Version
You are currently viewing API version 2020-05-19. New version is available! Click here to view newer versions.
Request Parameters
Example Update Customer Request
curl https://api.xendit.co/customers/239c16f4-866d-43e8-9341-7badafbc019f -X PATCH \
-u xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==: \
-H 'Content-Type: application/json'
-H 'API-VERSION: 2020-05-19'
--data-raw '{
"given_names": "John",
"surname": "Doe",
"email": "customer@website.com",
"mobile_number": "+628121234567890"
}'
<?php
$url = "https://api.xendit.co/customers/239c16f4-866d-43e8-9341-7badafbc019f";
$apiKey = "xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==:";
$headers = [];
$headers[] = "Content-Type: application/json";
$headers[] = "API-VERSION: 2020-05-19";
$data = [
"given_names" => "Jane",
"surname" => "Doe"
"email"=> "customer@website.com",
"mobile_number"=> "+628121234567890
];
$curl = curl_init();
$payload = json_encode($data);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_USERPWD, $apiKey.":");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
echo $result;
let apiKey = "xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==:";
let url = "https://api.xendit.co/customers/239c16f4-866d-43e8-9341-7badafbc019f";
var headers = new Headers();
headers.append("Authorization", "Basic " + btoa(apiKey + ":"));
headers.append("Content-Type", "application/json");
headers.append("API-VERSION", "2020-05-19");
var reqBody = JSON.stringify({
"given_names": "John",
"surname": "Doe",
"email": "customer@website.com",
"mobile_number": "+628121234567890"});
var requestOptions = {
method: 'PATCH',
headers: headers,
body: reqBody,
redirect: 'follow'
};
fetch(url, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
import requests
import base64
api_key = "xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==:"
url = "https://api.xendit.co/customers"
api_key_bytes = api_key.encode('ascii')
base64_bytes = base64.b64encode(api_key_bytes)
base64_token = base64_bytes.decode('ascii')
payload = {
"given_names": "John",
"surname": "Doe",
"email": "customer@website.com",
"mobile_number": "+628121234567890"
}
auth_token = 'Basic ' + base64_token
headers = {
'Authorization': auth_token,
'API-VERSION': '2020-05-19'
}
response = requests.request("PATCH", url, headers=headers, data=payload)
print(response.text)
string apiKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==";
XenditClient xendit = new XenditClient(apiKey);
CustomerClient customer = xendit.Customer;
CustomerParameter individualParameter = new CustomerParameter
{
GivenNames = "John",
Gender = CustomerGender.Male,
};
CustomerResponse individualCustomerVersion20200519 = await customer.Update(individualParameter);
Header Parameter | Type | Description |
---|---|---|
API-VERSIONoptional |
string |
API version in date semantic (e.g. 2020-10-31). Attach this parameter when calling a specific API version. List of API versions can be found here. |
for-user-idoptional |
string |
The sub-account user-id that you want to make this transaction for. This header is only used if you have access to xenPlatform. See xenPlatform for more information |
Request Body Parameter | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mobile_number either mobile_number or email is required |
string Mobile number of the customer in E.164 international standard. Format: +(country code)(subscriber number)
|
||||||||||||||||
string Email address of the customer |
|||||||||||||||||
given_names |
string Primary of first name/s of the customer
|
||||||||||||||||
middle_name |
string Middle name of the customer
|
||||||||||||||||
surname |
string Surname of the customer
|
||||||||||||||||
description |
string Merchant-provided description for the customer object
|
||||||||||||||||
phone_number |
string Alternate or landline phone number in E.164 international standard. Format: +(country code)(subscriber number)
|
||||||||||||||||
hashed_phone_number |
string Hashed phone number |
||||||||||||||||
nationality |
string
2-letter ISO 3166-2 country code for the customer's nationality |
||||||||||||||||
addresses |
array of object Array of objects containing the specific customer's address informationEach object may have the following properties:
|
||||||||||||||||
date_of_birth |
string Date of birth of the customer in YYYY-MM-DD format |
||||||||||||||||
metadata |
object A free-format JSON for additional information that you may use. |
Response Parameters
Success responses will contain a single Customer Object with the updated content
Error Codes
See other common errors here.
Error Code | Description |
---|---|
DATA_NOT_FOUND404 |
The provided id does not exist. Please review the id and try again |
Get Customer by Reference ID
Retrieves an array with a customer object that matches the provided reference_id
- the identifier provided by you
Endpoint: Get Customer by Reference ID
GET https://api.xendit.co/customers?reference_id={reference_id}
Version
You are currently viewing API version 2020-05-19. New version is available! Click here to view newer versions.
Get Customer by Reference ID - Request
Example Get Customer by Reference ID Request
curl https://api.xendit.co/customers?reference_id=demo_1475801962607 -X GET \
-u xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==: \
-H 'API-VERSION: 2020-05-19'
<?php
use Xendit\Xendit;
require 'vendor/autoload.php';
Xendit::setApiKey('xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==');
$getCustomer = \Xendit\Customers::getCustomerByReferenceID(
'cust-ref-id'
);
var_dump($getCustomer);
?>
const x = new require("xendit-node")({
secretKey:
"xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==",
});
const { Customer } = x;
const customerSpecificOptions = {};
const c = new Customer(customerSpecificOptions);
const resp = await c.getCustomerByReferenceID({
referenceID: 'demo_1475801962607',
});
console.log(resp);
xendit.Opt.SecretKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw=="
data := customer.GetCustomerByReferenceIDParams{
ReferenceID: "test-reference-id-003",
}
resp, err := customer.GetCustomerByReferenceID(&getCustomerByReferenceIDData)
if err != nil {
log.Fatal(err)
}
fmt.Printf("retrieved customer: %+v\n", resp)
try {
Xendit.apiKey = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw==";
Customer[] customers = Customer.getCustomerByReferenceId("test-reference-id");
} catch (XenditException e) {
e.printStackTrace();
}
from xendit import Xendit
api_key = "xnd_development_P4qDfOss0OCpl8RtKrROHjaQYNCk9dN5lSfk+R1l9Wbe+rSiCwZ3jw=="
xendit_instance = Xendit(api_key=api_key)
DirectDebit = xendit_instance.DirectDebit
customer = DirectDebit.get_customer_by_ref_id(
reference_id="merc-1594279037",
)
print(customer)
Query String Parameter | Description |
---|---|
reference_id required |
string Merchant-provided identifier for the customer |
Get Customer by Reference ID - Response
Example Get Customer by Reference ID Success Response
[{
"id": "239c16f4-866d-43e8-9341-7badafbc019f",
"reference_id": "demo_1475801962607",
"email": "customer@website.com",
"mobile_number": null,
"given_names": "John",
"description": null,
"middle_name": null,
"surname": null,
"phone_number": null,
"hashed_phone_number": null,
"nationality": null,
"addresses": null,
"date_of_birth": null,
"metadata": null
}]
Header | Description |
---|---|
for-user-id optional |
string The sub-account user-id that you want to make this transaction for. This header is only used if you have access to xenPlatform. See xenPlatform for more information |
Parameter | Description |
---|---|
id |
string Unique ID generated by Xendit for the particular customer |
reference_id |
string Identifer you provided during request |
mobile_number |
string Mobile number of the customer |
string Email address of the customer |
|
given_names |
string Primary of first name/s of the customer |
middle_name |
string Middle name of the customer |
surname |
string Surname of the customer |
description |
string Description you provided for the customer object |
phone_number |
string Alternate or landline phone number |
nationality |
string Country code for the customer's nationality |
addresses |
object array Array of objects containing the specific customer's address information |
date_of_birth |
string Date of birth of the customer in YYYY-MM-DD format |
metadata |
object A free-format JSON for additional information that you provded during request. |
Get Customer by Reference ID - Errors
See other common errors here.
Changelog
Version 2020-10-31
Update to support BUSINESS type customers and generic identity accounts
Version 2020-05-19
Original version