diff --git a/README.md b/README.md index 45d6faa..a752e3b 100644 --- a/README.md +++ b/README.md @@ -397,6 +397,8 @@ d.create(data: { emailCC?: string[]; emailBCC?: string[]; xIdempotencyKey?: string; + forUserID?: string; + withFeeRule?: string; }) ``` @@ -415,6 +417,8 @@ d.createBatch(data: { emailTo?: string[]; emailCC?: string[]; emailBCC?: string[]; + forUserID?: string; + withFeeRule?: string; }>; xIdempotencyKey?: string; }) diff --git a/examples/with_async/disbursement.js b/examples/with_async/disbursement.js index fa0d818..84c9679 100644 --- a/examples/with_async/disbursement.js +++ b/examples/with_async/disbursement.js @@ -26,6 +26,7 @@ const d = new Disbursement({}); accountNumber: '1234567890', description: `purchase paid from ${banks[0].name}`, amount: 10000, + forUserID: 'for-user-id-test', }); // eslint-disable-next-line no-console console.log('disbursement created:', disb); diff --git a/integration_test/ewallet.test.js b/integration_test/ewallet.test.js index fd6b8f0..a6f11a8 100644 --- a/integration_test/ewallet.test.js +++ b/integration_test/ewallet.test.js @@ -17,48 +17,34 @@ const c = new Customer({}); module.exports = function() { return ew - .createPayment({ - externalID: Date.now().toString(), - amount: 1, - phone: '081234567890', - ewalletType: EWallet.Type.OVO, - }) - .then(({ external_id, ewallet_type }) => - ew.getPayment({ - externalID: external_id, - ewalletType: ewallet_type, - }), - ) - .then(() => - ew.createEWalletCharge({ - referenceID: Date.now().toString(), - currency: 'IDR', - amount: 1688, - checkoutMethod: 'ONE_TIME_PAYMENT', - channelCode: 'ID_OVO', - channelProperties: { - mobileNumber: '+6281234567890', - }, - basket: [ - { - referenceID: 'basket-product-ref-id', - name: 'product name', - category: 'mechanics', - currency: 'IDR', - price: 50000, - quantity: 5, - type: 'wht', - subCategory: 'evr', - metadata: { - meta: 'data', - }, + .createEWalletCharge({ + referenceID: Date.now().toString(), + currency: 'IDR', + amount: 1688, + checkoutMethod: 'ONE_TIME_PAYMENT', + channelCode: 'ID_OVO', + channelProperties: { + mobileNumber: '+6281234567890', + }, + basket: [ + { + referenceID: 'basket-product-ref-id', + name: 'product name', + category: 'mechanics', + currency: 'IDR', + price: 50000, + quantity: 5, + type: 'wht', + subCategory: 'evr', + metadata: { + meta: 'data', }, - ], - metadata: { - meta2: 'data2', }, - }), - ) + ], + metadata: { + meta2: 'data2', + }, + }) .then(r => ew.getEWalletChargeStatus({ chargeID: r.id, diff --git a/package.json b/package.json index 952b112..0c74429 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xendit-node", - "version": "1.19.9", + "version": "1.20.1", "description": "NodeJS client for Xendit API", "main": "index.js", "types": "index.d.ts", @@ -8,6 +8,7 @@ "test": "mocha test/**/*.test.js", "test:integration": "node integration_test", "lint": "eslint index.js ./**/*.{js,ts}", + "lint:fix": "eslint index.js ./**/*.{js,ts} --fix", "format": "prettier --config .prettierrc --write index.js ./**/*.{js,json,ts}", "gentoc": "markdown-toc -i README.md", "release": "np", diff --git a/src/disbursement/disburse.js b/src/disbursement/disburse.js index 9dfd1f8..cb60a68 100644 --- a/src/disbursement/disburse.js +++ b/src/disbursement/disburse.js @@ -19,6 +19,14 @@ function create(data) { data.xIdempotencyKey, ); + if (data && data.forUserID) { + headers['for-user-id'] = data.forUserID; + } + + if (data && data.withFeeRule) { + headers['with-fee-rule'] = data.withFeeRule; + } + fetchWithHTTPErr(`${this.API_ENDPOINT}/disbursements`, { method: 'POST', headers, @@ -55,6 +63,13 @@ function createBatch(data) { this.opts.secretKey, data.xIdempotencyKey, ); + if (data && data.forUserID) { + headers['for-user-id'] = data.forUserID; + } + + if (data && data.withFeeRule) { + headers['with-fee-rule'] = data.withFeeRule; + } fetchWithHTTPErr(`${this.API_ENDPOINT}/batch_disbursements`, { method: 'POST',