From c73b6fcf8abb0ad1ce5fc93e8df40f6500c62418 Mon Sep 17 00:00:00 2001 From: Dharnit <85389770+dharmasatrya@users.noreply.github.com> Date: Wed, 29 Dec 2021 11:09:34 +0700 Subject: [PATCH 1/8] invoice-paramsUpdate --- examples/with_async/invoice.js | 4 ++++ package-lock.json | 5 +++-- src/invoice/invoice.d.ts | 5 +++++ src/invoice/invoice.js | 4 ++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/with_async/invoice.js b/examples/with_async/invoice.js index 2ce1779..d86e5e7 100644 --- a/examples/with_async/invoice.js +++ b/examples/with_async/invoice.js @@ -17,6 +17,10 @@ const i = new Invoice({}); customerNotificationPreference: { invoice_created: ['email'], }, + reminderTimeUnit: 'days', + remiderTime: 12, + locale: "en", + shouldAuthenticateCreditCard: true }); console.log('created invoice', invoice); // eslint-disable-line no-console diff --git a/package-lock.json b/package-lock.json index c6ba547..46d03e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,12 @@ { "name": "xendit-node", - "version": "1.17.0", + "version": "1.19.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "1.15.0", + "name": "xendit-node", + "version": "1.19.1", "license": "MIT", "dependencies": { "node-fetch": "^2.6.1" diff --git a/src/invoice/invoice.d.ts b/src/invoice/invoice.d.ts index 28bb3ee..a82b1a7 100644 --- a/src/invoice/invoice.d.ts +++ b/src/invoice/invoice.d.ts @@ -23,6 +23,11 @@ export = class Invoice { currency?: string; midLabel?: string; forUserID?: string; + reminderTimeUnit?: string; + reminderTime?: number; + locale?: string; + shouldAuthenticateCreditCard?: boolean; + }): Promise; getInvoice(data: { invoiceID: string; forUserID?: string }): Promise; expireInvoice(data: { diff --git a/src/invoice/invoice.js b/src/invoice/invoice.js index e3cba9e..9b2af66 100644 --- a/src/invoice/invoice.js +++ b/src/invoice/invoice.js @@ -58,6 +58,10 @@ Invoice.prototype.createInvoice = function(data) { customer_notification_preference: data.customerNotificationPreference, items: data.items, fees: data.fees, + reminder_time_unit: data.reminderTimeUnit, + reminder_time: data.reminderTime, + locale: data.locale, + should_authenticate_credit_card: data.shouldAuthenticateCreditCard }), }) .then(resolve) From 66ae58a758b95d4a895d95b7573209d837ae6c8a Mon Sep 17 00:00:00 2001 From: Dharnit <85389770+dharmasatrya@users.noreply.github.com> Date: Wed, 29 Dec 2021 11:13:02 +0700 Subject: [PATCH 2/8] invoice-paramsUpdate --- examples/with_async/invoice.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/examples/with_async/invoice.js b/examples/with_async/invoice.js index d86e5e7..2ce1779 100644 --- a/examples/with_async/invoice.js +++ b/examples/with_async/invoice.js @@ -17,10 +17,6 @@ const i = new Invoice({}); customerNotificationPreference: { invoice_created: ['email'], }, - reminderTimeUnit: 'days', - remiderTime: 12, - locale: "en", - shouldAuthenticateCreditCard: true }); console.log('created invoice', invoice); // eslint-disable-line no-console From 18db33ba94e0a746c921747f5e18119c47a27b8d Mon Sep 17 00:00:00 2001 From: Dharnit <85389770+dharmasatrya@users.noreply.github.com> Date: Wed, 29 Dec 2021 11:40:22 +0700 Subject: [PATCH 3/8] add with fee rules header --- src/invoice/invoice.d.ts | 2 +- src/invoice/invoice.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/invoice/invoice.d.ts b/src/invoice/invoice.d.ts index a82b1a7..99bc5a5 100644 --- a/src/invoice/invoice.d.ts +++ b/src/invoice/invoice.d.ts @@ -27,7 +27,7 @@ export = class Invoice { reminderTime?: number; locale?: string; shouldAuthenticateCreditCard?: boolean; - + withFeeRule?: string; }): Promise; getInvoice(data: { invoiceID: string; forUserID?: string }): Promise; expireInvoice(data: { diff --git a/src/invoice/invoice.js b/src/invoice/invoice.js index 9b2af66..f7c1eb9 100644 --- a/src/invoice/invoice.js +++ b/src/invoice/invoice.js @@ -37,6 +37,10 @@ Invoice.prototype.createInvoice = function(data) { headers['for-user-id'] = data.forUserID; } + if (data && data.withFeeRule) { + headers['with-fee-rule'] = data.withFeeRule; + } + fetchWithHTTPErr(`${this.API_ENDPOINT}/v2/invoices`, { method: 'POST', headers, From bee9b4fa2485505e32d1a896626444b1762bf8d8 Mon Sep 17 00:00:00 2001 From: Dharnit <85389770+dharmasatrya@users.noreply.github.com> Date: Wed, 29 Dec 2021 12:16:47 +0700 Subject: [PATCH 4/8] linter fix --- examples/with_async/card.js | 2 +- src/invoice/invoice.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/with_async/card.js b/examples/with_async/card.js index 0e09e20..7616ef1 100644 --- a/examples/with_async/card.js +++ b/examples/with_async/card.js @@ -18,7 +18,7 @@ const authID = '5e0461a96113354249aab7ee'; externalID: Date.now().toString(), // use your system's ID of the transaction capture: false, metadata: { - test: "data", + test: `data`, }, }); console.log('charge created:', charge); // eslint-disable-line no-console diff --git a/src/invoice/invoice.js b/src/invoice/invoice.js index f7c1eb9..e9aee20 100644 --- a/src/invoice/invoice.js +++ b/src/invoice/invoice.js @@ -65,7 +65,7 @@ Invoice.prototype.createInvoice = function(data) { reminder_time_unit: data.reminderTimeUnit, reminder_time: data.reminderTime, locale: data.locale, - should_authenticate_credit_card: data.shouldAuthenticateCreditCard + should_authenticate_credit_card: data.shouldAuthenticateCreditCard, }), }) .then(resolve) From b59d9b01403a32096be23c6c746232f3fca751a1 Mon Sep 17 00:00:00 2001 From: Dharnit <85389770+dharmasatrya@users.noreply.github.com> Date: Thu, 30 Dec 2021 17:43:42 +0700 Subject: [PATCH 5/8] update versioning --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da976cc..d03b6de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xendit-node", - "version": "1.19.1", + "version": "1.19.2", "description": "NodeJS client for Xendit API", "main": "index.js", "types": "index.d.ts", From 9ede8b5054a88fa209c7ca2cb5f7209a868faf0d Mon Sep 17 00:00:00 2001 From: xen-HendryZheng <90175540+xen-HendryZheng@users.noreply.github.com> Date: Fri, 31 Dec 2021 15:16:17 +0700 Subject: [PATCH 6/8] Update va.test.js --- integration_test/va.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test/va.test.js b/integration_test/va.test.js index 4ff1181..37d5c96 100644 --- a/integration_test/va.test.js +++ b/integration_test/va.test.js @@ -15,7 +15,7 @@ module.exports = function() { expectedAmt: 10000, }); }) - .then(({ id }) => va.getFixedVA({ id })) + .then(({ id }) => va.getFixedVA({ id: id })) .then(({ id }) => { return va.updateFixedVA({ id, From c1317e0c669911d59305f51b1c03eec8810a58e6 Mon Sep 17 00:00:00 2001 From: Hendry Zheng Date: Fri, 31 Dec 2021 15:28:56 +0700 Subject: [PATCH 7/8] add sleep on the test --- integration_test/va.test.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/integration_test/va.test.js b/integration_test/va.test.js index 37d5c96..5f4713d 100644 --- a/integration_test/va.test.js +++ b/integration_test/va.test.js @@ -2,21 +2,28 @@ const x = require('./xendit.test'); const VirtualAcc = x.VirtualAcc; const va = new VirtualAcc({}); - -module.exports = function() { +function sleepFor(sleepDuration){ + var now = new Date().getTime(); + while(new Date().getTime() < now + sleepDuration){ /* Do nothing */ } +} +module.exports = function () { return va .getVABanks() .then(banks => { return va.createFixedVA({ - externalID: new Date().toLocaleString(), + externalID: 'VA-' + new Date().toLocaleString(), bankCode: banks[0].code, name: 'Stanley Nguyen', isClosed: true, expectedAmt: 10000, }); }) - .then(({ id }) => va.getFixedVA({ id: id })) .then(({ id }) => { + sleepFor(3000); + return va.getFixedVA({ id }) + }) + .then(({ id }) => { + console.log(id); return va.updateFixedVA({ id, suggestedAmt: 10000, From 013ca1c12196c8c4ad90ec879a793e437f4fbb1c Mon Sep 17 00:00:00 2001 From: Hendry Zheng Date: Fri, 31 Dec 2021 15:29:52 +0700 Subject: [PATCH 8/8] remove console log --- integration_test/va.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/integration_test/va.test.js b/integration_test/va.test.js index 5f4713d..c62cc13 100644 --- a/integration_test/va.test.js +++ b/integration_test/va.test.js @@ -23,7 +23,6 @@ module.exports = function () { return va.getFixedVA({ id }) }) .then(({ id }) => { - console.log(id); return va.updateFixedVA({ id, suggestedAmt: 10000,