Skip to content

Commit

Permalink
Merge pull request #117 from xendit/feat/add-missing-recurring-paymen…
Browse files Browse the repository at this point in the history
…t-properties

#116 Add missing recurring payment properties
  • Loading branch information
bob-xendit authored Nov 2, 2021
2 parents d9daa75 + 98b8ce9 commit 59529ba
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 2021-11-01

- Add missing recurring payment properties

## 2021-06-01

- Add missing Customer and DirectDebit services types to index definition file
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,8 @@ Refer to [Xendit API Reference](https://developers.xendit.co/api-reference/#recu
```ts
rp.createPayment(data: {
externalID: string;
payerEmail: string;
description: string;
payerEmail?: string;
description?: string;
amount: number;
interval: Interval;
intervalCount: number;
Expand All @@ -530,6 +530,11 @@ rp.createPayment(data: {
chargeImmediately?: boolean;
currency?: string;
rescheduleAt?: Date;
customer?: object;
customerNotificationPreference?: object;
reminderTimeUnit?: string;
reminderTime?: number;
paymentMethodId?: string;
})
```

Expand All @@ -551,6 +556,11 @@ rp.editPayment(data: {
shouldSendEmail?: boolean;
invoiceDuration?: number;
missedPaymentAction?: Action;
rescheduleAt?: Date;
customerId?: string;
reminderTimeUnit?: string;
reminderTime?: number;
paymentMethodId?: string;
})
```

Expand Down
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.17.0",
"version": "1.18.0",
"description": "NodeJS client for Xendit API",
"main": "index.js",
"types": "index.d.ts",
Expand Down
13 changes: 11 additions & 2 deletions src/recurring/manage_payments.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ enum Action {

export function createPayment(data: {
externalID: string;
payerEmail: string;
description: string;
payerEmail?: string;
description?: string;
amount: number;
interval: Interval;
intervalCount: number;
Expand All @@ -27,6 +27,11 @@ export function createPayment(data: {
chargeImmediately?: boolean;
currency?: string;
rescheduleAt?: Date;
customer?: object;
customerNotificationPreference?: object;
reminderTimeUnit?: string;
reminderTime?: number;
paymentMethodId?: string;
}): Promise<object>;

export function getPayment(data: { id: string }): Promise<object>;
Expand All @@ -41,4 +46,8 @@ export function editPayment(data: {
invoiceDuration?: number;
missedPaymentAction?: Action;
rescheduleAt?: Date;
customerId?: string;
reminderTimeUnit?: string;
reminderTime?: number;
paymentMethodId?: string;
}): Promise<object>;
11 changes: 9 additions & 2 deletions src/recurring/manage_payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ function createPayment(data) {
return promWithJsErr((resolve, reject) => {
const compulsoryFields = [
'externalID',
'payerEmail',
'description',
'amount',
'interval',
'intervalCount',
Expand Down Expand Up @@ -39,6 +37,11 @@ function createPayment(data) {
reschedule_at: data.rescheduleAt
? data.rescheduleAt.toISOString()
: undefined,
customer: data.customer,
customer_notification_preference: data.customerNotificationPreference,
reminder_time_unit: data.reminderTimeUnit,
reminder_time: data.reminderTime,
payment_method_id: data.paymentMethodId,
}),
})
.then(resolve)
Expand Down Expand Up @@ -80,6 +83,10 @@ function editPayment(data) {
reschedule_at: data.rescheduleAt
? data.rescheduleAt.toISOString()
: undefined,
customer_id: data.customerId,
reminder_time_unit: data.reminderTimeUnit,
reminder_time: data.reminderTime,
payment_method_id: data.paymentMethodId,
}),
})
.then(resolve)
Expand Down
10 changes: 9 additions & 1 deletion test/recurring/constants.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
const EXT_ID = '123';
const PAYER_EMAIL = 'stanley@xendit.co';
const PAYER_EMAIL = 'dummy@email.co';
const DESCRIPTION = 'Payment for something';
const AMOUNT = 10000;
const INTERVAL = 'MONTH';
const INTERVAL_COUNT = 1;
const PAYMENT_ID = '5e0577bdf4d38b20d542009b';
const START_DATE = '2020-01-31T17:00:00.000Z';
const CUSTOMER = {
given_names: 'stan',
email: '[email protected]',
mobile_number: '',
address: '',
};

const PAYMENT_DETAILS = {
id: PAYMENT_ID,
Expand All @@ -16,6 +22,7 @@ const PAYMENT_DETAILS = {
interval: INTERVAL,
interval_count: INTERVAL_COUNT,
start_date: START_DATE,
customer: CUSTOMER,
};

const UPDATED_AMOUNT = 20000;
Expand All @@ -35,4 +42,5 @@ module.exports = {
START_DATE,
UPDATED_AMOUNT,
UPDATED_PAYMENT_DETAILS,
CUSTOMER,
};
2 changes: 2 additions & 0 deletions test/recurring/manage_payments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = function(x) {
interval: TestConstants.INTERVAL,
interval_count: TestConstants.INTERVAL_COUNT,
start_date: TestConstants.START_DATE,
customer: TestConstants.CUSTOMER,
})
.reply(201, TestConstants.PAYMENT_DETAILS);
nock(rp.API_ENDPOINT)
Expand All @@ -46,6 +47,7 @@ module.exports = function(x) {
interval: RecurringPayment.Interval.Month,
intervalCount: TestConstants.INTERVAL_COUNT,
startDate: new Date(TestConstants.PAYMENT_DETAILS.start_date),
customer: TestConstants.CUSTOMER,
}),
)
.to.eventually.deep.equal(TestConstants.PAYMENT_DETAILS)
Expand Down

0 comments on commit 59529ba

Please sign in to comment.