diff --git a/examples/va.js b/examples/va.js index 0f8c03b..0eef17c 100644 --- a/examples/va.js +++ b/examples/va.js @@ -9,14 +9,10 @@ va.getVABanks() return r; }) .then(banks => { - const expDate = new Date(); - expDate.setDate(expDate.getDate() + 7); - return va.createFixedVA({ externalID: '123', bankCode: banks[0].code, name: 'Stanley Nguyen', - expirationDate: expDate, }); }) .then(r => { @@ -29,14 +25,10 @@ va.getVABanks() return r; }) .then(({ id }) => { - const expDate = new Date(); - expDate.setMonth(expDate.getMonth() + 1); - return va.updateFixedVA({ id, suggestedAmt: 20, expectedAmt: 30, - expirationDate: expDate, }); }) .then(r => { diff --git a/src/va/account.js b/src/va/account.js index e6a0a64..b7cab2e 100644 --- a/src/va/account.js +++ b/src/va/account.js @@ -64,7 +64,7 @@ function updateFixedVA(data) { expected_amount: data.expectedAmt, expiration_date: data.expirationDate ? data.expirationDate.toISOString() - : null, + : undefined, is_single_use: data.isSingleUse, description: data.description, }), diff --git a/test/va/account.test.js b/test/va/account.test.js index 816242a..efadc54 100644 --- a/test/va/account.test.js +++ b/test/va/account.test.js @@ -27,9 +27,30 @@ module.exports = function(x) { nock(x.opts.xenditURL) .patch(`/callback_virtual_accounts/${TestConstants.VA_ID}`, { expected_amount: TestConstants.EXPECTED_AMT, - expiration_date: null, }) .reply(200, TestConstants.UPDATED_VA_DETAILS); + nock(x.opts.xenditURL) + .post('/callback_virtual_accounts', { + external_id: TestConstants.EXT_ID, + bank_code: TestConstants.BANK_CODE, + name: TestConstants.NAME, + expiration_date: null, + }) + .reply(400, { + status: 400, + code: 'API_VALIDATION_ERROR', + message: 'There was an error with the format submitted to the server.', + }); + nock(x.opts.xenditURL) + .patch(`/callback_virtual_accounts/${TestConstants.VA_ID}`, { + expected_amount: TestConstants.EXPECTED_AMT, + expiration_date: null, + }) + .reply(400, { + status: 400, + code: 'API_VALIDATION_ERROR', + message: 'There was an error with the format submitted to the server.', + }); }); describe('createFixedVA', () => {