The PHP library is a library to make it easier for you to integrate with our supported payment channels.

Xendit currently has multiple versions of PHP libraries:

  • v3+ (latest) - Released Sep 20, 2023
  • v2 - Released Feb 21, 2020
  • v1

All upcoming new features are going to be introduced exclusively to our newer SDKs. If you are in v1 or v2, we recommend upgrading to v3 to enjoy the latest features.

This is the list of supported products for Xendit PHP v3+:

  • Credit / Debit Cards (via Payments API)
  • E-Wallets (via Payments API)
  • Virtual Accounts (via Payments API)
  • Retail Outlets (via Payments API)
  • QR Code (via Payments API)
  • Customers
  • Invoices
  • Payouts
  • Balances
  • Transactions


Xendit PHP is compatible with PHP 7.4 or later.


Install the Xendit PHP library by adding the following to your composer.json file

  "repositories": [
      "type": "vcs",
      "url": ""
  "require": {
    "xendit/xendit-php": "4.0.0" // Refer to GitHub for our latest version

Then install the library by running

composer install

You've successfully installed Xendit's PHP library with Composer. Then import the library:

require_once(__DIR__ . '/vendor/autoload.php');

Check out our Python source on Github for the complete installation guide and to verify the latest version.


The SDK needs to be instantiated using your secret API key obtained from the Xendit Dashboard. You can sign up for a free Dashboard account here.

require_once(__DIR__ . '/vendor/autoload.php');

use Xendit\Configuration;


Sample Usage

You can use the APIs below to interface with Xendit's BalanceApi. To start using the API, you need to configure the secret key and initiate the client instance.

require_once(__DIR__ . '/vendor/autoload.php');

use Xendit\Configuration;
use Xendit\BalanceAndTransaction\BalanceApi;


$apiInstance = new BalanceApi();
$account_type = "CASH"; // string | The selected balance type
$currency = "IDR"; // string | Currency for filter for customers with multi currency accounts
$for_user_id = "5dbf20d7c8eb0c0896f811b6"; // 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

try {
    $result = $apiInstance->getBalance($account_type, $currency, $for_user_id);
} catch (\Xendit\XenditSdkException $e) {
    echo 'Exception when calling BalanceApi->getBalance: ', $e->getMessage(), PHP_EOL;
    echo 'Full Error: ', json_encode($e->getFullError()), PHP_EOL;

For sample of other available APIs, please refer to our PHP SDK Github Documentation.

Last Updated on 2024-01-09