xendit-php icon indicating copy to clipboard operation
xendit-php copied to clipboard

Problem with Disbursement related to xenPlatform

Open AaEzha opened this issue 3 years ago • 0 comments

First of all, I wanna create a disbursement example within sub-account-id using Laravel framework.

Here the code :

$time = time();

$params = [
    'external_id' => 'DISBURSEMENT-007-' . $time,
    'amount' => (int) rand(1, 20) . '000',
    'bank_code' => 'BCA',
    'account_holder_name' => 'Reza',
    'account_number' => '098765123,
    'description' => 'Disbursement to Reza at ' . date('d F Y, H:i:s'),
    'X-IDEMPOTENCY-KEY' => $time,
    'for-user-id' => '624bd88d95474******',
];

Xendit::setApiKey(env('XENDIT_SECRET_API_KEY'));

$response = \Xendit\Disbursements::create($params);

The issue is everytime I use 'for-user-id' in the parameters, Xendit gives a PENDING and DOESN'T give a COMPLETED callback (Test environment) but it DOES reduce that user balance.

BUT...

If I do this

$time = time();

$params = [
    'external_id' => 'DISBURSEMENT-007-' . $time,
    'amount' => (int) rand(1, 20) . '000',
    'bank_code' => 'BCA',
    'account_holder_name' => 'Reza',
    'account_number' => '098765123,
    'description' => 'Disbursement to Reza at ' . date('d F Y, H:i:s'),
    'X-IDEMPOTENCY-KEY' => $time,
    'for-user-id' => '624bd88d95474******',
];
$response = Http::withBasicAuth(env('XENDIT_SECRET_API_KEY'), '')
  ->post('https://api.xendit.co/disbursements', $params);

The result is Xendit gives a PENDING and COMPLETED callback (Test environment) and it DOES NOT reduce that user balance. Instead it reduces master balance.

This is the summary

Before disbursement
Talent Balance : 32202603
Master Balance : 2816937619


After disbursement sequentially


Using package : 19000
Talent Balance : 32178053       (changed : 24550)
Master Balance : 2816937619
Completed response  : None

Using API : 16000
Talent Balance : 32178053
Master Balance : 2816916069     (changed : 21550)
Completed response  : Yes

Using API : 11000 (with header for-user-id)
Talent Balance : 32161503       (changed : 16550)
Master Balance : 2816916069     
Completed response  : None

Please correct me if i was wrong on doing disbursement.

Thank you.

AaEzha avatar Jul 06 '22 05:07 AaEzha