From 05ee98b4258ebe2e51b7f73397db3135c03f9c0d Mon Sep 17 00:00:00 2001 From: Hendry Zheng Date: Tue, 22 Feb 2022 16:32:39 +0700 Subject: [PATCH 1/4] add forUserId on disbrusement https://github.com/xendit/xendit-node/issues/140 --- README.md | 2 ++ examples/with_async/disbursement.js | 1 + package.json | 2 +- src/disbursement/disburse.js | 9 +++++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 45d6faa..549db4b 100644 --- a/README.md +++ b/README.md @@ -397,6 +397,7 @@ d.create(data: { emailCC?: string[]; emailBCC?: string[]; xIdempotencyKey?: string; + forUserID?: string; }) ``` @@ -415,6 +416,7 @@ d.createBatch(data: { emailTo?: string[]; emailCC?: string[]; emailBCC?: string[]; + forUserID?: string; }>; xIdempotencyKey?: string; }) diff --git a/examples/with_async/disbursement.js b/examples/with_async/disbursement.js index fa0d818..4bc6ad9 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: 'qwie@#' }); // eslint-disable-next-line no-console console.log('disbursement created:', disb); diff --git a/package.json b/package.json index 952b112..330c2a7 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", diff --git a/src/disbursement/disburse.js b/src/disbursement/disburse.js index 9dfd1f8..5484f7a 100644 --- a/src/disbursement/disburse.js +++ b/src/disbursement/disburse.js @@ -19,6 +19,11 @@ function create(data) { data.xIdempotencyKey, ); + if (data && data.forUserID) { + headers['for-user-id'] = data.forUserID; + } + + fetchWithHTTPErr(`${this.API_ENDPOINT}/disbursements`, { method: 'POST', headers, @@ -55,6 +60,10 @@ function createBatch(data) { this.opts.secretKey, data.xIdempotencyKey, ); + + if (data && data.forUserID) { + headers['for-user-id'] = data.forUserID; + } fetchWithHTTPErr(`${this.API_ENDPOINT}/batch_disbursements`, { method: 'POST', From 8b0648d60a995f97bdd0eea3fc3db63fbf47d90c Mon Sep 17 00:00:00 2001 From: Hendry Zheng Date: Tue, 22 Feb 2022 16:50:13 +0700 Subject: [PATCH 2/4] remove deprecated ewallet test and add withFeeRule --- README.md | 2 + integration_test/ewallet.test.js | 68 +++++++++++++------------------- src/disbursement/disburse.js | 7 ++++ 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 549db4b..a752e3b 100644 --- a/README.md +++ b/README.md @@ -398,6 +398,7 @@ d.create(data: { emailBCC?: string[]; xIdempotencyKey?: string; forUserID?: string; + withFeeRule?: string; }) ``` @@ -417,6 +418,7 @@ d.createBatch(data: { emailCC?: string[]; emailBCC?: string[]; forUserID?: string; + withFeeRule?: string; }>; xIdempotencyKey?: string; }) diff --git a/integration_test/ewallet.test.js b/integration_test/ewallet.test.js index fd6b8f0..3a34335 100644 --- a/integration_test/ewallet.test.js +++ b/integration_test/ewallet.test.js @@ -15,50 +15,36 @@ const c = new Customer({}); * can only be carried out after the manual authorization */ -module.exports = function() { +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/src/disbursement/disburse.js b/src/disbursement/disburse.js index 5484f7a..ffc905e 100644 --- a/src/disbursement/disburse.js +++ b/src/disbursement/disburse.js @@ -23,6 +23,9 @@ function create(data) { headers['for-user-id'] = data.forUserID; } + if (data && data.withFeeRule) { + headers['with-fee-rule'] = data.withFeeRule; + } fetchWithHTTPErr(`${this.API_ENDPOINT}/disbursements`, { method: 'POST', @@ -65,6 +68,10 @@ function createBatch(data) { headers['for-user-id'] = data.forUserID; } + if (data && data.withFeeRule) { + headers['with-fee-rule'] = data.withFeeRule; + } + fetchWithHTTPErr(`${this.API_ENDPOINT}/batch_disbursements`, { method: 'POST', headers, From 5deb6f203f6095777a55523231654c66460f2a33 Mon Sep 17 00:00:00 2001 From: Hendry Zheng Date: Tue, 22 Feb 2022 16:56:24 +0700 Subject: [PATCH 3/4] update lint fix add linting fix in package.json --- integration_test/ewallet.test.js | 2 +- package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/integration_test/ewallet.test.js b/integration_test/ewallet.test.js index 3a34335..a6f11a8 100644 --- a/integration_test/ewallet.test.js +++ b/integration_test/ewallet.test.js @@ -15,7 +15,7 @@ const c = new Customer({}); * can only be carried out after the manual authorization */ -module.exports = function () { +module.exports = function() { return ew .createEWalletCharge({ referenceID: Date.now().toString(), diff --git a/package.json b/package.json index 330c2a7..0c74429 100644 --- a/package.json +++ b/package.json @@ -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", From f05add30efee016fbeeb24aec98de50aee7e5867 Mon Sep 17 00:00:00 2001 From: Hendry Zheng Date: Tue, 22 Feb 2022 16:59:57 +0700 Subject: [PATCH 4/4] update linter --- examples/with_async/disbursement.js | 2 +- src/disbursement/disburse.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/with_async/disbursement.js b/examples/with_async/disbursement.js index 4bc6ad9..84c9679 100644 --- a/examples/with_async/disbursement.js +++ b/examples/with_async/disbursement.js @@ -26,7 +26,7 @@ const d = new Disbursement({}); accountNumber: '1234567890', description: `purchase paid from ${banks[0].name}`, amount: 10000, - forUserID: 'qwie@#' + forUserID: 'for-user-id-test', }); // eslint-disable-next-line no-console console.log('disbursement created:', disb); diff --git a/src/disbursement/disburse.js b/src/disbursement/disburse.js index ffc905e..cb60a68 100644 --- a/src/disbursement/disburse.js +++ b/src/disbursement/disburse.js @@ -63,7 +63,6 @@ function createBatch(data) { this.opts.secretKey, data.xIdempotencyKey, ); - if (data && data.forUserID) { headers['for-user-id'] = data.forUserID; }