xendit / xendit-php

Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services, xenPlatforms
https://developers.xendit.co/api-reference/
MIT License
152 stars 76 forks source link

Problem with Disbursement related to xenPlatform #189

Closed AaEzha closed 1 year ago

AaEzha commented 2 years ago

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.

adityarx commented 1 year ago

Hi @AaEzha, closing this issue as stale. Please help to re-open this in a new issue if you're still facing this problem and would like us to have a look at it 🙏