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

Disbursement error in the format submitted to the server

Open Peepersoak opened this issue 3 years ago • 1 comments

Getting an error when creating a new Disbursement

import xendit from "xendit-node";
const x = new xendit({
  secretKey: DEVELOPMENT_KEY,
});

const { Disbursement } = x;
const disbursementSpecificOptions = {};
const d = new Disbursement(disbursementSpecificOptions);

const disbursementData = {
  externalID: `disb-${unique_id}`,
  amount: 25,
  bankCode: "PH_GCASH",
  accountHolderName: "John Doe",
  accountNumber: "09971234567",
  description: "Sample disbursement",
};

const resp = await d.create(disbursementData);

The error that I get is this, only this.

{ status: 400, code: 'API_VALIDATION_ERROR', message: 'There was an error with the format submitted to the server.' }

I also tried using the default data but still getting the same error

d.create({
  externalID: 'your-external-tracking-ID',
  bankCode: 'BCA',
  accountHolderName: 'Stan',
  accountNumber: '1234567890',
  description: 'Payment for nasi padang',
  amount: 10000,
})

I'm no longer sure which format is wrong, I double check the data and all of them are in the correct format

Peepersoak avatar Nov 13 '22 18:11 Peepersoak

After tying things out with postman, I think one reason might be that I lived and created a disbursement on PH and it has a different format compared to the one being used in Indonesia.

Tried inputting the same data on postman but I got the error that the bank code "PH_GCASH" was not supported since the default secret key in postman which I got from xendit API is located in Indonesia. Change the code to OVO and it works properly. I got the correct response

Now I tried creating my own POST method in postman with my own dev key and it produce a different error, instead of bank_code, it requires a channel_code. Instead of external_id, it requires reference_id, instead of account_holder_name, it only requires account_name and it also required the currency. But in the end, I still get the same error of API_VALIDATION_ERROR with the message of

There was an error with the format submitted to the server.

I think the reason is that PH disbursement has a different format layout compared to the Indonesia one and by default xendit-node only uses the Indonesia format in creating disbursement.

I also can't find the correct format for the PH disbursement in the documentation

Peepersoak avatar Nov 14 '22 07:11 Peepersoak