PHP code example of appkita / xendit-php
1. Go to this page and download the library: Download appkita/xendit-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
appkita / xendit-php example snippets
Xendit::setApiKey('secretKey');
Xendit::setHttpClient($client);
$params = array(
'for-user-id' => '<sub account user id>' //The sub-account user-id that you want to make this transaction for (Optional).
);
\Xendit\Balance::getBalance(string $account_type, array $params);
$getBalance = \Xendit\Balance::getBalance('CASH');
var_dump($getBalance);
\Xendit\PaymentChannels::list();
$getPaymentChannels = \Xendit\PaymentChannels::list();
var_dump($getPaymentChannels);
\Xendit\Cards::create(array $params);
$params = [
'token_id' => '5e2e8231d97c174c58bcf644',
'external_id' => 'card_' . time(),
'authentication_id' => '5e2e8658bae82e4d54d764c0',
'amount' => 100000,
'card_cvn' => '123',
'capture' => false
];
$createCharge = \Xendit\Cards::create($params);
var_dump($createCharge);
\Xendit\Cards::reverseAuthorization(string $id, array $params);
$id = 'charge-id';
$params = ['external_id' => 'ext-id'];
$reverseAuth = \Xendit\Cards::reverseAuthorization(
$id,
$params
);
var_dump($reverseAuth);
\Xendit\Cards::capture(string $id, array $params);
$id = 'charge-id';
$params = ['amount' => 100000];
$captureCharge = \Xendit\Cards::capture($id, $params);
var_dump($captureCharge);
\Xendit\Cards::retrieve(string $id);
$id = 'charge-id';
$getCharge = \Xendit\Cards::retrieve($id);
var_dump($getCharge);
\Xendit\Cards::createRefund(string $id, array $params);
$params = [
'external_id' => 'ext-id',
'amount' => 20000
];
$refund = \Xendit\Cards::createRefund($id, $params);
var_dump($refund);
$params = [
'external_id' => 'ext-id',
'amount' => 20000,
'X-IDEMPOTENCY-KEY' => 'unique-id'
];
$refund = \Xendit\Cards::createRefund($id, $params);
var_dump($refund);
\Xendit\Promotion::create(array $params);
$params = [
'reference_id' => 'reference_123',
'description' => 'test promotion',
'currency' => 'IDR',
'start_time' => '2021-01-01T00:00:00.000Z',
'end_time' => '2021-01-02T00:00:00.000Z',
'promo_code' => 'testpromo',
'discount_amount' => 5000
];
$createPromotion = \Xendit\Promotion::create($params);
var_dump($createPromotion);
\Xendit\CardlessCredit::create(array $params);
$params = [
'cardless_credit_type' => 'KREDIVO',
'external_id' => 'test-cardless-credit-02',
'amount' => 800000,
'payment_type' => '3_months',
'items' => [
[
'id' => '123123',
'name' => 'Phone Case',
'price' => 200000,
'type' => 'Smartphone',
'url' => 'http=>//example.com/phone/phone_case',
'quantity' => 2
],
[
'id' => '234567',
'name' => 'Bluetooth Headset',
'price' => 400000,
'type' => 'Audio',
'url' => 'http=>//example.com/phone/bluetooth_headset',
'quantity' => 1
]
],
'customer_details' => [
'first_name' => 'customer first name',
'last_name' => 'customer last name',
'email' => '[email protected] ',
'phone' => '081513114262'
],
'shipping_address' => [
'first_name' => 'first name',
'last_name' => 'last name',
'address' => 'Jalan Teknologi No. 12',
'city' => 'Jakarta',
'postal_code' => '12345',
'phone' => '081513114262',
'country_code' => 'IDN'
],
'redirect_url' => 'https://example.com',
'callback_url' => 'http://example.com/callback-cardless-credit'
];
$createPayment = \Xendit\CardlessCredit::create($params);
var_dump($createPayment);
\Xendit\CardlessCredit::calculatePaymentTypes(array $params);
$params = [
'cardless_credit_type' => 'KREDIVO',
'amount' => 2000000,
'items' => [
[
'id' => '123123',
'name' => 'Phone Case',
'price' => 1000000,
'type' => 'Smartphone',
'url' => 'http://example.com/phone/phone_case',
'quantity' => 2
]
]
];
$calculatePaymentTypes = \Xendit\CardlessCredit::calculatePaymentTypes($params);
var_dump($calculatePaymentTypes);
\Xendit\Customers::createCustomer(array $params);
$customerParams = [
'reference_id' => '' . time(),
'given_names' => 'customer 1',
'email' => '[email protected] ',
'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);
\Xendit\Customers::getCustomerByReferenceID(string $reference_id);
$reference_id = 'ref_id';
$getCustomer = \Xendit\Customers::getCustomerByReferenceID($reference_id);
var_dump($getCustomer);
\Xendit\DirectDebit::initializeLinkedAccountTokenization(array $params);
$params = [
'customer_id' => '4b7b6050-0830-440a-903b-37d527dbbaa9',
'channel_code' => 'DC_BRI',
'properties' => [
'account_mobile_number' => '+62818555988',
'card_last_four' => '8888',
'card_expiry' => '06/24',
'account_email' => '[email protected] '
],
'metadata' => [
'meta' => 'data'
]
];
$initializeTokenization = \Xendit\DirectDebit::initializeLinkedAccountTokenization($params);
var_dump($initializeTokenization);
\Xendit\DirectDebit::validateOTPForLinkedAccount(string $linked_account_token_id, array $params);
$params = [
'otp_code' => '333000'
];
$validateOTPForLinkedAccount = \Xendit\DirectDebit::validateOTPForLinkedAccount(
'lat-a08fba1b-100c-445b-b788-aaeaf8215e8f',
$params
);
var_dump($validateOTPForLinkedAccount);
\Xendit\DirectDebit::retrieveAccessibleLinkedAccounts(string $linked_account_token_id);
$retrieveAccessibleLinkedAccounts = \Xendit\DirectDebit::retrieveAccessibleLinkedAccounts(
'lat-a08fba1b-100c-445b-b788-aaeaf8215e8f'
);
var_dump($retrieveAccessibleLinkedAccounts);
\Xendit\DirectDebit::unbindLinkedAccountToken(string $linked_account_token_id);
$unbindLinkedAccountToken = \Xendit\DirectDebit::unbindLinkedAccountToken(
'lat-a08fba1b-100c-445b-b788-aaeaf8215e8f'
);
var_dump($unbindLinkedAccountToken);
\Xendit\DirectDebit::createPaymentMethod(array $params);
$params = [
'customer_id' => '4b7b6050-0830-440a-903b-37d527dbbaa9',
'type' => 'DEBIT_CARD',
'properties' => [
'id' => 'la-052d3e2d-bc4d-4c98-8072-8d232a552299'
],
'metadata' => [
'meta' => 'data'
]
];
$createPaymentMethod = \Xendit\DirectDebit::createPaymentMethod($params);
var_dump($createPaymentMethod);
\Xendit\DirectDebit::getPaymentMethodsByCustomerID(string $customer_id);
$getPaymentMethods = \Xendit\DirectDebit::getPaymentMethodsByCustomerID('4b7b6050-0830-440a-903b-37d527dbbaa9');
var_dump($getPaymentMethods);
\Xendit\DirectDebit::createDirectDebitPayment(array $params);
$params = [
'reference_id' => 'test-direct-debit-ref',
'payment_method_id' => 'pm-ebb1c863-c7b5-4f20-b116-b3071b1d3aef',
'currency' => 'IDR',
'amount' => 15000,
'callback_url' => 'http://webhook.site/',
'enable_otp' => true,
'description' => 'test description',
'basket' => [
[
'reference_id' => 'basket-product-ref-id',
'name' => 'product name',
'category' => 'mechanics',
'market' => 'ID',
'price' => 50000,
'quantity' => 5,
'type' => 'product type',
'sub_category' => 'product sub category',
'description' => 'product description',
'url' => 'https://product.url'
]
],
'device' => [
'id' => 'device_id',
'ip_address' => '0.0.0.0',
'ad_id' => 'ad-id',
'imei' => '123a456b789c'
],
'success_redirect_url' => 'https://success-redirect.url',
'failure_redirect_url' => 'https://failure-redirect.url',
'metadata' => [
'meta' => 'data'
],
'Idempotency-key' => '' . time()
];
$createDirectDebitPayment = \Xendit\DirectDebit::createDirectDebitPayment(
$params
);
var_dump($createDirectDebitPayment);
\Xendit\DirectDebit::validateOTPForDirectDebitPayment(
string $direct_debit_payment_id,
array $params
);
$params = [
'otp_code' => '222000'
];
$validateOTPForDirectDebitPayment = \Xendit\DirectDebit::validateOTPForDirectDebitPayment(
'ddpy-7e61b0a7-92f9-4762-a994-c2936306f44c',
$params
);
var_dump($validateOTPForDirectDebitPayment);
\Xendit\DirectDebit::getDirectDebitPaymentByID(
string $direct_debit_payment_id
);
$getDirectDebitPaymentByID = \Xendit\DirectDebit::getDirectDebitPaymentByID(
'ddpy-7e61b0a7-92f9-4762-a994-c2936306f44c'
);
var_dump($getDirectDebitPaymentByID);
\Xendit\DirectDebit::getDirectDebitPaymentByReferenceID(
string $reference_id
);
$getDirectDebitPaymentByReferenceID = \Xendit\DirectDebit::getDirectDebitPaymentByReferenceID(
'test-direct-debit-ref'
);
var_dump($getDirectDebitPaymentByReferenceID);
\Xendit\PayoutsNew::create(array $params);
\Xendit\PayoutsNew::create([
'reference_id' => 'ref-823723232',
'channel_code' => 'ID_BRI',
'channel_properties' => [
'account_number' => '0000000000',
'account_holder_name' => 'Yanuar'
],
'amount' => 1000,
'description' => 'Sample Successful Create IDR Payout',
'currency' => 'IDR',
'receipt_notification' => [
'email_to' => ['[email protected] '],
'email_cc' => ['[email protected] '],
'email_bcc' => ['[email protected] '],
],
'metadata' => [
'lotto_outlet' => 24
]
])
## Using ID
\Xendit\PayoutsNew::retrieve(string $id);
## Using Reference ID
\Xendit\PayoutsNew::retrieveReference(string $referenceID)
\Xendit\PayoutsNew::cancel(string $id);
\Xendit\PayoutsNew::getPayoutsChannels()
\Xendit\Disbursements::create(array $params);
$params = [
'external_id' => 'disb-12345678',
'amount' => 15000,
'bank_code' => 'BCA',
'account_holder_name' => 'Joe',
'account_number' => '1234567890',
'description' => 'Disbursement from Example'
];
$createDisbursements = \Xendit\Disbursements::create($params);
var_dump($createDisbursements);
$params = [
'external_id' => 'disb-12345678',
'amount' => 15000,
'bank_code' => 'BCA',
'account_holder_name' => 'Joe',
'account_number' => '1234567890',
'description' => 'Disbursement from Example',
'X-IDEMPOTENCY-KEY' => 'unique-id'
];
$createDisbursements = \Xendit\Disbursements::create($params);
var_dump($createDisbursements);
\Xendit\Disbursements::createBatch(array $params);
$batch_params = [
'reference' => 'disb_batch-12345678',
'disbursements' => [
[
'amount' => 20000,
'bank_code' => 'BCA',
'bank_account_name' => 'Fadlan',
'bank_account_number' => '1234567890',
'description' => 'Batch Disbursement',
'external_id' => 'disbursement-1'
],
[
'amount' => 30000,
'bank_code' => 'MANDIRI',
'bank_account_name' => 'Lutfi',
'bank_account_number' => '1234567891',
'description' => 'Batch Disbursement with email notifications',
'external_id' => 'disbursement-2',
'email_to' => ['[email protected] '],
'email_cc' => ['[email protected] '],
'email_bcc' => ['[email protected] ', '[email protected] ']
]
]
];
$createBatchDisbursements = \Xendit\Disbursements::createBatch($batch_params);
var_dump($createBatchDisbursements);
\Xendit\Disbursements::retrieve(string $id, array $params);
$id = 'disbursements-id';
$retrieveParams = [
'for-user-id' => 'test-reference-user-id'
]
$getDisbursements = \Xendit\Disbursements::retrieve($id, $retrieveParams);
var_dump($getDisbursements);
\Xendit\Disbursements::retrieveExternal(string $external_id);
$external_id = 'disbursements-ext-id';
$getDisbursementsByExt = \Xendit\Disbursements::retrieveExternal($external_id);
var_dump($getDisbursementsByExt);
\Xendit\Disbursements::getAvailableBanks();
$getDisbursementsBanks = \Xendit\Disbursements::getAvailableBanks();
var_dump($getDisbursementsBanks);
\Xendit\DisbursementsPHP::createPHPDisbursement(array $params);
$params = [
'reference_id' => 'reference_id',
'currency' => 'PHP',
'amount' => 15000,
'channel_code' => 'PH_BDO',
'account_name' => 'Test',
'account_number' => '1234567890',
'description' => 'PHP Disbursement from Example',
'xendit-idempotency-key' => 'unique-id'
];
$createDisbursements = \Xendit\DisbursementsPHP::createPHPDisbursement($params);
var_dump($createDisbursements);
$params = [
'reference_id' => 'reference_id',
'currency' => 'PHP',
'amount' => 15000,
'channel_code' => 'PH_BDO',
'account_name' => 'Test',
'account_number' => '1234567890',
'description' => 'PHP Disbursement from Example',
'xendit-idempotency-key' => 'unique-id',
'beneficiary' => [
'type' => 'INDIVIDUAL',
'given_names' => 'Test Name',
'middle_name' => 'middle_name',
'surname' => 'surname',
'business_name' => 'business_name',
'street_line1' => 'street_line1',
'street_line2' => 'street_line2',
'city' => 'city',
'province' => 'province',
'state' => 'state',
'country' => 'country',
'zip_code' => '12345',
'mobile_number' => '9876543210',
'phone_number' => '987654321',
'email' => '[email protected] '
]
];
$createDisbursementsWithbeneficiary = \Xendit\DisbursementsPHP::createPHPDisbursement($params);
var_dump($createDisbursementsWithbeneficiary);
$params = [
'reference_id' => 'reference_id',
'currency' => 'PHP',
'amount' => 15000,
'channel_code' => 'PH_BDO',
'account_name' => 'Test',
'account_number' => '1234567890',
'description' => 'PHP Disbursement from Example',
'xendit-idempotency-key' => 'unique-id',
'beneficiary' => [
'type' => 'INDIVIDUAL',
'given_names' => 'Test Name',
'middle_name' => 'middle_name',
'surname' => 'surname',
'business_name' => 'business_name',
'street_line1' => 'street_line1',
'street_line2' => 'street_line2',
'city' => 'city',
'province' => 'province',
'state' => 'state',
'country' => 'country',
'zip_code' => '12345',
'mobile_number' => '9876543210',
'phone_number' => '987654321',
'email' => '[email protected] '
],
'receipt_notification' => [
'email_to' => ['[email protected] '],
'email_cc' => [],
'email_bcc' => []
]
];
$createDisbursementsWithReceipt = \Xendit\DisbursementsPHP::createPHPDisbursement($params);
var_dump($createDisbursementsWithReceipt);
\Xendit\DisbursementsPHP::getPHPDisbursementByID(string $id, array $params);
$id = 'php-disbursements-id';
$retrieveParams = [
'for-user-id' => 'test-reference-user-id'
]
$getDisbursements = \Xendit\DisbursementsPHP::getPHPDisbursementByID($id, $retrieveParams);
var_dump($getDisbursements);
\Xendit\DisbursementsPHP::getPHPDisbursementsByReferenceID(string $reference_id);
$reference_id = 'reference_id';
$getDisbursementsByRef = \Xendit\DisbursementsPHP::getPHPDisbursementsByReferenceID($reference_id);
var_dump($getDisbursementsByRef);
\Xendit\DisbursementChannels::getDisbursementChannels();
$disbursementChannels = \Xendit\DisbursementChannels::getDisbursementChannels();
var_dump($disbursementChannels);
\Xendit\DisbursementChannels::getDisbursementChannelsByChannelCategory(string $channelCategory);
$channelCategory = 'Test';
$getdisbursementChannelsByCategory = \Xendit\DisbursementChannels::getDisbursementChannelsByChannelCategory($channelCategory);
var_dump($getdisbursementChannelsByCategory);
\Xendit\DisbursementChannels::getDisbursementChannelsByChannelCode(string $channelCode);
$channelCode = 'Test';
$getdisbursementChannelsByCode = \Xendit\DisbursementChannels::getDisbursementChannelsByChannelCode($channelCode);
var_dump($getdisbursementChannelsByCode);
\Xendit\EWallets::createEWalletCharge(array $params);
$ewalletChargeParams = [
'reference_id' => 'test-reference-id',
'currency' => 'IDR',
'amount' => 50000,
'checkout_method' => 'ONE_TIME_PAYMENT',
'channel_code' => 'ID_SHOPEEPAY',
'channel_properties' => [
'success_redirect_url' => 'https://yourwebsite.com/order/123',
],
'metadata' => [
'meta' => 'data'
]
];
$createEWalletCharge = \Xendit\EWallets::createEWalletCharge($ewalletChargeParams);
var_dump($createEWalletCharge);
\Xendit\EWallets::getEWalletChargeStatus(string $charge_id, array $params);
$charge_id = 'ewc_f3925450-5c54-4777-98c1-fcf22b0d1e1c';
$eWalletStatusParam = [
'for-user-id' => 'test-reference-user-id'
]
$getEWalletChargeStatus = \Xendit\EWallets::getEWalletChargeStatus($charge_id, $eWalletStatusParam);
var_dump($getEWalletChargeStatus);
\Xendit\EWallets::voidEwalletCharge(string $charge_id,array $params);
$charge_id = 'ewc_f3925450-5c54-4777-98c1-fcf22b0d1e1c';
$voidEwalletChargeParam = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
]
$voidEwalletCharge = \Xendit\EWallets::voidEwalletCharge($charge_id, $voidEwalletChargeParam);
var_dump($voidEwalletCharge);
\Xendit\EWallets::refundEwalletCharge(string $charge_id,array $params);
$charge_id = 'ewc_f3925450-5c54-4777-98c1-fcf22b0d1e1c';
$refundEwalletChargeParam = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
]
$refundEwalletCharge = \Xendit\EWallets::refundEwalletCharge($charge_id, $refundEwalletChargeParam);
var_dump($refundEwalletCharge);
\Xendit\EWallets::getRefund(string $charge_id,string $refund_id, array $params);
$charge_id = 'ewc_f3925450-5c54-4777-98c1-fcf22b0d1e1c';
$refund_id = 'ewr_532as23lew2321id';
$getRefundEwalletChargeParam = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
]
$getRefundEwalletCharge = \Xendit\EWallets::getRefund($charge_id, $refund_id, $getRefundEwalletChargeParam);
var_dump($getRefundEwalletCharge);
\Xendit\EWallets::listRefund(string $charge_id, array $params);
$charge_id = 'ewc_f3925450-5c54-4777-98c1-fcf22b0d1e1c';
$listRefundEwalletChargeParam = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
]
$listRefundEwalletCharge = \Xendit\EWallets::listRefund($charge_id, $getRefundEwalletChargeParam);
var_dump($listRefundEwalletCharge);
\Xendit\Invoice::create(array $params);
$params = ['external_id' => 'demo_147580196270',
'payer_email' => '[email protected] ',
'description' => 'Trip to Bali',
'amount' => 32000,
'for-user-id' => '5c2323c67d6d305ac433ba20'
];
$createInvoice = \Xendit\Invoice::create($params);
var_dump($createInvoice);
\Xendit\Invoice::retrieve(string $id, array $params);
$id = 'invoice-id';
$retrieveParam = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
];
$getInvoice = \Xendit\Invoice::retrieve($id, $retrieveParam);
var_dump($getInvoice);
\Xendit\Invoice::retrieveAll(array $params);
$retrieveAllParam = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
];
$getAllInvoice = \Xendit\Invoice::retrieveAll($retrieveAllParam);
var_dump(($getAllInvoice));
\Xendit\Invoice::expireInvoice(string $id, array $params);
$id = 'invoice-id';
$params = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
];
$expireInvoice = \Xendit\Invoice::expireInvoice($id, $params);
var_dump($expireInvoice);
\Xendit\PayLater::initiatePayLaterPlans(array $params);
$params = [
'customer_id' => '<your-customer-id>',
'channel_code' => 'ID_KREDIVO',
'currency' => 'IDR',
'amount' => 6000000,
'order_items' => [
[
'type' => 'PHYSICAL_PRODUCT',
'reference_id' => '1533',
'name' => 'Mobile Phone',
'net_unit_amount' => 6000000,
'quantity' => 1,
'url' => '<your-url>',
'category' => 'Smartphone'
]
]
];
$payLaterPlan = \Xendit\PayLater::initiatePayLaterPlans($params);
var_dump($payLaterPlan);
\Xendit\PayLater::createPayLaterCharge(array $params);
bash
composer
bash
composer update xendit/xendit-php
php
$params = [
'plan_id' => $payLaterPlan['id'],
'reference_id' => 'order_id_' . time(),
'checkout_method' => 'ONE_TIME_PAYMENT',
'success_redirect_url' => '<your-success-redirect-url>',
'failure_redirect_url' => '<your-failure-redirect-url>',
];
$payLaterCharge = \Xendit\PayLater::createPayLaterCharge($params);
var_dump($payLaterCharge);
php
\Xendit\PayLater::getPayLaterChargeStatus($id, array $params);
php
$params = []; // Optional (You can put for-user-id if needed)
$id = '<pay-later-charge-id>';
$payLaterCharge = \Xendit\PayLater::getPayLaterChargeStatus($id, $params);
var_dump($payLaterCharge);
php
\Xendit\PayLater::createPayLaterRefund($id, array $params);
php
$params = []; // Optional (You can put for-user-id if needed)
$id = '<pay-later-charge-id>';
$payLaterCharge = \Xendit\PayLater::createPayLaterRefund($id, $params);
var_dump($payLaterCharge);
php
\Xendit\PayLater::createPayLaterRefund($id, array $params);
php
$params = []; // Optional (You can put for-user-id if needed)
$id = '<pay-later-charge-id>';
$payLaterChargeRefundCreate = \Xendit\PayLater::createPayLaterRefund($id, $params);
var_dump($payLaterChargeRefundCreate);
php
\Xendit\PayLater::getPayLaterRefund($charge_id, $refund_id, array $params);
php
$params = []; // Optional (You can put for-user-id if needed)
$charge_id = '<pay-later-charge-id>';
$refund_id = '<pay-later-refund-id>';
$payLaterChargeRefund = \Xendit\PayLater::getPayLaterRefund($charge_id, $refund_id, $params);
var_dump($payLaterChargeRefund);
php
\Xendit\PayLater::listPayLaterRefund($charge_id, array $params);
php
$params = []; // Optional (You can put for-user-id if needed)
$charge_id = '<pay-later-charge-id>';
$payLaterChargeRefundList = \Xendit\PayLater::listPayLaterRefund($charge_id, $params);
var_dump($payLaterChargeRefundList);
php
$id = 'payout-id';
$voidPayout = \Xendit\Payouts::void($id);
var_dump($voidPayout);
php
\Xendit\Payouts::create(array $params);
php
$params = [
'external_id' => 'payouts-123456789',
'amount' => 50000
];
$createPayout = \Xendit\Payouts::create($params);
var_dump($createPayout);
php
\Xendit\Payouts::retrieve(string $id, array $params);
php
$id = 'payout-id';
$params = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
]
$getPayout = \Xendit\Payouts::retrieve($id, $params);
var_dump($getPayout);
php
$id = 'payout-id';
$voidPayout = \Xendit\Payouts::void($id);
var_dump($voidPayout);
php
\Xendit\QRCode::create(array $params);
php
$params = [
'external_id' => 'demo_123456',
'type' => 'STATIC',
'callback_url' => 'https://webhook.site',
'amount' => 10000,
];
$qr_code = \Xendit\QRCode::create($params);
var_dump($qr_code)
php
\Xendit\QRCode::get(string $external_id);
php
$qr_code = \Xendit\QRCode::get('external_123');
var_dump($qr_code);
php
\Xendit\Recurring::create(array $params);
php
$params = [
'external_id' => 'demo_147580196270',
'payer_email' => '[email protected] ',
'description' => 'Trip to Bali',
'amount' => 32000,
'interval' => 'MONTH',
'interval_count' => 1
];
$createRecurring = \Xendit\Recurring::create($params);
var_dump($createRecurring);
php
\Xendit\Recurring::retrieve(string $id, array $params);
php
$id = 'recurring-payment-id';
$params = [
'for-user-id' => 'test-reference-user-id' // OPTIONAL
]
$getRecurring = \Xendit\Recurring::retrieve($id, $params);
var_dump($getRecurring);
php
\Xendit\Recurring::update(string $id, array $params);
php
$id = 'recurring-payment-id';
$params = ['amount' => 10000];
$editRecurring = \Xendit\Recurring::update($id, $params);
var_dump($editRecurring);
php
\Xendit\Recurring::stop(string $id);
php
$id = 'recurring-payment-id';
$stopRecurring = \Xendit\Recurring::stop($id);
var_dump($stopRecurring);
php
\Xendit\Recurring::pause(string $id);
php
$id = 'recurring-payment-id';
$pauseRecurring = \Xendit\Recurring::pause($id);
var_dump($pauseRecurring);
php
\Xendit\Recurring::resume(string $id);
php
$id = 'recurring-payment-id';
$resumeRecurring = \Xendit\Recurring::resume($id);
var_dump($resumeRecurring);
php
\Xendit\Retail::create(array $params);
php
\Xendit\Retail::update(string $id, array $params);
php
$id = 'FPC-id';
$updateParams = ['expected_amount' => 20000];
$updateFPC = \Xendit\Retail::update($id, $updateParams);
var_dump($updateFPC);
php
\Xendit\Retail::retrieve(string $id);
php
$id = 'FPC-id';
$getFPC = \Xendit\Retail::retrieve($id);
var_dump($getFPC);
php
\Xendit\VirtualAccounts::create(array $params);
php
$params = ["external_id" => "VA_fixed-12341234",
"bank_code" => "MANDIRI",
"name" => "Steve Wozniak"
];
$createVA = \Xendit\VirtualAccounts::create($params);
var_dump($createVA);
php
\Xendit\VirtualAccounts::getVABanks();
php
$getVABanks = \Xendit\VirtualAccounts::getVABanks();
var_dump($getVABanks);
php
\Xendit\VirtualAccounts::retrieve(string $id, array $params);
php
$id = 'VA-id';
$params = [
'for-user-id' => 'test-reference-user-id' //OPTIONAL
]
$getVA = \Xendit\VirtualAccounts::retrieve($id, $params);
var_dump($getVA);
php
\Xendit\VirtualAccounts::update(string $id, array $params);
php
$id = 'VA-id';
$updateParams = ["suggested_amount" => 1000];
$updateVA = \Xendit\VirtualAccounts::update($id, $updateParams);
var_dump($updateVA);
php
\Xendit\VirtualAccounts::getFVAPayment(string $paymentID);
php
$paymentID = 'payment-ID';
$getFVAPayment = \Xendit\VirtualAccounts::getFVAPayment($paymentID);
var_dump($getFVAPayment);
php
\Xendit\Platform::createAccount(array $params);
php
$params = [
'email' => '[email protected] ',
'type' => 'OWNED',
'public_profile' => ['business_name' => 'customer company']
];
$createAccount = \Xendit\Platform::createAccount(array $params);
var_dump($createAccount);
php
$getAccount = \Xendit\Platform::getAccount($accountId);
var_dump($getAccount);
php
$updateAccount = \Xendit\Platform::updateAccount(string $account_id, array $params);
php
$updateParams = [
'email' => '[email protected] ',
'public_profile' => ['business_name' => 'customer company updated']
];
$updateAccount = \Xendit\Platform::updateAccount($accountId, $updateParams);
var_dump($updateAccount);
php
$createTransfer = \Xendit\Platform::createTransfer(array $transferParams);
php
$transferParams = [
'reference' => ''.time(),
'amount' => 50000,
'source_user_id' => '54afeb170a2b18519b1b8768',
'destination_user_id' => '5cafeb170a2b1851246b8768',
];
$createTransfer = \Xendit\Platform::createTransfer($transferParams);
var_dump($createTransfer);
php
$createFeeRule = \Xendit\Platform::createFeeRule(array $feeRuleParams);
php
$feeRuleParams = [
'name' => 'standard_platform_fee',
'description' => 'Fee charged to insurance agents based in Java',
'unit' => 'flat',
'amount' => 6500,
'currency' => 'IDR'
];
$createFeeRule = \Xendit\Platform::createFeeRule($feeRuleParams);
var_dump($createFeeRule);
php
$setCallbackUrl = \Xendit\Platform::setCallbackUrl(string $callbackType, array $callbackUrlParams);
php
$callbackUrlParams = [
'url' => 'https://webhook.site/c9c9140b-96b8-434c-9c59-7440eeae4d7f'
];
$callbackType = 'invoice';
$setCallbackUrl = \Xendit\Platform::setCallbackUrl($callbackType, $callbackUrlParams);
var_dump($setCallbackUrl);
php
\Xendit\Transaction::list(array $params);
php
$params = [
'types' => 'DISBURSEMENT'
'for-user-id' => 'Your User Id', //Optional
'query-param'=> 'true' //This is to enable parameters as query strings
];
$transactions = \Xendit\Transaction::list(array $params);
var_dump($transactions);
php
$detailTransaction = \Xendit\Transaction::detail(string $transaction_id);
var_dump($detailTransaction);
php
\Xendit\Report::generate(array $params);
php
$params = [
'type' => 'TRANSACTIONS'
];
$generate = \Xendit\Report::generate($params);
var_dump($generate);
php
$detailReport = \Xendit\Report::detail('report_5c1b34a2-6ceb-4c24-aba9-c836bac82b28');
var_dump($detailReport);
php
try {
$getInvoice = \Xendit\Invoice::retrieve('123');
} catch (\Xendit\Exceptions\ApiException $e) {
var_dump($e->getMessage());
}
php
try {
$getInvoice = \Xendit\Invoice::retrieve('123');
} catch (\Xendit\Exceptions\ApiException $e) {
var_dump($e->getCode());
}
php
try {
$getInvoice = \Xendit\Invoice::retrieve('123');
} catch (\Xendit\Exceptions\ApiException $e) {
var_dump($e->getErrorCode());
}
bash
php examples\InvoiceExample.php