You can use the APIs below to interface with Xendit's CustomerApi
.
To start using the API, you need to configure the secret key and initiate the client instance.
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \Customer \CustomerApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new CustomerApi ();
All URIs are relative to https://api.xendit.co , except if the operation defines another base path.
createCustomer()
Function
createCustomer ($ idempotency_key , $ for_user_id , $ customer_request ): \Customer \Customer
Create Customer
Function to create a customer that you may use in your Invoice or Payment Requests. For detail explanations, see this link: https://developers.xendit.co/api-reference/#create-customer
Request Parameters - CreateCustomerRequestParams
Name
Type
Required
Default
idempotency_key
string
for_user_id
string
customer_request
CustomerRequest
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \Customer \CustomerApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new CustomerApi ();
$ idempotency_key = "idempotency-123 " ; // string | A unique key to prevent processing duplicate requests.
$ for_user_id = "user-1 " ; // string | The sub-account user-id that you want to make this transaction for.
$ customer_request = new \Xendit \Customer \CustomerRequest (); // \Xendit\Customer\CustomerRequest | Request object for end customer object
try {
$ result = $ apiInstance ->createCustomer ($ idempotency_key , $ for_user_id , $ customer_request );
print_r ($ result );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling CustomerApi->createCustomer: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
getCustomer ($ id , $ for_user_id ): \Customer \Customer
Get Customer By ID
Retrieves a single customer object For detail explanations, see this link: https://developers.xendit.co/api-reference/#get-customer
Request Parameters - GetCustomerRequestParams
Name
Type
Required
Default
id
string
☑️
for_user_id
string
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \Customer \CustomerApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new CustomerApi ();
$ id = "d290f1ee-6c54-4b01-90e6-d701748f0851 " ; // string | End customer resource id
$ for_user_id = "user-1 " ; // string | The sub-account user-id that you want to make this transaction for.
try {
$ result = $ apiInstance ->getCustomer ($ id , $ for_user_id );
print_r ($ result );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling CustomerApi->getCustomer: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
getCustomerByReferenceID()
Function
getCustomerByReferenceID ($ reference_id , $ for_user_id ): \Customer \GetCustomerByReferenceID200Response
GET customers by reference id
Retrieves an array with a customer object that matches the provided reference_id - the identifier provided by you For detail explanations, see this link: https://developers.xendit.co/api-reference/#get-customer-by-reference-id
Request Parameters - GetCustomerByReferenceIDRequestParams
Name
Type
Required
Default
reference_id
string
☑️
for_user_id
string
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \Customer \CustomerApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new CustomerApi ();
$ reference_id = "'reference_id_example' " ; // string | Merchant's reference of end customer
$ for_user_id = "user-1 " ; // string | The sub-account user-id that you want to make this transaction for.
try {
$ result = $ apiInstance ->getCustomerByReferenceID ($ reference_id , $ for_user_id );
print_r ($ result );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling CustomerApi->getCustomerByReferenceID: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
updateCustomer()
Function
updateCustomer ($ id , $ for_user_id , $ patch_customer ): \Customer \Customer
Update End Customer Resource
Function to update an existing customer. For a detailed explanation For detail explanations, see this link: https://developers.xendit.co/api-reference/#update-customer
Request Parameters - UpdateCustomerRequestParams
Name
Type
Required
Default
id
string
☑️
for_user_id
string
patch_customer
PatchCustomer
<?php
require_once (__DIR__ . '/vendor/autoload.php ' );
use Xendit \Configuration ;
use Xendit \Customer \CustomerApi ;
Configuration::setXenditKey ("YOUR_API_KEY_HERE " );
$ apiInstance = new CustomerApi ();
$ id = "d290f1ee-6c54-4b01-90e6-d701748f0851 " ; // string | End customer resource id
$ for_user_id = "user-1 " ; // string | The sub-account user-id that you want to make this transaction for.
$ patch_customer = new \Xendit \Customer \PatchCustomer (); // \Xendit\Customer\PatchCustomer | Update Request for end customer object
try {
$ result = $ apiInstance ->updateCustomer ($ id , $ for_user_id , $ patch_customer );
print_r ($ result );
} catch (\Xendit \XenditSdkException $ e ) {
echo 'Exception when calling CustomerApi->updateCustomer: ' , $ e ->getMessage (), PHP_EOL ;
echo 'Full Error: ' , json_encode ($ e ->getFullError ()), PHP_EOL ;
}
[Back to README]