Skip to content

Commit

Permalink
Merge pull request #126 from xendit/invoice-paramsUpdate
Browse files Browse the repository at this point in the history
invoice-paramsUpdate
  • Loading branch information
xen-HendryZheng authored Dec 31, 2021
2 parents b725385 + 013ca1c commit f191fb4
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/with_async/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions integration_test/va.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@ 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 }))
.then(({ id }) => {
sleepFor(3000);
return va.getFixedVA({ id })
})
.then(({ id }) => {
return va.updateFixedVA({
id,
Expand Down
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions src/invoice/invoice.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export = class Invoice {
currency?: string;
midLabel?: string;
forUserID?: string;
reminderTimeUnit?: string;
reminderTime?: number;
locale?: string;
shouldAuthenticateCreditCard?: boolean;
withFeeRule?: string;
}): Promise<object>;
getInvoice(data: { invoiceID: string; forUserID?: string }): Promise<object>;
expireInvoice(data: {
Expand Down
8 changes: 8 additions & 0 deletions src/invoice/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -58,6 +62,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)
Expand Down

0 comments on commit f191fb4

Please sign in to comment.