From 0abfd726805c52ec4c75d18dd0e15ea85fa443f9 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 15:20:18 +0700 Subject: [PATCH 01/67] Add init e-wallet client --- src/ewallet/ewallet.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/ewallet/ewallet.js diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js new file mode 100644 index 0000000..949e346 --- /dev/null +++ b/src/ewallet/ewallet.js @@ -0,0 +1,19 @@ +const E_WALLET_PATH = ''; + +function EWallet(options) { + let aggOpts = options; + if (EWallet._injectedOpts && Object.keys(EWallet._injectedOpts).length > 0) { + aggOpts = Object.assign({}, options, EWallet._injectedOpts); + } + + this.opts = aggOpts; + this.API_ENDPOINT = this.opts.xenditURL + E_WALLET_PATH; +} + +EWallet._injectedOpts = {}; +EWallet._constructorWithInjectedXenditOpts = function(options) { + EWallet._injectedOpts = options; + return EWallet; +}; + +module.exports = EWallet; From 1fecdfced8385139e9fd03f7652474f60bf9f6e9 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 15:47:08 +0700 Subject: [PATCH 02/67] Add get ovo payment status by external id --- src/ewallet/ewallet.js | 4 ++-- src/ewallet/ovo.js | 53 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 src/ewallet/ovo.js diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index 949e346..02e9313 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -1,4 +1,4 @@ -const E_WALLET_PATH = ''; +const EWALLET_PATH = ''; function EWallet(options) { let aggOpts = options; @@ -7,7 +7,7 @@ function EWallet(options) { } this.opts = aggOpts; - this.API_ENDPOINT = this.opts.xenditURL + E_WALLET_PATH; + this.API_ENDPOINT = this.opts.xenditURL + EWALLET_PATH; } EWallet._injectedOpts = {}; diff --git a/src/ewallet/ovo.js b/src/ewallet/ovo.js new file mode 100644 index 0000000..d5c2ba6 --- /dev/null +++ b/src/ewallet/ovo.js @@ -0,0 +1,53 @@ +const { Validate, Auth, fetchWithHTTPErr, promWithJsErr } = require('../utils'); +const OVO_EWALLET_TYPE = 'OVO'; + +function createPayment(data) { + return promWithJsErr((resolve, reject) => { + Validate.rejectOnMissingFields( + ['externalID', 'amount', 'phone'], + data, + reject, + ); + + const headers = Auth.basicHeaderWithIdempotencyKey( + this.opts.secretKey, + data.xIdempotencyKey, + ); + + fetchWithHTTPErr(`${this.API_ENDPOINT}/ewallets`, { + method: 'POST', + headers, + body: JSON.stringify(_transformEWalletForRequestBody(data)), + }) + .then(resolve) + .catch(reject); + }); +} + +function _transformEWalletForRequestBody(ewalletPayment) { + return { + external_id: ewalletPayment.externalID, + amount: ewalletPayment.amount, + phone: ewalletPayment.phone, + ewallet_type: OVO_EWALLET_TYPE, + }; +} + +function getByExtID(data) { + return promWithJsErr((resolve, reject) => { + Validate.rejectOnMissingFields(['externalID'], data, reject); + fetchWithHTTPErr( + `${this.API_ENDPOINT}/ewallets/external_id=${data.external_id}&ewallet_type=${OVO_EWALLET_TYPE}`, + { + method: 'GET', + headers: { + Authorization: Auth.basicAuthHeader(this.opts.secretKey), + }, + }, + ) + .then(resolve) + .catch(reject); + }); +} + +module.exports = { createPayment, getByExtID }; From 873377bd83d70273b989a415419969727740dbc1 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 15:53:21 +0700 Subject: [PATCH 03/67] Export ovo payment function --- src/ewallet/ewallet.js | 7 ++++++- src/ewallet/ovo.js | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index 02e9313..3aaa657 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -1,4 +1,6 @@ -const EWALLET_PATH = ''; +const ovo = require('./ovo'); + +const EWALLET_PATH = 'ewallets'; function EWallet(options) { let aggOpts = options; @@ -16,4 +18,7 @@ EWallet._constructorWithInjectedXenditOpts = function(options) { return EWallet; }; +Disbursement.prototype.createOVOPayment = ovo.createPayment; +Disbursement.prototype.getOVOPaymentStatusByExtID = ovo.getByExtID; + module.exports = EWallet; diff --git a/src/ewallet/ovo.js b/src/ewallet/ovo.js index d5c2ba6..273ea32 100644 --- a/src/ewallet/ovo.js +++ b/src/ewallet/ovo.js @@ -14,7 +14,7 @@ function createPayment(data) { data.xIdempotencyKey, ); - fetchWithHTTPErr(`${this.API_ENDPOINT}/ewallets`, { + fetchWithHTTPErr(`${this.API_ENDPOINT}`, { method: 'POST', headers, body: JSON.stringify(_transformEWalletForRequestBody(data)), @@ -37,7 +37,7 @@ function getByExtID(data) { return promWithJsErr((resolve, reject) => { Validate.rejectOnMissingFields(['externalID'], data, reject); fetchWithHTTPErr( - `${this.API_ENDPOINT}/ewallets/external_id=${data.external_id}&ewallet_type=${OVO_EWALLET_TYPE}`, + `${this.API_ENDPOINT}/external_id=${data.external_id}&ewallet_type=${OVO_EWALLET_TYPE}`, { method: 'GET', headers: { From a7a03cd6af9fa114ad1b68a01bf2c81c02301f90 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 16:21:07 +0700 Subject: [PATCH 04/67] Add create dana payment function --- src/ewallet/dana.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/ewallet/dana.js diff --git a/src/ewallet/dana.js b/src/ewallet/dana.js new file mode 100644 index 0000000..20a7596 --- /dev/null +++ b/src/ewallet/dana.js @@ -0,0 +1,34 @@ +const { Validate, Auth, fetchWithHTTPErr, promWithJsErr } = require('../utils'); +const DANA_EWALLET_TYPE = 'DANA'; + +function createPayment(data) { + return promWithJsErr((resolve, reject) => { + Validate.rejectOnMissingFields( + ['externalID', 'amount', 'callbackURL', 'redirectURL'], + data, + reject, + ); + + const headers = Auth.basicHeaderWithIdempotencyKey( + this.opts.secretKey, + data.xIdempotencyKey, + ); + + fetchWithHTTPErr(`${this.API_ENDPOINT}`, { + method: 'POST', + headers, + body: JSON.stringify({ + external_id: data.externalID, + amount: data.amount, + expiration_date: data.expirationDate, + callback_url: data.callbackURL, + redirect_url: data.redirectURL, + ewallet_type: DANA_EWALLET_TYPE, + }), + }) + .then(resolve) + .catch(reject); + }); +} + +module.exports = { createPayment }; From 4dc4c3b3ab09145b704a22c05aab5f621120c4fd Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 16:23:05 +0700 Subject: [PATCH 05/67] Add get Dana Payment Status By External ID --- src/ewallet/dana.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/ewallet/dana.js b/src/ewallet/dana.js index 20a7596..424689b 100644 --- a/src/ewallet/dana.js +++ b/src/ewallet/dana.js @@ -31,4 +31,21 @@ function createPayment(data) { }); } -module.exports = { createPayment }; +function getByExtID(data) { + return promWithJsErr((resolve, reject) => { + Validate.rejectOnMissingFields(['externalID'], data, reject); + fetchWithHTTPErr( + `${this.API_ENDPOINT}/external_id=${data.external_id}&ewallet_type=${DANA_EWALLET_TYPE}`, + { + method: 'GET', + headers: { + Authorization: Auth.basicAuthHeader(this.opts.secretKey), + }, + }, + ) + .then(resolve) + .catch(reject); + }); +} + +module.exports = { createPayment, getByExtID }; From 8fe4ccbfd4fcad5ad8ff08de2dfe850d625a3f0c Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 16:26:25 +0700 Subject: [PATCH 06/67] Implemen dana payment --- src/ewallet/ewallet.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index 3aaa657..70e69cd 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -1,4 +1,5 @@ const ovo = require('./ovo'); +const dana = require('./dana'); const EWALLET_PATH = 'ewallets'; @@ -18,7 +19,9 @@ EWallet._constructorWithInjectedXenditOpts = function(options) { return EWallet; }; -Disbursement.prototype.createOVOPayment = ovo.createPayment; -Disbursement.prototype.getOVOPaymentStatusByExtID = ovo.getByExtID; +EWallet.prototype.createOVOPayment = ovo.createPayment; +EWallet.prototype.getOVOPaymentStatusByExtID = ovo.getByExtID; +EWallet.prototype.createDanaPayment = dana.createPayment; +EWallet.prototype.getDanaPaymentStatusByExtID = dana.getByExtID; module.exports = EWallet; From bf0128992f8e779641039c341fb3bcddf38dbe25 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 16:36:52 +0700 Subject: [PATCH 07/67] Add create link aja payment function --- src/ewallet/liinkaja.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/ewallet/liinkaja.js diff --git a/src/ewallet/liinkaja.js b/src/ewallet/liinkaja.js new file mode 100644 index 0000000..0a04265 --- /dev/null +++ b/src/ewallet/liinkaja.js @@ -0,0 +1,35 @@ +const { Validate, Auth, fetchWithHTTPErr, promWithJsErr } = require('../utils'); +const LINKAJA_EWALLET_TYPE = 'LINKAJA'; + +function createPayment(data) { + return promWithJsErr((resolve, reject) => { + Validate.rejectOnMissingFields( + ['externalID', 'phone', 'amount', 'items', 'callbackURL', 'redirectURL'], + data, + reject, + ); + + const headers = Auth.basicHeaderWithIdempotencyKey( + this.opts.secretKey, + data.xIdempotencyKey, + ); + + fetchWithHTTPErr(`${this.API_ENDPOINT}`, { + method: 'POST', + headers, + body: JSON.stringify({ + external_id: data.externalID, + phone: data.phone, + amount: data.amount, + items: data.items, + callback_url: data.callbackURL, + redirect_url: data.redirectURL, + ewallet_type: LINKAJA_EWALLET_TYPE, + }), + }) + .then(resolve) + .catch(reject); + }); +} + +module.exports = { createPayment }; From eb5e2f02984523689b49730ecb9aaa8be8faada8 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 16:39:07 +0700 Subject: [PATCH 08/67] Impement link aja payment --- src/ewallet/ewallet.js | 2 ++ src/ewallet/{liinkaja.js => linkaja.js} | 0 2 files changed, 2 insertions(+) rename src/ewallet/{liinkaja.js => linkaja.js} (100%) diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index 70e69cd..f79ff57 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -1,5 +1,6 @@ const ovo = require('./ovo'); const dana = require('./dana'); +const linkaja = require('./linkaja'); const EWALLET_PATH = 'ewallets'; @@ -23,5 +24,6 @@ EWallet.prototype.createOVOPayment = ovo.createPayment; EWallet.prototype.getOVOPaymentStatusByExtID = ovo.getByExtID; EWallet.prototype.createDanaPayment = dana.createPayment; EWallet.prototype.getDanaPaymentStatusByExtID = dana.getByExtID; +EWallet.prototype.createLinkAjaPayment = linkaja.createPayment; module.exports = EWallet; diff --git a/src/ewallet/liinkaja.js b/src/ewallet/linkaja.js similarity index 100% rename from src/ewallet/liinkaja.js rename to src/ewallet/linkaja.js From 52825b2e968f3ca777fae59f0d51181fe8a18b0e Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 16:40:02 +0700 Subject: [PATCH 09/67] Add ewallet service --- src/ewallet/index.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/ewallet/index.js diff --git a/src/ewallet/index.js b/src/ewallet/index.js new file mode 100644 index 0000000..6636228 --- /dev/null +++ b/src/ewallet/index.js @@ -0,0 +1,3 @@ +const EWalletService = require('./ewallet'); + +module.exports = { EWalletService }; From 20bc5edd8baf4cf871daef97e81c753e391d4ef6 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 16:41:26 +0700 Subject: [PATCH 10/67] Implement ewallet service --- src/xendit.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/xendit.js b/src/xendit.js index f8f1353..3fa0a4a 100644 --- a/src/xendit.js +++ b/src/xendit.js @@ -2,6 +2,7 @@ const { CardService } = require('./card'); const { VAService } = require('./va'); const { DisbursementService } = require('./disbursement'); const { InvoiceService } = require('./invoice'); +const { EWalletService } = require('./ewallet'); const Errors = require('./errors'); function Xendit(options) { @@ -21,6 +22,7 @@ function Xendit(options) { this.opts, ); this.Invoice = InvoiceService._constructorWithInjectedXenditOpts(this.opts); + this.EWallet = EWalletService._constructorWithInjectedXenditOpts(thi.opts); } Xendit.Errors = Errors; From 8310f682952dd075f3f030d4f5a9d7c4b1a44aec Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 16:51:00 +0700 Subject: [PATCH 11/67] Add e wallet to xendit ts --- src/xendit.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/xendit.d.ts b/src/xendit.d.ts index cfa7a9f..6eb0735 100644 --- a/src/xendit.d.ts +++ b/src/xendit.d.ts @@ -3,6 +3,7 @@ import { CardService } from './card'; import { VAService } from './va'; import { DisbursementService } from './disbursement'; import { InvoiceService } from './invoice'; +import { EWalletService } from './ewallet'; import { XenditOptions } from './xendit_opts'; export = class Xendit { @@ -12,4 +13,5 @@ export = class Xendit { VirtualAcc: typeof VAService; Disbursement: typeof DisbursementService; Invoice: typeof InvoiceService; + EWalletService: typeof EWalletService; }; From 9859f5c67e3164cb3cd2bad6d07c41763c642168 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 16:52:08 +0700 Subject: [PATCH 12/67] remove _transformEWalletForRequestBody --- src/ewallet/ovo.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/ewallet/ovo.js b/src/ewallet/ovo.js index 273ea32..2d5b0d7 100644 --- a/src/ewallet/ovo.js +++ b/src/ewallet/ovo.js @@ -17,22 +17,18 @@ function createPayment(data) { fetchWithHTTPErr(`${this.API_ENDPOINT}`, { method: 'POST', headers, - body: JSON.stringify(_transformEWalletForRequestBody(data)), + body: JSON.stringify({ + external_id: ewalletPayment.externalID, + amount: ewalletPayment.amount, + phone: ewalletPayment.phone, + ewallet_type: OVO_EWALLET_TYPE, + }), }) .then(resolve) .catch(reject); }); } -function _transformEWalletForRequestBody(ewalletPayment) { - return { - external_id: ewalletPayment.externalID, - amount: ewalletPayment.amount, - phone: ewalletPayment.phone, - ewallet_type: OVO_EWALLET_TYPE, - }; -} - function getByExtID(data) { return promWithJsErr((resolve, reject) => { Validate.rejectOnMissingFields(['externalID'], data, reject); From 4d31e39b50216197707f33426bfe5daabf996a4c Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 16:56:43 +0700 Subject: [PATCH 13/67] Fix bad data passing --- src/ewallet/ovo.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ewallet/ovo.js b/src/ewallet/ovo.js index 2d5b0d7..2f44cc9 100644 --- a/src/ewallet/ovo.js +++ b/src/ewallet/ovo.js @@ -18,9 +18,9 @@ function createPayment(data) { method: 'POST', headers, body: JSON.stringify({ - external_id: ewalletPayment.externalID, - amount: ewalletPayment.amount, - phone: ewalletPayment.phone, + external_id: data.externalID, + amount: data.amount, + phone: data.phone, ewallet_type: OVO_EWALLET_TYPE, }), }) From 13bf214161bf17332d20a433fcf0b522f4bbc956 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 17:00:01 +0700 Subject: [PATCH 14/67] Add OVO.d.ts --- src/ewallet/ovo.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/ewallet/ovo.d.ts diff --git a/src/ewallet/ovo.d.ts b/src/ewallet/ovo.d.ts new file mode 100644 index 0000000..7eb49d6 --- /dev/null +++ b/src/ewallet/ovo.d.ts @@ -0,0 +1,6 @@ +export function createPayment(data: { + externalID: string; + amount: number; + phone: string; +}): Promise; +export function getByExtID(data: { externalID: string }): Promise; From 5504f4b0539c6711e100dc7e368b83428ef034aa Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 17:04:35 +0700 Subject: [PATCH 15/67] Add dana.d.ts --- src/ewallet/dana.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/ewallet/dana.d.ts diff --git a/src/ewallet/dana.d.ts b/src/ewallet/dana.d.ts new file mode 100644 index 0000000..e04cc69 --- /dev/null +++ b/src/ewallet/dana.d.ts @@ -0,0 +1,9 @@ +export function createPayment(data: { + externalID: string; + amount: number; + expirationDate: string; + callbackURL: string; + redirectURL: string; +}): Promise; +export function getByExtID(data: { externalID: string }): Promise; + \ No newline at end of file From ba967243b6d01c7b7f7bef04e8d918a10ac0f7b5 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 17:10:06 +0700 Subject: [PATCH 16/67] Add linkaja.d.ts --- src/ewallet/linkaja.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/ewallet/linkaja.d.ts diff --git a/src/ewallet/linkaja.d.ts b/src/ewallet/linkaja.d.ts new file mode 100644 index 0000000..f9dc690 --- /dev/null +++ b/src/ewallet/linkaja.d.ts @@ -0,0 +1,16 @@ +interface paymentItem { + id: string; + name: string; + price: number; + quantity: number; +} + +export function createPayment(data: { + externalID: string; + phone: string; + amount: number; + items: paymentItem[]; + callbackURL: string; + redirectURL: string; +}): Promise; + \ No newline at end of file From 45837eda0b1b14d77bc85d77738ed903231bfa50 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 17:15:57 +0700 Subject: [PATCH 17/67] Add ewallet.d.ts --- src/ewallet/ewallet.d.ts | 16 ++++++++++++++++ src/ewallet/linkaja.d.ts | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/ewallet/ewallet.d.ts diff --git a/src/ewallet/ewallet.d.ts b/src/ewallet/ewallet.d.ts new file mode 100644 index 0000000..99a60dc --- /dev/null +++ b/src/ewallet/ewallet.d.ts @@ -0,0 +1,16 @@ +import ovo from './ovo'; +import dana from './dana'; +import linkaja from './linkaja'; +import { XenditOptions } from '../xendit_opts'; + +export = class EWallet { + constructor({}); + static _constructorWithInjectedXenditOpts: ( + opts: XenditOptions, + ) => typeof EWallet; + createOVOPayment = ovo.createPayment; + getOVOPaymentStatusByExtID = ovo.getByExtID; + createDanaPayment = dana.createPayment; + getDanaPaymentStatusByExtID = dana.getByExtID; + createLinkAjaPayment = linkaja.createPayment; +}; diff --git a/src/ewallet/linkaja.d.ts b/src/ewallet/linkaja.d.ts index f9dc690..8e0f446 100644 --- a/src/ewallet/linkaja.d.ts +++ b/src/ewallet/linkaja.d.ts @@ -13,4 +13,3 @@ export function createPayment(data: { callbackURL: string; redirectURL: string; }): Promise; - \ No newline at end of file From c01ec3b101e8a1953ac9ea52f89da5a113b8ae1a Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 20:36:57 +0700 Subject: [PATCH 18/67] [Fix] Bad parameter passing --- src/ewallet/ewallet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index f79ff57..e70f0f1 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -2,7 +2,7 @@ const ovo = require('./ovo'); const dana = require('./dana'); const linkaja = require('./linkaja'); -const EWALLET_PATH = 'ewallets'; +const EWALLET_PATH = '/ewallets'; function EWallet(options) { let aggOpts = options; From b7279cb2ffae015dc0c0957ca4ec339820629734 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 20:37:41 +0700 Subject: [PATCH 19/67] [Fix] Bad parameter passing --- src/xendit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xendit.js b/src/xendit.js index 3fa0a4a..3e963c5 100644 --- a/src/xendit.js +++ b/src/xendit.js @@ -22,7 +22,7 @@ function Xendit(options) { this.opts, ); this.Invoice = InvoiceService._constructorWithInjectedXenditOpts(this.opts); - this.EWallet = EWalletService._constructorWithInjectedXenditOpts(thi.opts); + this.EWallet = EWalletService._constructorWithInjectedXenditOpts(this.opts); } Xendit.Errors = Errors; From 26976909e2d69d7ddd927d27d13b20754a5703e4 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 20:41:38 +0700 Subject: [PATCH 20/67] [Fix] Remove unuser var --- test/ewallet/constants.js | 25 ++++++++++++++++++++++ test/ewallet/ewallet.test.js | 13 ++++++++++++ test/ewallet/ovo.test.js | 40 ++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 test/ewallet/constants.js create mode 100644 test/ewallet/ewallet.test.js create mode 100644 test/ewallet/ovo.test.js diff --git a/test/ewallet/constants.js b/test/ewallet/constants.js new file mode 100644 index 0000000..2d29d98 --- /dev/null +++ b/test/ewallet/constants.js @@ -0,0 +1,25 @@ +const OVO_EWALLET_TYPE = 'OVO'; +const DANA_EWALLET_TYPE = 'DANA'; +const LINKAJA_EWALLET_TYPE = 'LINKAJA'; + +const EXT_ID = '123'; +const PHONE = '081234567890'; +const AMOUNT = 10000; + +const VALID_CREATE_OVO_RESPONSE = { + transaction_date: String(new Date()), + amount: AMOUNT, + external_id: EXT_ID, + ewallet_type: OVO_EWALLET_TYPE, + business_id: '12121212', +}; + +module.exports = { + OVO_EWALLET_TYPE, + DANA_EWALLET_TYPE, + LINKAJA_EWALLET_TYPE, + EXT_ID, + PHONE, + AMOUNT, + VALID_CREATE_OVO_RESPONSE, +}; diff --git a/test/ewallet/ewallet.test.js b/test/ewallet/ewallet.test.js new file mode 100644 index 0000000..97cffd8 --- /dev/null +++ b/test/ewallet/ewallet.test.js @@ -0,0 +1,13 @@ +process.env.NODE_ENV = 'test'; + +const Xendit = require('../../src/xendit'); +const ovo = require('./ovo.test'); + +const x = new Xendit({ + publicKey: 'fake_public_key', + secretKey: 'fake_secret_key', +}); + +describe('EWallet Service', function() { + ovo(x); +}); diff --git a/test/ewallet/ovo.test.js b/test/ewallet/ovo.test.js new file mode 100644 index 0000000..7cff863 --- /dev/null +++ b/test/ewallet/ovo.test.js @@ -0,0 +1,40 @@ +const chai = require('chai'); +const chaiAsProm = require('chai-as-promised'); +const TestConstants = require('./constants'); +const { expect } = chai; +const nock = require('nock'); + +chai.use(chaiAsProm); + +module.exports = function(x) { + const { EWallet } = x; + let ewallet; + beforeEach(function() { + ewallet = new EWallet({}); + }); + before(function() { + nock(x.opts.xenditURL) + .post('/ewallets', { + external_id: TestConstants.EXT_ID, + phone: TestConstants.PHONE, + amount: TestConstants.AMOUNT, + ewallet_type: TestConstants.OVO_EWALLET_TYPE, + }) + .reply(200, TestConstants.VALID_CREATE_OVO_RESPONSE); + }); + + describe('createOVOPayment', () => { + it('should create an OVO Payment', done => { + expect( + ewallet.createOVOPayment({ + externalID: TestConstants.EXT_ID, + phone: TestConstants.PHONE, + amount: TestConstants.AMOUNT, + }), + ) + .to.eventually.deep.equal(TestConstants.VALID_CREATE_OVO_RESPONSE) + .then(() => done()) + .catch(e => done(e)); + }); + }); +}; From cbc2f7765327ad68bf41e3d8b1a575c70ce674b6 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 20:42:09 +0700 Subject: [PATCH 21/67] [Test] OVO Integration test --- integration_test/ewallet.test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 integration_test/ewallet.test.js diff --git a/integration_test/ewallet.test.js b/integration_test/ewallet.test.js new file mode 100644 index 0000000..82ea77c --- /dev/null +++ b/integration_test/ewallet.test.js @@ -0,0 +1,17 @@ +const x = require('./xendit.test'); + +const { EWallet } = x; +const e = new EWallet({}); + +module.exports = function() { + return e + .createOVOPayment({ + externalID: Date.now().toString(), + phone: '081234567890', + amount: 100000, + }) + .then(() => { + // eslint-disable-next-line no-console + console.log('Invoice integration test done...'); + }); +}; From c0a69f870422385e458407d491da09305cdfaf02 Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 22:08:29 +0700 Subject: [PATCH 22/67] [Fix] Bad parameter passing --- src/ewallet/ovo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ewallet/ovo.js b/src/ewallet/ovo.js index 2f44cc9..7991b19 100644 --- a/src/ewallet/ovo.js +++ b/src/ewallet/ovo.js @@ -33,7 +33,7 @@ function getByExtID(data) { return promWithJsErr((resolve, reject) => { Validate.rejectOnMissingFields(['externalID'], data, reject); fetchWithHTTPErr( - `${this.API_ENDPOINT}/external_id=${data.external_id}&ewallet_type=${OVO_EWALLET_TYPE}`, + `${this.API_ENDPOINT}/external_id=${data.externalID}&ewallet_type=${OVO_EWALLET_TYPE}`, { method: 'GET', headers: { From 601b6b5ec4d9ee7e15108b34aa5de7832fe8aa7e Mon Sep 17 00:00:00 2001 From: Ervan Date: Thu, 26 Dec 2019 22:09:01 +0700 Subject: [PATCH 23/67] [Test] Get OVO payment status --- test/ewallet/constants.js | 10 ++++++++++ test/ewallet/ovo.test.js | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/test/ewallet/constants.js b/test/ewallet/constants.js index 2d29d98..bfc674c 100644 --- a/test/ewallet/constants.js +++ b/test/ewallet/constants.js @@ -14,6 +14,15 @@ const VALID_CREATE_OVO_RESPONSE = { business_id: '12121212', }; +const VALID_GET_OVO_PAYMENT_STATUS = { + external_id: EXT_ID, + amount: AMOUNT, + transaction_date: String(new Date()), + business_id: '12121212', + ewallet_type: OVO_EWALLET_TYPE, + status: 'COMPLETED', +}; + module.exports = { OVO_EWALLET_TYPE, DANA_EWALLET_TYPE, @@ -22,4 +31,5 @@ module.exports = { PHONE, AMOUNT, VALID_CREATE_OVO_RESPONSE, + VALID_GET_OVO_PAYMENT_STATUS, }; diff --git a/test/ewallet/ovo.test.js b/test/ewallet/ovo.test.js index 7cff863..4a08a1c 100644 --- a/test/ewallet/ovo.test.js +++ b/test/ewallet/ovo.test.js @@ -3,6 +3,7 @@ const chaiAsProm = require('chai-as-promised'); const TestConstants = require('./constants'); const { expect } = chai; const nock = require('nock'); +const { Errors } = require('../../src/xendit'); chai.use(chaiAsProm); @@ -21,6 +22,11 @@ module.exports = function(x) { ewallet_type: TestConstants.OVO_EWALLET_TYPE, }) .reply(200, TestConstants.VALID_CREATE_OVO_RESPONSE); + nock(x.opts.xenditURL) + .get( + `/ewallets/external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.OVO_EWALLET_TYPE}`, + ) + .reply(200, TestConstants.VALID_GET_OVO_PAYMENT_STATUS); }); describe('createOVOPayment', () => { @@ -36,5 +42,40 @@ module.exports = function(x) { .then(() => done()) .catch(e => done(e)); }); + it('should report missing required fields', done => { + expect(ewallet.createOVOPayment({})) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); + }); + + describe('getOVOPaymentStatusByExtID', () => { + it('should get OVO Payment Status', done => { + expect( + ewallet.getOVOPaymentStatusByExtID({ + externalID: TestConstants.EXT_ID, + }), + ) + .to.eventually.deep.equal(TestConstants.VALID_GET_OVO_PAYMENT_STATUS) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing required fields', done => { + expect(ewallet.getOVOPaymentStatusByExtID({})) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); }); }; From bd97b4355c8a3badb51da9ef98319313185edb20 Mon Sep 17 00:00:00 2001 From: Ervan Date: Fri, 27 Dec 2019 16:57:10 +0700 Subject: [PATCH 24/67] [Fix] Wrong Url --- src/ewallet/ovo.js | 2 +- test/ewallet/ovo.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ewallet/ovo.js b/src/ewallet/ovo.js index 7991b19..3a06b92 100644 --- a/src/ewallet/ovo.js +++ b/src/ewallet/ovo.js @@ -33,7 +33,7 @@ function getByExtID(data) { return promWithJsErr((resolve, reject) => { Validate.rejectOnMissingFields(['externalID'], data, reject); fetchWithHTTPErr( - `${this.API_ENDPOINT}/external_id=${data.externalID}&ewallet_type=${OVO_EWALLET_TYPE}`, + `${this.API_ENDPOINT}?external_id=${data.externalID}&ewallet_type=${OVO_EWALLET_TYPE}`, { method: 'GET', headers: { diff --git a/test/ewallet/ovo.test.js b/test/ewallet/ovo.test.js index 4a08a1c..b53eb69 100644 --- a/test/ewallet/ovo.test.js +++ b/test/ewallet/ovo.test.js @@ -24,7 +24,7 @@ module.exports = function(x) { .reply(200, TestConstants.VALID_CREATE_OVO_RESPONSE); nock(x.opts.xenditURL) .get( - `/ewallets/external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.OVO_EWALLET_TYPE}`, + `/ewallets?external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.OVO_EWALLET_TYPE}`, ) .reply(200, TestConstants.VALID_GET_OVO_PAYMENT_STATUS); }); From e8be9ef91125102f3c2cf8744861b192b58812c2 Mon Sep 17 00:00:00 2001 From: Ervan Date: Fri, 27 Dec 2019 17:08:35 +0700 Subject: [PATCH 25/67] [Fix] bad logic --- examples/ewallet.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/ewallet.js diff --git a/examples/ewallet.js b/examples/ewallet.js new file mode 100644 index 0000000..978bf44 --- /dev/null +++ b/examples/ewallet.js @@ -0,0 +1,25 @@ +const x = require('./xendit'); + +const EWallet = x.EWallet; +const ew = new EWallet({}); + +ew.createOVOPayment({ + externalID: new Date(), + amount: 1, + phone: '087877971875', +}) + .then(r => { + console.log('create ovo payment detail:', r); // eslint-disable-line no-console + return r; + }) + .then(({ external_id }) => + ew.getOVOPaymentStatusByExtID({ externalID: external_id }), + ) + .then(r => { + console.log('ovo payment status detail:', r); // eslint-disable-line no-console + return r; + }) + .catch(e => { + console.error(e); // eslint-disable-line no-console + process.exit(1); + }); From 45f8866d4d02a59b60e446415e0789fb64332d36 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sat, 28 Dec 2019 15:14:25 +0700 Subject: [PATCH 26/67] Add dana example --- examples/ewallet.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/examples/ewallet.js b/examples/ewallet.js index 978bf44..cf3776a 100644 --- a/examples/ewallet.js +++ b/examples/ewallet.js @@ -6,17 +6,39 @@ const ew = new EWallet({}); ew.createOVOPayment({ externalID: new Date(), amount: 1, - phone: '087877971875', + phone: '081234567890', }) .then(r => { - console.log('create ovo payment detail:', r); // eslint-disable-line no-console + console.log('create OVO payment detail:', r); // eslint-disable-line no-console return r; }) .then(({ external_id }) => ew.getOVOPaymentStatusByExtID({ externalID: external_id }), ) .then(r => { - console.log('ovo payment status detail:', r); // eslint-disable-line no-console + console.log('OVO payment status detail:', r); // eslint-disable-line no-console + return r; + }) + .catch(e => { + console.error(e); // eslint-disable-line no-console + process.exit(1); + }); + +ew.createDanaPayment({ + externalID: new Date(), + amount: 1, + callbackURL: 'http://google.com', + redirectURL: 'http://google.com', +}) + .then(r => { + console.log('create dana payment detail:', r); // eslint-disable-line no-console + return r; + }) + .then(({ external_id }) => + ew.getDanaPaymentStatusByExtID({ externalID: external_id }), + ) + .then(r => { + console.log('Dana payment status detail:', r); // eslint-disable-line no-console return r; }) .catch(e => { From 440a53c4be7e64a9e902d9e05d67e6ccaa1a3390 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sat, 28 Dec 2019 15:15:01 +0700 Subject: [PATCH 27/67] Add linkAja example --- examples/ewallet.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/examples/ewallet.js b/examples/ewallet.js index cf3776a..da468a8 100644 --- a/examples/ewallet.js +++ b/examples/ewallet.js @@ -45,3 +45,33 @@ ew.createDanaPayment({ console.error(e); // eslint-disable-line no-console process.exit(1); }); + +ew.createLinkAjaPayment({ + externalID: new Date(), + phone: '081234567890', + amount: 30000, + items: [ + { + id: '123123', + name: 'Phone Case', + price: 100000, + quantity: 1, + }, + { + id: '345678', + name: 'Powerbank', + price: 200000, + quantity: 1, + }, + ], + callbackURL: 'https://yourwebsite.com/callback', + redirectURL: 'https://yourwebsite.com/callback', +}) + .then(r => { + console.log('create linkAja payment detail:', r); // eslint-disable-line no-console + return r; + }) + .catch(e => { + console.error(e); // eslint-disable-line no-console + process.exit(1); + }); From 00ce8d23b844a6e659aa4a74299fd968e93e07b1 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sat, 28 Dec 2019 15:19:42 +0700 Subject: [PATCH 28/67] [Fix] linter --- src/ewallet/dana.d.ts | 1 + src/ewallet/ovo.d.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/ewallet/dana.d.ts b/src/ewallet/dana.d.ts index e04cc69..7d12c46 100644 --- a/src/ewallet/dana.d.ts +++ b/src/ewallet/dana.d.ts @@ -5,5 +5,6 @@ export function createPayment(data: { callbackURL: string; redirectURL: string; }): Promise; + export function getByExtID(data: { externalID: string }): Promise; \ No newline at end of file diff --git a/src/ewallet/ovo.d.ts b/src/ewallet/ovo.d.ts index 7eb49d6..0459ef1 100644 --- a/src/ewallet/ovo.d.ts +++ b/src/ewallet/ovo.d.ts @@ -3,4 +3,5 @@ export function createPayment(data: { amount: number; phone: string; }): Promise; + export function getByExtID(data: { externalID: string }): Promise; From 9b5b0e5182a7fc888cd17e59c0d4dd75c4cc1163 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sat, 28 Dec 2019 15:35:52 +0700 Subject: [PATCH 29/67] [Fix] Remove unneeded function --- src/ewallet/dana.js | 9 +++------ src/ewallet/linkaja.js | 9 +++------ src/ewallet/ovo.js | 9 +++------ 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/ewallet/dana.js b/src/ewallet/dana.js index 424689b..9920dfb 100644 --- a/src/ewallet/dana.js +++ b/src/ewallet/dana.js @@ -9,14 +9,11 @@ function createPayment(data) { reject, ); - const headers = Auth.basicHeaderWithIdempotencyKey( - this.opts.secretKey, - data.xIdempotencyKey, - ); - fetchWithHTTPErr(`${this.API_ENDPOINT}`, { method: 'POST', - headers, + headers: { + Authorization: Auth.basicAuthHeader(this.opts.secretKey), + }, body: JSON.stringify({ external_id: data.externalID, amount: data.amount, diff --git a/src/ewallet/linkaja.js b/src/ewallet/linkaja.js index 0a04265..632238d 100644 --- a/src/ewallet/linkaja.js +++ b/src/ewallet/linkaja.js @@ -9,14 +9,11 @@ function createPayment(data) { reject, ); - const headers = Auth.basicHeaderWithIdempotencyKey( - this.opts.secretKey, - data.xIdempotencyKey, - ); - fetchWithHTTPErr(`${this.API_ENDPOINT}`, { method: 'POST', - headers, + headers: { + Authorization: Auth.basicAuthHeader(this.opts.secretKey), + }, body: JSON.stringify({ external_id: data.externalID, phone: data.phone, diff --git a/src/ewallet/ovo.js b/src/ewallet/ovo.js index 3a06b92..46ef4c4 100644 --- a/src/ewallet/ovo.js +++ b/src/ewallet/ovo.js @@ -9,14 +9,11 @@ function createPayment(data) { reject, ); - const headers = Auth.basicHeaderWithIdempotencyKey( - this.opts.secretKey, - data.xIdempotencyKey, - ); - fetchWithHTTPErr(`${this.API_ENDPOINT}`, { method: 'POST', - headers, + headers: { + Authorization: Auth.basicAuthHeader(this.opts.secretKey), + }, body: JSON.stringify({ external_id: data.externalID, amount: data.amount, From d615a8de7d9d4cd98370c8d194cff2659aa4f6bb Mon Sep 17 00:00:00 2001 From: Ervan Date: Sat, 28 Dec 2019 19:52:18 +0700 Subject: [PATCH 30/67] [Fix] Missing Header --- src/ewallet/dana.js | 1 + src/ewallet/linkaja.js | 1 + src/ewallet/ovo.js | 1 + 3 files changed, 3 insertions(+) diff --git a/src/ewallet/dana.js b/src/ewallet/dana.js index 9920dfb..89c7f6c 100644 --- a/src/ewallet/dana.js +++ b/src/ewallet/dana.js @@ -12,6 +12,7 @@ function createPayment(data) { fetchWithHTTPErr(`${this.API_ENDPOINT}`, { method: 'POST', headers: { + 'Content-Type': 'application/json', Authorization: Auth.basicAuthHeader(this.opts.secretKey), }, body: JSON.stringify({ diff --git a/src/ewallet/linkaja.js b/src/ewallet/linkaja.js index 632238d..3c0c9e7 100644 --- a/src/ewallet/linkaja.js +++ b/src/ewallet/linkaja.js @@ -12,6 +12,7 @@ function createPayment(data) { fetchWithHTTPErr(`${this.API_ENDPOINT}`, { method: 'POST', headers: { + 'Content-Type': 'application/json', Authorization: Auth.basicAuthHeader(this.opts.secretKey), }, body: JSON.stringify({ diff --git a/src/ewallet/ovo.js b/src/ewallet/ovo.js index 46ef4c4..7b80fcf 100644 --- a/src/ewallet/ovo.js +++ b/src/ewallet/ovo.js @@ -12,6 +12,7 @@ function createPayment(data) { fetchWithHTTPErr(`${this.API_ENDPOINT}`, { method: 'POST', headers: { + 'Content-Type': 'application/json', Authorization: Auth.basicAuthHeader(this.opts.secretKey), }, body: JSON.stringify({ From ff11173001d463c42d23f79daa042b9736f0e20e Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 11:52:57 +0700 Subject: [PATCH 31/67] [Update] Restruct OVO Payment --- examples/ewallet.js | 13 +++++++------ src/ewallet/ewallet.d.ts | 4 ++-- src/ewallet/ewallet.js | 10 ++++++---- src/ewallet/ovo.d.ts | 2 +- src/ewallet/ovo.js | 29 +++++++++++++++++++++++------ test/ewallet/ovo.test.js | 10 +++++----- 6 files changed, 44 insertions(+), 24 deletions(-) diff --git a/examples/ewallet.js b/examples/ewallet.js index da468a8..802cfcd 100644 --- a/examples/ewallet.js +++ b/examples/ewallet.js @@ -3,17 +3,18 @@ const x = require('./xendit'); const EWallet = x.EWallet; const ew = new EWallet({}); -ew.createOVOPayment({ - externalID: new Date(), - amount: 1, - phone: '081234567890', -}) +ew.ovo + .createPayment({ + externalID: new Date(), + amount: 1, + phone: '081234567890', + }) .then(r => { console.log('create OVO payment detail:', r); // eslint-disable-line no-console return r; }) .then(({ external_id }) => - ew.getOVOPaymentStatusByExtID({ externalID: external_id }), + ew.ovo.getPaymentStatusByExtID({ externalID: external_id }), ) .then(r => { console.log('OVO payment status detail:', r); // eslint-disable-line no-console diff --git a/src/ewallet/ewallet.d.ts b/src/ewallet/ewallet.d.ts index 99a60dc..804ff89 100644 --- a/src/ewallet/ewallet.d.ts +++ b/src/ewallet/ewallet.d.ts @@ -8,8 +8,8 @@ export = class EWallet { static _constructorWithInjectedXenditOpts: ( opts: XenditOptions, ) => typeof EWallet; - createOVOPayment = ovo.createPayment; - getOVOPaymentStatusByExtID = ovo.getByExtID; + + ovo: typeof ovo; createDanaPayment = dana.createPayment; getDanaPaymentStatusByExtID = dana.getByExtID; createLinkAjaPayment = linkaja.createPayment; diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index e70f0f1..c7515bc 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -1,4 +1,4 @@ -const ovo = require('./ovo'); +const OVO = require('./ovo'); const dana = require('./dana'); const linkaja = require('./linkaja'); @@ -11,7 +11,11 @@ function EWallet(options) { } this.opts = aggOpts; - this.API_ENDPOINT = this.opts.xenditURL + EWALLET_PATH; + this.opts.API_ENDPOINT = this.opts.xenditURL + EWALLET_PATH; + + let ovo = OVO._constructorWithInjectedXenditOpts(this.opts); + + this.ovo = new ovo({}); } EWallet._injectedOpts = {}; @@ -20,8 +24,6 @@ EWallet._constructorWithInjectedXenditOpts = function(options) { return EWallet; }; -EWallet.prototype.createOVOPayment = ovo.createPayment; -EWallet.prototype.getOVOPaymentStatusByExtID = ovo.getByExtID; EWallet.prototype.createDanaPayment = dana.createPayment; EWallet.prototype.getDanaPaymentStatusByExtID = dana.getByExtID; EWallet.prototype.createLinkAjaPayment = linkaja.createPayment; diff --git a/src/ewallet/ovo.d.ts b/src/ewallet/ovo.d.ts index 0459ef1..82e0e76 100644 --- a/src/ewallet/ovo.d.ts +++ b/src/ewallet/ovo.d.ts @@ -4,4 +4,4 @@ export function createPayment(data: { phone: string; }): Promise; -export function getByExtID(data: { externalID: string }): Promise; +export function getPaymentStatusByExtID(data: { externalID: string }): Promise; diff --git a/src/ewallet/ovo.js b/src/ewallet/ovo.js index 7b80fcf..de57c3e 100644 --- a/src/ewallet/ovo.js +++ b/src/ewallet/ovo.js @@ -1,7 +1,24 @@ const { Validate, Auth, fetchWithHTTPErr, promWithJsErr } = require('../utils'); const OVO_EWALLET_TYPE = 'OVO'; -function createPayment(data) { +function OVO(options) { + let aggOpts = options; + if (OVO._injectedOpts && Object.keys(OVO._injectedOpts).length > 0) { + aggOpts = Object.assign({}, options, OVO._injectedOpts); + } + + this.opts = aggOpts; + this.API_ENDPOINT = this.opts.API_ENDPOINT; + this.EWALLET_TYPE = 'OVO'; +} + +OVO._injectedOpts = {}; +OVO._constructorWithInjectedXenditOpts = function(options) { + OVO._injectedOpts = options; + return OVO; +}; + +OVO.prototype.createPayment = function(data) { return promWithJsErr((resolve, reject) => { Validate.rejectOnMissingFields( ['externalID', 'amount', 'phone'], @@ -19,15 +36,15 @@ function createPayment(data) { external_id: data.externalID, amount: data.amount, phone: data.phone, - ewallet_type: OVO_EWALLET_TYPE, + ewallet_type: this.EWALLET_TYPE, }), }) .then(resolve) .catch(reject); }); -} +}; -function getByExtID(data) { +OVO.prototype.getPaymentStatusByExtID = function(data) { return promWithJsErr((resolve, reject) => { Validate.rejectOnMissingFields(['externalID'], data, reject); fetchWithHTTPErr( @@ -42,6 +59,6 @@ function getByExtID(data) { .then(resolve) .catch(reject); }); -} +}; -module.exports = { createPayment, getByExtID }; +module.exports = OVO; diff --git a/test/ewallet/ovo.test.js b/test/ewallet/ovo.test.js index b53eb69..5249afa 100644 --- a/test/ewallet/ovo.test.js +++ b/test/ewallet/ovo.test.js @@ -29,10 +29,10 @@ module.exports = function(x) { .reply(200, TestConstants.VALID_GET_OVO_PAYMENT_STATUS); }); - describe('createOVOPayment', () => { + describe('createPayment', () => { it('should create an OVO Payment', done => { expect( - ewallet.createOVOPayment({ + ewallet.ovo.createPayment({ externalID: TestConstants.EXT_ID, phone: TestConstants.PHONE, amount: TestConstants.AMOUNT, @@ -43,7 +43,7 @@ module.exports = function(x) { .catch(e => done(e)); }); it('should report missing required fields', done => { - expect(ewallet.createOVOPayment({})) + expect(ewallet.ovo.createPayment({})) .to.eventually.to.be.rejected.then(e => Promise.all([ expect(e).to.have.property('status', 400), @@ -58,7 +58,7 @@ module.exports = function(x) { describe('getOVOPaymentStatusByExtID', () => { it('should get OVO Payment Status', done => { expect( - ewallet.getOVOPaymentStatusByExtID({ + ewallet.ovo.getPaymentStatusByExtID({ externalID: TestConstants.EXT_ID, }), ) @@ -67,7 +67,7 @@ module.exports = function(x) { .catch(e => done(e)); }); it('should report missing required fields', done => { - expect(ewallet.getOVOPaymentStatusByExtID({})) + expect(ewallet.ovo.getPaymentStatusByExtID({})) .to.eventually.to.be.rejected.then(e => Promise.all([ expect(e).to.have.property('status', 400), From 77e8c339735eed4a3d9530563a7052b7cb7fd43a Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 12:58:07 +0700 Subject: [PATCH 32/67] [Update] Restruct Ewallet --- examples/ewallet.js | 60 ++++++++++++++++++----------------- src/ewallet/dana.d.ts | 23 +++++++++----- src/ewallet/dana.js | 34 +++++++++++++++----- src/ewallet/ewallet.js | 16 +++++----- src/ewallet/ewallet_opts.d.ts | 7 ++++ src/ewallet/linkaja.d.ts | 25 ++++++++++----- src/ewallet/linkaja.js | 28 +++++++++++++--- src/ewallet/ovo.d.ts | 19 +++++++---- src/ewallet/ovo.js | 9 +++--- 9 files changed, 145 insertions(+), 76 deletions(-) create mode 100644 src/ewallet/ewallet_opts.d.ts diff --git a/examples/ewallet.js b/examples/ewallet.js index 802cfcd..e5db031 100644 --- a/examples/ewallet.js +++ b/examples/ewallet.js @@ -7,7 +7,7 @@ ew.ovo .createPayment({ externalID: new Date(), amount: 1, - phone: '081234567890', + phone: '087877971875', }) .then(r => { console.log('create OVO payment detail:', r); // eslint-disable-line no-console @@ -25,18 +25,19 @@ ew.ovo process.exit(1); }); -ew.createDanaPayment({ - externalID: new Date(), - amount: 1, - callbackURL: 'http://google.com', - redirectURL: 'http://google.com', -}) +ew.dana + .createPayment({ + externalID: new Date(), + amount: 1, + callbackURL: 'http://google.com', + redirectURL: 'http://google.com', + }) .then(r => { console.log('create dana payment detail:', r); // eslint-disable-line no-console return r; }) .then(({ external_id }) => - ew.getDanaPaymentStatusByExtID({ externalID: external_id }), + ew.dana.getPaymentStatusByExtID({ externalID: external_id }), ) .then(r => { console.log('Dana payment status detail:', r); // eslint-disable-line no-console @@ -47,27 +48,28 @@ ew.createDanaPayment({ process.exit(1); }); -ew.createLinkAjaPayment({ - externalID: new Date(), - phone: '081234567890', - amount: 30000, - items: [ - { - id: '123123', - name: 'Phone Case', - price: 100000, - quantity: 1, - }, - { - id: '345678', - name: 'Powerbank', - price: 200000, - quantity: 1, - }, - ], - callbackURL: 'https://yourwebsite.com/callback', - redirectURL: 'https://yourwebsite.com/callback', -}) +ew.linkaja + .createPayment({ + externalID: new Date(), + phone: '081234567890', + amount: 30000, + items: [ + { + id: '123123', + name: 'Phone Case', + price: 100000, + quantity: 1, + }, + { + id: '345678', + name: 'Powerbank', + price: 200000, + quantity: 1, + }, + ], + callbackURL: 'https://yourwebsite.com/callback', + redirectURL: 'https://yourwebsite.com/callback', + }) .then(r => { console.log('create linkAja payment detail:', r); // eslint-disable-line no-console return r; diff --git a/src/ewallet/dana.d.ts b/src/ewallet/dana.d.ts index 7d12c46..0f9d0ca 100644 --- a/src/ewallet/dana.d.ts +++ b/src/ewallet/dana.d.ts @@ -1,10 +1,17 @@ -export function createPayment(data: { - externalID: string; - amount: number; - expirationDate: string; - callbackURL: string; - redirectURL: string; -}): Promise; +import { EWalletOptions } from './ewallet_opts'; -export function getByExtID(data: { externalID: string }): Promise; +export = class OVO { + constructor({}); + static _constructorWithInjectedEWalletOpts: ( + opts: EWalletOptions, + ) => typeof OVO; + createPayment(data: { + externalID: string; + amount: number; + expirationDate: string; + callbackURL: string; + redirectURL: string; + }): Promise; + getPaymentStatusByExtID(data: { externalID: string }): Promise; +}; \ No newline at end of file diff --git a/src/ewallet/dana.js b/src/ewallet/dana.js index 89c7f6c..3a1610c 100644 --- a/src/ewallet/dana.js +++ b/src/ewallet/dana.js @@ -1,7 +1,25 @@ const { Validate, Auth, fetchWithHTTPErr, promWithJsErr } = require('../utils'); -const DANA_EWALLET_TYPE = 'DANA'; -function createPayment(data) { +const DANA_EWALLET_PATH = ''; + +function Dana(options) { + let aggOpts = options; + if (Dana._injectedOpts && Object.keys(Dana._injectedOpts).length > 0) { + aggOpts = Object.assign({}, options, Dana._injectedOpts); + } + + this.opts = aggOpts; + this.API_ENDPOINT = this.opts.eWalletURL + DANA_EWALLET_PATH; + this.EWALLET_TYPE = 'DANA'; +} + +Dana._injectedOpts = {}; +Dana._constructorWithInjectedEWalletOpts = function(options) { + Dana._injectedOpts = options; + return Dana; +}; + +Dana.prototype.createPayment = function(data) { return promWithJsErr((resolve, reject) => { Validate.rejectOnMissingFields( ['externalID', 'amount', 'callbackURL', 'redirectURL'], @@ -21,19 +39,19 @@ function createPayment(data) { expiration_date: data.expirationDate, callback_url: data.callbackURL, redirect_url: data.redirectURL, - ewallet_type: DANA_EWALLET_TYPE, + ewallet_type: this.EWALLET_TYPE, }), }) .then(resolve) .catch(reject); }); -} +}; -function getByExtID(data) { +Dana.prototype.getPaymentStatusByExtID = function(data) { return promWithJsErr((resolve, reject) => { Validate.rejectOnMissingFields(['externalID'], data, reject); fetchWithHTTPErr( - `${this.API_ENDPOINT}/external_id=${data.external_id}&ewallet_type=${DANA_EWALLET_TYPE}`, + `${this.API_ENDPOINT}?external_id=${data.externalID}&ewallet_type=${this.EWALLET_TYPE}`, { method: 'GET', headers: { @@ -44,6 +62,6 @@ function getByExtID(data) { .then(resolve) .catch(reject); }); -} +}; -module.exports = { createPayment, getByExtID }; +module.exports = Dana; diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index c7515bc..91f19a0 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -1,6 +1,6 @@ const OVO = require('./ovo'); -const dana = require('./dana'); -const linkaja = require('./linkaja'); +const Dana = require('./dana'); +const LinkAja = require('./linkaja'); const EWALLET_PATH = '/ewallets'; @@ -11,11 +11,15 @@ function EWallet(options) { } this.opts = aggOpts; - this.opts.API_ENDPOINT = this.opts.xenditURL + EWALLET_PATH; + this.opts.eWalletURL = this.opts.xenditURL + EWALLET_PATH; - let ovo = OVO._constructorWithInjectedXenditOpts(this.opts); + let ovo = OVO._constructorWithInjectedEWalletOpts(this.opts); + let dana = Dana._constructorWithInjectedEWalletOpts(this.opts); + let linkaja = LinkAja._constructorWithInjectedEWalletOpts(this.opts); this.ovo = new ovo({}); + this.dana = new dana({}); + this.linkaja = new linkaja({}); } EWallet._injectedOpts = {}; @@ -24,8 +28,4 @@ EWallet._constructorWithInjectedXenditOpts = function(options) { return EWallet; }; -EWallet.prototype.createDanaPayment = dana.createPayment; -EWallet.prototype.getDanaPaymentStatusByExtID = dana.getByExtID; -EWallet.prototype.createLinkAjaPayment = linkaja.createPayment; - module.exports = EWallet; diff --git a/src/ewallet/ewallet_opts.d.ts b/src/ewallet/ewallet_opts.d.ts new file mode 100644 index 0000000..afcc977 --- /dev/null +++ b/src/ewallet/ewallet_opts.d.ts @@ -0,0 +1,7 @@ +export interface XenditOptions { + publicKey?: string; + secretKey: string; + xenditURL?: string; + eWalletURL: string; +} + \ No newline at end of file diff --git a/src/ewallet/linkaja.d.ts b/src/ewallet/linkaja.d.ts index 8e0f446..6cb32a1 100644 --- a/src/ewallet/linkaja.d.ts +++ b/src/ewallet/linkaja.d.ts @@ -1,3 +1,5 @@ +import { EWalletOptions } from './ewallet_opts'; + interface paymentItem { id: string; name: string; @@ -5,11 +7,18 @@ interface paymentItem { quantity: number; } -export function createPayment(data: { - externalID: string; - phone: string; - amount: number; - items: paymentItem[]; - callbackURL: string; - redirectURL: string; -}): Promise; + +export = class LinkAja { + constructor({}); + static _constructorWithInjectedEWalletOpts: ( + opts: EWalletOptions, + ) => typeof LinkAja; + createPayment(data: { + externalID: string; + phone: string; + amount: number; + items: paymentItem[]; + callbackURL: string; + redirectURL: string; + }): Promise; +}; diff --git a/src/ewallet/linkaja.js b/src/ewallet/linkaja.js index 3c0c9e7..10e4577 100644 --- a/src/ewallet/linkaja.js +++ b/src/ewallet/linkaja.js @@ -1,7 +1,25 @@ const { Validate, Auth, fetchWithHTTPErr, promWithJsErr } = require('../utils'); -const LINKAJA_EWALLET_TYPE = 'LINKAJA'; -function createPayment(data) { +const LINKAJA_EWALLET_PATH = ''; + +function LinkAja(options) { + let aggOpts = options; + if (LinkAja._injectedOpts && Object.keys(LinkAja._injectedOpts).length > 0) { + aggOpts = Object.assign({}, options, LinkAja._injectedOpts); + } + + this.opts = aggOpts; + this.API_ENDPOINT = this.opts.eWalletURL + LINKAJA_EWALLET_PATH; + this.EWALLET_TYPE = 'LINKAJA'; +} + +LinkAja._injectedOpts = {}; +LinkAja._constructorWithInjectedEWalletOpts = function(options) { + LinkAja._injectedOpts = options; + return LinkAja; +}; + +LinkAja.prototype.createPayment = function(data) { return promWithJsErr((resolve, reject) => { Validate.rejectOnMissingFields( ['externalID', 'phone', 'amount', 'items', 'callbackURL', 'redirectURL'], @@ -22,12 +40,12 @@ function createPayment(data) { items: data.items, callback_url: data.callbackURL, redirect_url: data.redirectURL, - ewallet_type: LINKAJA_EWALLET_TYPE, + ewallet_type: this.EWALLET_TYPE, }), }) .then(resolve) .catch(reject); }); -} +}; -module.exports = { createPayment }; +module.exports = LinkAja; diff --git a/src/ewallet/ovo.d.ts b/src/ewallet/ovo.d.ts index 82e0e76..3b0d526 100644 --- a/src/ewallet/ovo.d.ts +++ b/src/ewallet/ovo.d.ts @@ -1,7 +1,14 @@ -export function createPayment(data: { - externalID: string; - amount: number; - phone: string; -}): Promise; +import { EWalletOptions } from './ewallet_opts'; -export function getPaymentStatusByExtID(data: { externalID: string }): Promise; +export = class OVO { + constructor({}); + static _constructorWithInjectedEWalletOpts: ( + opts: EWalletOptions, + ) => typeof OVO; + createPayment(data: { + externalID: string; + amount: number; + phone: string; + }): Promise; + getPaymentStatusByExtID(data: { externalID: string }): Promise; +}; diff --git a/src/ewallet/ovo.js b/src/ewallet/ovo.js index de57c3e..63ee117 100644 --- a/src/ewallet/ovo.js +++ b/src/ewallet/ovo.js @@ -1,5 +1,6 @@ const { Validate, Auth, fetchWithHTTPErr, promWithJsErr } = require('../utils'); -const OVO_EWALLET_TYPE = 'OVO'; + +const OVO_EWALLET_PATH = ''; function OVO(options) { let aggOpts = options; @@ -8,12 +9,12 @@ function OVO(options) { } this.opts = aggOpts; - this.API_ENDPOINT = this.opts.API_ENDPOINT; + this.API_ENDPOINT = this.opts.eWalletURL + OVO_EWALLET_PATH; this.EWALLET_TYPE = 'OVO'; } OVO._injectedOpts = {}; -OVO._constructorWithInjectedXenditOpts = function(options) { +OVO._constructorWithInjectedEWalletOpts = function(options) { OVO._injectedOpts = options; return OVO; }; @@ -48,7 +49,7 @@ OVO.prototype.getPaymentStatusByExtID = function(data) { return promWithJsErr((resolve, reject) => { Validate.rejectOnMissingFields(['externalID'], data, reject); fetchWithHTTPErr( - `${this.API_ENDPOINT}?external_id=${data.externalID}&ewallet_type=${OVO_EWALLET_TYPE}`, + `${this.API_ENDPOINT}?external_id=${data.externalID}&ewallet_type=${this.EWALLET_TYPE}`, { method: 'GET', headers: { From 2d92a7a381479aa1c7ebb62125c32a591a4fb641 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 13:18:26 +0700 Subject: [PATCH 33/67] [Update] Rename variable --- test/ewallet/constants.js | 4 +-- test/ewallet/linkaja.test.js | 57 ++++++++++++++++++++++++++++++++++++ test/ewallet/ovo.test.js | 6 ++-- 3 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 test/ewallet/linkaja.test.js diff --git a/test/ewallet/constants.js b/test/ewallet/constants.js index bfc674c..cc09798 100644 --- a/test/ewallet/constants.js +++ b/test/ewallet/constants.js @@ -14,7 +14,7 @@ const VALID_CREATE_OVO_RESPONSE = { business_id: '12121212', }; -const VALID_GET_OVO_PAYMENT_STATUS = { +const VALID_GET_OVO_PAYMENT_STATUS_RESPONSE = { external_id: EXT_ID, amount: AMOUNT, transaction_date: String(new Date()), @@ -31,5 +31,5 @@ module.exports = { PHONE, AMOUNT, VALID_CREATE_OVO_RESPONSE, - VALID_GET_OVO_PAYMENT_STATUS, + VALID_GET_OVO_PAYMENT_STATUS_RESPONSE, }; diff --git a/test/ewallet/linkaja.test.js b/test/ewallet/linkaja.test.js new file mode 100644 index 0000000..25cfba7 --- /dev/null +++ b/test/ewallet/linkaja.test.js @@ -0,0 +1,57 @@ +const chai = require('chai'); +const chaiAsProm = require('chai-as-promised'); +const TestConstants = require('./constants'); +const { expect } = chai; +const nock = require('nock'); +const { Errors } = require('../../src/xendit'); + +chai.use(chaiAsProm); + +module.exports = function(x) { + const { EWallet } = x; + let ewallet; + beforeEach(function() { + ewallet = new EWallet({}); + }); + before(function() { + nock(x.opts.xenditURL) + .post('/ewallets', { + external_id: TestConstants.EXT_ID, + phone: TestConstants.PHONE, + amount: TestConstants.AMOUNT, + ewallet_type: TestConstants.LINKAJA_EWALLET_TYPE, + }) + .reply(200, TestConstants.VALID_CREATE_OVO_RESPONSE); + nock(x.opts.xenditURL) + .get( + `/ewallets?external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.LINKAJA_EWALLET_TYPE}`, + ) + .reply(200, TestConstants.VALID_GET_OVO_PAYMENT_STATUS); + }); + + describe('createPayment', () => { + it('should create an OVO Payment', done => { + expect( + ewallet.ovo.createPayment({ + externalID: TestConstants.EXT_ID, + phone: TestConstants.PHONE, + amount: TestConstants.AMOUNT, + }), + ) + .to.eventually.deep.equal(TestConstants.VALID_CREATE_OVO_RESPONSE) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing required fields', done => { + expect(ewallet.ovo.createPayment({})) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); + }); +}; diff --git a/test/ewallet/ovo.test.js b/test/ewallet/ovo.test.js index 5249afa..bf7ca11 100644 --- a/test/ewallet/ovo.test.js +++ b/test/ewallet/ovo.test.js @@ -26,7 +26,7 @@ module.exports = function(x) { .get( `/ewallets?external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.OVO_EWALLET_TYPE}`, ) - .reply(200, TestConstants.VALID_GET_OVO_PAYMENT_STATUS); + .reply(200, TestConstants.VALID_GET_OVO_PAYMENT_STATUS_RESPONSE); }); describe('createPayment', () => { @@ -62,7 +62,9 @@ module.exports = function(x) { externalID: TestConstants.EXT_ID, }), ) - .to.eventually.deep.equal(TestConstants.VALID_GET_OVO_PAYMENT_STATUS) + .to.eventually.deep.equal( + TestConstants.VALID_GET_OVO_PAYMENT_STATUS_RESPONSE, + ) .then(() => done()) .catch(e => done(e)); }); From 599f2f6c7385955a00ccbc31772668f5c6b40947 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 13:30:20 +0700 Subject: [PATCH 34/67] Add Link Aja test --- test/ewallet/constants.js | 29 +++++++++++++++++++++++++++++ test/ewallet/ewallet.test.js | 2 ++ test/ewallet/linkaja.test.js | 21 +++++++++++---------- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/test/ewallet/constants.js b/test/ewallet/constants.js index cc09798..851e8db 100644 --- a/test/ewallet/constants.js +++ b/test/ewallet/constants.js @@ -5,6 +5,22 @@ const LINKAJA_EWALLET_TYPE = 'LINKAJA'; const EXT_ID = '123'; const PHONE = '081234567890'; const AMOUNT = 10000; +const CALLBACK_URL = 'https://yourwebsite.com/callback'; +const REDIRECT_URL = 'https://yourwebsite.com/order/123'; +const ITEMS = [ + { + id: '123123', + name: 'Phone Case', + price: 100000, + quantity: 1, + }, + { + id: '345678', + name: 'Powerbank', + price: 200000, + quantity: 1, + }, +]; const VALID_CREATE_OVO_RESPONSE = { transaction_date: String(new Date()), @@ -23,6 +39,15 @@ const VALID_GET_OVO_PAYMENT_STATUS_RESPONSE = { status: 'COMPLETED', }; +const VALID_CREATE_LINKAJA_RESPONSE = { + checkout_url: + 'https://ewallet-linkaja.xendit.co/checkouts/75d64796-c9e7-46e9-8c96-3edeacf3817b', + transaction_date: String(new Date()), + amount: 30000, + external_id: EXT_ID, + ewallet_type: LINKAJA_EWALLET_TYPE, +}; + module.exports = { OVO_EWALLET_TYPE, DANA_EWALLET_TYPE, @@ -30,6 +55,10 @@ module.exports = { EXT_ID, PHONE, AMOUNT, + CALLBACK_URL, + REDIRECT_URL, + ITEMS, VALID_CREATE_OVO_RESPONSE, VALID_GET_OVO_PAYMENT_STATUS_RESPONSE, + VALID_CREATE_LINKAJA_RESPONSE, }; diff --git a/test/ewallet/ewallet.test.js b/test/ewallet/ewallet.test.js index 97cffd8..8c20951 100644 --- a/test/ewallet/ewallet.test.js +++ b/test/ewallet/ewallet.test.js @@ -2,6 +2,7 @@ process.env.NODE_ENV = 'test'; const Xendit = require('../../src/xendit'); const ovo = require('./ovo.test'); +const linkaja = require('./linkaja.test'); const x = new Xendit({ publicKey: 'fake_public_key', @@ -10,4 +11,5 @@ const x = new Xendit({ describe('EWallet Service', function() { ovo(x); + linkaja(x); }); diff --git a/test/ewallet/linkaja.test.js b/test/ewallet/linkaja.test.js index 25cfba7..a314661 100644 --- a/test/ewallet/linkaja.test.js +++ b/test/ewallet/linkaja.test.js @@ -19,31 +19,32 @@ module.exports = function(x) { external_id: TestConstants.EXT_ID, phone: TestConstants.PHONE, amount: TestConstants.AMOUNT, + items: TestConstants.ITEMS, + callback_url: TestConstants.CALLBACK_URL, + redirect_url: TestConstants.REDIRECT_URL, ewallet_type: TestConstants.LINKAJA_EWALLET_TYPE, }) - .reply(200, TestConstants.VALID_CREATE_OVO_RESPONSE); - nock(x.opts.xenditURL) - .get( - `/ewallets?external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.LINKAJA_EWALLET_TYPE}`, - ) - .reply(200, TestConstants.VALID_GET_OVO_PAYMENT_STATUS); + .reply(200, TestConstants.VALID_CREATE_LINKAJA_RESPONSE); }); describe('createPayment', () => { - it('should create an OVO Payment', done => { + it('should create an linkAja Payment', done => { expect( - ewallet.ovo.createPayment({ + ewallet.linkaja.createPayment({ externalID: TestConstants.EXT_ID, phone: TestConstants.PHONE, amount: TestConstants.AMOUNT, + items: TestConstants.ITEMS, + callbackURL: TestConstants.CALLBACK_URL, + redirectURL: TestConstants.REDIRECT_URL, }), ) - .to.eventually.deep.equal(TestConstants.VALID_CREATE_OVO_RESPONSE) + .to.eventually.deep.equal(TestConstants.VALID_CREATE_LINKAJA_RESPONSE) .then(() => done()) .catch(e => done(e)); }); it('should report missing required fields', done => { - expect(ewallet.ovo.createPayment({})) + expect(ewallet.linkaja.createPayment({})) .to.eventually.to.be.rejected.then(e => Promise.all([ expect(e).to.have.property('status', 400), From c2bacf11e2ce303ee01585a239986b86c3bdf06b Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 13:42:33 +0700 Subject: [PATCH 35/67] [Update] Add dana test --- test/ewallet/constants.js | 18 ++++++++ test/ewallet/dana.test.js | 85 ++++++++++++++++++++++++++++++++++++ test/ewallet/ewallet.test.js | 2 + test/ewallet/ovo.test.js | 2 +- 4 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 test/ewallet/dana.test.js diff --git a/test/ewallet/constants.js b/test/ewallet/constants.js index 851e8db..d5284ee 100644 --- a/test/ewallet/constants.js +++ b/test/ewallet/constants.js @@ -39,6 +39,22 @@ const VALID_GET_OVO_PAYMENT_STATUS_RESPONSE = { status: 'COMPLETED', }; +const VALID_CREATE_DANA_RESPONSE = { + external_id: EXT_ID, + checkout_url: + 'https://dana.id/m/portal/cashier/checkout?id=a1b2c3d4e5f6g7h8i9j10k11', + amount: AMOUNT, + ewallet_type: DANA_EWALLET_TYPE, +}; + +const VALID_GET_DANA_PAYMENT_STATUS_RESPONSE = { + amount: EXT_ID, + external_id: EXT_ID, + expiration_date: String(new Date()), + business_id: '12121212', + status: 'PAID', +}; + const VALID_CREATE_LINKAJA_RESPONSE = { checkout_url: 'https://ewallet-linkaja.xendit.co/checkouts/75d64796-c9e7-46e9-8c96-3edeacf3817b', @@ -60,5 +76,7 @@ module.exports = { ITEMS, VALID_CREATE_OVO_RESPONSE, VALID_GET_OVO_PAYMENT_STATUS_RESPONSE, + VALID_CREATE_DANA_RESPONSE, + VALID_GET_DANA_PAYMENT_STATUS_RESPONSE, VALID_CREATE_LINKAJA_RESPONSE, }; diff --git a/test/ewallet/dana.test.js b/test/ewallet/dana.test.js new file mode 100644 index 0000000..01278dd --- /dev/null +++ b/test/ewallet/dana.test.js @@ -0,0 +1,85 @@ +const chai = require('chai'); +const chaiAsProm = require('chai-as-promised'); +const TestConstants = require('./constants'); +const { expect } = chai; +const nock = require('nock'); +const { Errors } = require('../../src/xendit'); + +chai.use(chaiAsProm); + +module.exports = function(x) { + const { EWallet } = x; + let ewallet; + beforeEach(function() { + ewallet = new EWallet({}); + }); + before(function() { + nock(x.opts.xenditURL) + .post('/ewallets', { + external_id: TestConstants.EXT_ID, + amount: TestConstants.AMOUNT, + callback_url: TestConstants.CALLBACK_URL, + redirect_url: TestConstants.REDIRECT_URL, + ewallet_type: TestConstants.DANA_EWALLET_TYPE, + }) + .reply(200, TestConstants.VALID_CREATE_DANA_RESPONSE); + nock(x.opts.xenditURL) + .get( + `/ewallets?external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.DANA_EWALLET_TYPE}`, + ) + .reply(200, TestConstants.VALID_GET_DANA_PAYMENT_STATUS_RESPONSE); + }); + + describe('createPayment', () => { + it('should create an Dana Payment', done => { + expect( + ewallet.dana.createPayment({ + externalID: TestConstants.EXT_ID, + amount: TestConstants.AMOUNT, + callbackURL: TestConstants.CALLBACK_URL, + redirectURL: TestConstants.REDIRECT_URL, + }), + ) + .to.eventually.deep.equal(TestConstants.VALID_CREATE_DANA_RESPONSE) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing required fields', done => { + expect(ewallet.dana.createPayment({})) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); + }); + + describe('getPaymentStatusByExtID', () => { + it('should get Dana Payment Status', done => { + expect( + ewallet.dana.getPaymentStatusByExtID({ + externalID: TestConstants.EXT_ID, + }), + ) + .to.eventually.deep.equal( + TestConstants.VALID_GET_DANA_PAYMENT_STATUS_RESPONSE, + ) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing required fields', done => { + expect(ewallet.dana.getPaymentStatusByExtID({})) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); + }); +}; diff --git a/test/ewallet/ewallet.test.js b/test/ewallet/ewallet.test.js index 8c20951..2b617f9 100644 --- a/test/ewallet/ewallet.test.js +++ b/test/ewallet/ewallet.test.js @@ -2,6 +2,7 @@ process.env.NODE_ENV = 'test'; const Xendit = require('../../src/xendit'); const ovo = require('./ovo.test'); +const dana = require('./dana.test'); const linkaja = require('./linkaja.test'); const x = new Xendit({ @@ -11,5 +12,6 @@ const x = new Xendit({ describe('EWallet Service', function() { ovo(x); + dana(x); linkaja(x); }); diff --git a/test/ewallet/ovo.test.js b/test/ewallet/ovo.test.js index bf7ca11..9d82083 100644 --- a/test/ewallet/ovo.test.js +++ b/test/ewallet/ovo.test.js @@ -55,7 +55,7 @@ module.exports = function(x) { }); }); - describe('getOVOPaymentStatusByExtID', () => { + describe('getPaymentStatusByExtID', () => { it('should get OVO Payment Status', done => { expect( ewallet.ovo.getPaymentStatusByExtID({ From 79d9c281da3049683116012b25295ee12dc254d9 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 13:43:09 +0700 Subject: [PATCH 36/67] [Fix] make dana expiration date as optional --- src/ewallet/dana.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ewallet/dana.d.ts b/src/ewallet/dana.d.ts index 0f9d0ca..32512c5 100644 --- a/src/ewallet/dana.d.ts +++ b/src/ewallet/dana.d.ts @@ -8,7 +8,7 @@ export = class OVO { createPayment(data: { externalID: string; amount: number; - expirationDate: string; + expirationDate?: string; callbackURL: string; redirectURL: string; }): Promise; From af0d66eb85b4eae7ba88be6ed35cc91120a453d5 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 13:45:36 +0700 Subject: [PATCH 37/67] [Update] Improve unit test --- test/ewallet/dana.test.js | 132 ++++++++++++++++++----------------- test/ewallet/linkaja.test.js | 82 +++++++++++----------- test/ewallet/ovo.test.js | 126 +++++++++++++++++---------------- 3 files changed, 173 insertions(+), 167 deletions(-) diff --git a/test/ewallet/dana.test.js b/test/ewallet/dana.test.js index 01278dd..00cace3 100644 --- a/test/ewallet/dana.test.js +++ b/test/ewallet/dana.test.js @@ -8,78 +8,80 @@ const { Errors } = require('../../src/xendit'); chai.use(chaiAsProm); module.exports = function(x) { - const { EWallet } = x; - let ewallet; - beforeEach(function() { - ewallet = new EWallet({}); - }); - before(function() { - nock(x.opts.xenditURL) - .post('/ewallets', { - external_id: TestConstants.EXT_ID, - amount: TestConstants.AMOUNT, - callback_url: TestConstants.CALLBACK_URL, - redirect_url: TestConstants.REDIRECT_URL, - ewallet_type: TestConstants.DANA_EWALLET_TYPE, - }) - .reply(200, TestConstants.VALID_CREATE_DANA_RESPONSE); - nock(x.opts.xenditURL) - .get( - `/ewallets?external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.DANA_EWALLET_TYPE}`, - ) - .reply(200, TestConstants.VALID_GET_DANA_PAYMENT_STATUS_RESPONSE); - }); - - describe('createPayment', () => { - it('should create an Dana Payment', done => { - expect( - ewallet.dana.createPayment({ - externalID: TestConstants.EXT_ID, - amount: TestConstants.AMOUNT, - callbackURL: TestConstants.CALLBACK_URL, - redirectURL: TestConstants.REDIRECT_URL, - }), - ) - .to.eventually.deep.equal(TestConstants.VALID_CREATE_DANA_RESPONSE) - .then(() => done()) - .catch(e => done(e)); + describe('Dana', () => { + const { EWallet } = x; + let ewallet; + beforeEach(function() { + ewallet = new EWallet({}); }); - it('should report missing required fields', done => { - expect(ewallet.dana.createPayment({})) - .to.eventually.to.be.rejected.then(e => - Promise.all([ - expect(e).to.have.property('status', 400), - expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), - ]), + before(function() { + nock(x.opts.xenditURL) + .post('/ewallets', { + external_id: TestConstants.EXT_ID, + amount: TestConstants.AMOUNT, + callback_url: TestConstants.CALLBACK_URL, + redirect_url: TestConstants.REDIRECT_URL, + ewallet_type: TestConstants.DANA_EWALLET_TYPE, + }) + .reply(200, TestConstants.VALID_CREATE_DANA_RESPONSE); + nock(x.opts.xenditURL) + .get( + `/ewallets?external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.DANA_EWALLET_TYPE}`, ) - .then(() => done()) - .catch(e => done(e)); + .reply(200, TestConstants.VALID_GET_DANA_PAYMENT_STATUS_RESPONSE); }); - }); - describe('getPaymentStatusByExtID', () => { - it('should get Dana Payment Status', done => { - expect( - ewallet.dana.getPaymentStatusByExtID({ - externalID: TestConstants.EXT_ID, - }), - ) - .to.eventually.deep.equal( - TestConstants.VALID_GET_DANA_PAYMENT_STATUS_RESPONSE, + describe('createPayment', () => { + it('should create an Dana Payment', done => { + expect( + ewallet.dana.createPayment({ + externalID: TestConstants.EXT_ID, + amount: TestConstants.AMOUNT, + callbackURL: TestConstants.CALLBACK_URL, + redirectURL: TestConstants.REDIRECT_URL, + }), ) - .then(() => done()) - .catch(e => done(e)); + .to.eventually.deep.equal(TestConstants.VALID_CREATE_DANA_RESPONSE) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing required fields', done => { + expect(ewallet.dana.createPayment({})) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); }); - it('should report missing required fields', done => { - expect(ewallet.dana.getPaymentStatusByExtID({})) - .to.eventually.to.be.rejected.then(e => - Promise.all([ - expect(e).to.have.property('status', 400), - expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), - ]), + + describe('getPaymentStatusByExtID', () => { + it('should get Dana Payment Status', done => { + expect( + ewallet.dana.getPaymentStatusByExtID({ + externalID: TestConstants.EXT_ID, + }), ) - .then(() => done()) - .catch(e => done(e)); + .to.eventually.deep.equal( + TestConstants.VALID_GET_DANA_PAYMENT_STATUS_RESPONSE, + ) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing required fields', done => { + expect(ewallet.dana.getPaymentStatusByExtID({})) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); }); }); }; diff --git a/test/ewallet/linkaja.test.js b/test/ewallet/linkaja.test.js index a314661..80c5523 100644 --- a/test/ewallet/linkaja.test.js +++ b/test/ewallet/linkaja.test.js @@ -8,51 +8,53 @@ const { Errors } = require('../../src/xendit'); chai.use(chaiAsProm); module.exports = function(x) { - const { EWallet } = x; - let ewallet; - beforeEach(function() { - ewallet = new EWallet({}); - }); - before(function() { - nock(x.opts.xenditURL) - .post('/ewallets', { - external_id: TestConstants.EXT_ID, - phone: TestConstants.PHONE, - amount: TestConstants.AMOUNT, - items: TestConstants.ITEMS, - callback_url: TestConstants.CALLBACK_URL, - redirect_url: TestConstants.REDIRECT_URL, - ewallet_type: TestConstants.LINKAJA_EWALLET_TYPE, - }) - .reply(200, TestConstants.VALID_CREATE_LINKAJA_RESPONSE); - }); - - describe('createPayment', () => { - it('should create an linkAja Payment', done => { - expect( - ewallet.linkaja.createPayment({ - externalID: TestConstants.EXT_ID, + describe('LinkAja', () => { + const { EWallet } = x; + let ewallet; + beforeEach(function() { + ewallet = new EWallet({}); + }); + before(function() { + nock(x.opts.xenditURL) + .post('/ewallets', { + external_id: TestConstants.EXT_ID, phone: TestConstants.PHONE, amount: TestConstants.AMOUNT, items: TestConstants.ITEMS, - callbackURL: TestConstants.CALLBACK_URL, - redirectURL: TestConstants.REDIRECT_URL, - }), - ) - .to.eventually.deep.equal(TestConstants.VALID_CREATE_LINKAJA_RESPONSE) - .then(() => done()) - .catch(e => done(e)); + callback_url: TestConstants.CALLBACK_URL, + redirect_url: TestConstants.REDIRECT_URL, + ewallet_type: TestConstants.LINKAJA_EWALLET_TYPE, + }) + .reply(200, TestConstants.VALID_CREATE_LINKAJA_RESPONSE); }); - it('should report missing required fields', done => { - expect(ewallet.linkaja.createPayment({})) - .to.eventually.to.be.rejected.then(e => - Promise.all([ - expect(e).to.have.property('status', 400), - expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), - ]), + + describe('createPayment', () => { + it('should create an linkAja Payment', done => { + expect( + ewallet.linkaja.createPayment({ + externalID: TestConstants.EXT_ID, + phone: TestConstants.PHONE, + amount: TestConstants.AMOUNT, + items: TestConstants.ITEMS, + callbackURL: TestConstants.CALLBACK_URL, + redirectURL: TestConstants.REDIRECT_URL, + }), ) - .then(() => done()) - .catch(e => done(e)); + .to.eventually.deep.equal(TestConstants.VALID_CREATE_LINKAJA_RESPONSE) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing required fields', done => { + expect(ewallet.linkaja.createPayment({})) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); }); }); }; diff --git a/test/ewallet/ovo.test.js b/test/ewallet/ovo.test.js index 9d82083..ddabc42 100644 --- a/test/ewallet/ovo.test.js +++ b/test/ewallet/ovo.test.js @@ -8,76 +8,78 @@ const { Errors } = require('../../src/xendit'); chai.use(chaiAsProm); module.exports = function(x) { - const { EWallet } = x; - let ewallet; - beforeEach(function() { - ewallet = new EWallet({}); - }); - before(function() { - nock(x.opts.xenditURL) - .post('/ewallets', { - external_id: TestConstants.EXT_ID, - phone: TestConstants.PHONE, - amount: TestConstants.AMOUNT, - ewallet_type: TestConstants.OVO_EWALLET_TYPE, - }) - .reply(200, TestConstants.VALID_CREATE_OVO_RESPONSE); - nock(x.opts.xenditURL) - .get( - `/ewallets?external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.OVO_EWALLET_TYPE}`, - ) - .reply(200, TestConstants.VALID_GET_OVO_PAYMENT_STATUS_RESPONSE); - }); - - describe('createPayment', () => { - it('should create an OVO Payment', done => { - expect( - ewallet.ovo.createPayment({ - externalID: TestConstants.EXT_ID, + describe('OVO', () => { + const { EWallet } = x; + let ewallet; + beforeEach(function() { + ewallet = new EWallet({}); + }); + before(function() { + nock(x.opts.xenditURL) + .post('/ewallets', { + external_id: TestConstants.EXT_ID, phone: TestConstants.PHONE, amount: TestConstants.AMOUNT, - }), - ) - .to.eventually.deep.equal(TestConstants.VALID_CREATE_OVO_RESPONSE) - .then(() => done()) - .catch(e => done(e)); - }); - it('should report missing required fields', done => { - expect(ewallet.ovo.createPayment({})) - .to.eventually.to.be.rejected.then(e => - Promise.all([ - expect(e).to.have.property('status', 400), - expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), - ]), + ewallet_type: TestConstants.OVO_EWALLET_TYPE, + }) + .reply(200, TestConstants.VALID_CREATE_OVO_RESPONSE); + nock(x.opts.xenditURL) + .get( + `/ewallets?external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.OVO_EWALLET_TYPE}`, ) - .then(() => done()) - .catch(e => done(e)); + .reply(200, TestConstants.VALID_GET_OVO_PAYMENT_STATUS_RESPONSE); }); - }); - describe('getPaymentStatusByExtID', () => { - it('should get OVO Payment Status', done => { - expect( - ewallet.ovo.getPaymentStatusByExtID({ - externalID: TestConstants.EXT_ID, - }), - ) - .to.eventually.deep.equal( - TestConstants.VALID_GET_OVO_PAYMENT_STATUS_RESPONSE, + describe('createPayment', () => { + it('should create an OVO Payment', done => { + expect( + ewallet.ovo.createPayment({ + externalID: TestConstants.EXT_ID, + phone: TestConstants.PHONE, + amount: TestConstants.AMOUNT, + }), ) - .then(() => done()) - .catch(e => done(e)); + .to.eventually.deep.equal(TestConstants.VALID_CREATE_OVO_RESPONSE) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing required fields', done => { + expect(ewallet.ovo.createPayment({})) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); }); - it('should report missing required fields', done => { - expect(ewallet.ovo.getPaymentStatusByExtID({})) - .to.eventually.to.be.rejected.then(e => - Promise.all([ - expect(e).to.have.property('status', 400), - expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), - ]), + + describe('getPaymentStatusByExtID', () => { + it('should get OVO Payment Status', done => { + expect( + ewallet.ovo.getPaymentStatusByExtID({ + externalID: TestConstants.EXT_ID, + }), ) - .then(() => done()) - .catch(e => done(e)); + .to.eventually.deep.equal( + TestConstants.VALID_GET_OVO_PAYMENT_STATUS_RESPONSE, + ) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing required fields', done => { + expect(ewallet.ovo.getPaymentStatusByExtID({})) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); }); }); }; From d74acecf3ee1a73a4bd75107889009c3924cf7df Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 13:56:07 +0700 Subject: [PATCH 38/67] [Update] Change phone number --- examples/ewallet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/ewallet.js b/examples/ewallet.js index e5db031..1134062 100644 --- a/examples/ewallet.js +++ b/examples/ewallet.js @@ -7,7 +7,7 @@ ew.ovo .createPayment({ externalID: new Date(), amount: 1, - phone: '087877971875', + phone: '081234567890', }) .then(r => { console.log('create OVO payment detail:', r); // eslint-disable-line no-console From 881a7c89dabb0286ea873cde962b95c83764efd6 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 14:18:15 +0700 Subject: [PATCH 39/67] [Update] Add Ewallets documentation --- README.md | 121 ++++++++++++++++++++++++++++++++++++++++++++ examples/ewallet.js | 6 +-- 2 files changed, 124 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f2aa4ac..ea17644 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,13 @@ For PCI compliance to be maintained, tokenization of credt cards info should be + [Methods](#methods-2) * [Invoice Services](#invoice-services) + [Methods](#methods-3) + * [EWallet Services](#ewallet-services) + + [OVO](#ovo) + + [Methods](#methods-4) + + [Dana](#dana) + + [Methods](#methods-5) + + [LinkAja](#linkaja) + + [Methods](#methods-6) - [Contributing](#contributing) @@ -399,6 +406,120 @@ i.getAllInvoices(data?: { }) ``` +### EWallet Services + +Instanitiate Invoice service using constructor that has been injected with Xendit keys + +```js +const { EWallet } = x; +const ewalletSpecificOptions = {}; +const ew = new EWallet(ewalletSpecificOptions); +``` + +- #### OVO + + Example: Create an OVO payment + +```js +ew.ovo.createPayment({ + externalID: 'my-ovo-payment', + amount: 1, + phone: '081234567890', + }) + .then(r => { + console.log('create OVO payment detail:', r); + return r; + }) +``` + + #### Methods + + - Create an OVO payment +```ts +ew.ovo.createPayment(data: { + externalID: string; + amount: number; + phone: string; +}) +``` + + - Get an OVO Payment Status +```ts +ew.ovo.getPaymentStatusByExtID(data: { externalID: string }) +``` + +- #### Dana + + Example: Create a dana payment + +```js +ew.dana.createPayment({ + externalID: 'my-dana-payment', + amount: 1, + callbackURL: 'https://my-shop.com/callbacks', + redirectURL: 'https://my-shop.com/home', + }) + .then(r => { + console.log('create Dana payment detail:', r); + return r; + }) +``` + + #### Methods + + - Create an Dana payment +```ts +ew.dana.createPayment(data: { + externalID: string; + amount: number; + expirationDate?: string; + callbackURL: string; + redirectURL: string; +}) +``` + +- #### LinkAja + + Example: Create a linkAja payment + +```js +ew.linkaja.createPayment({ + externalID: 'my-linkaja-payment', + phone: '081234567890', + amount: 30000, + items: [ + { + id: '123123', + name: 'Phone Case', + price: 100000, + quantity: 1, + }, + { + id: '345678', + name: 'Powerbank', + price: 200000, + quantity: 1, + }, + ], + callbackURL: 'https://yourwebsite.com/callback', + redirectURL: 'https://yourwebsite.com/home', + }) +``` + + #### Methods + + - Create an Dana payment +```ts +ew.linkaja.createPayment(data: { + externalID: string; + phone: string; + amount: number; + items: paymentItem[]; + callbackURL: string; + redirectURL: string; +}) +``` + ## Contributing Running test suite diff --git a/examples/ewallet.js b/examples/ewallet.js index 1134062..74f2a2f 100644 --- a/examples/ewallet.js +++ b/examples/ewallet.js @@ -29,8 +29,8 @@ ew.dana .createPayment({ externalID: new Date(), amount: 1, - callbackURL: 'http://google.com', - redirectURL: 'http://google.com', + callbackURL: 'https://my-shop.com/callbacks', + redirectURL: 'https://my-shop.com/home', }) .then(r => { console.log('create dana payment detail:', r); // eslint-disable-line no-console @@ -68,7 +68,7 @@ ew.linkaja }, ], callbackURL: 'https://yourwebsite.com/callback', - redirectURL: 'https://yourwebsite.com/callback', + redirectURL: 'https://yourwebsite.com/home', }) .then(r => { console.log('create linkAja payment detail:', r); // eslint-disable-line no-console From ec1ff4e4cce396051cd9f276f2bed166916e94d7 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 14:26:22 +0700 Subject: [PATCH 40/67] [Fix] Readme indentation From c2a2cd37e8d5758ebd2f2368a330bf86301eb0f3 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 14:30:18 +0700 Subject: [PATCH 41/67] [Fix] Readme indentation From a359e54750923e34e8f49e9fe5d7af7e0dfa643b Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 14:36:03 +0700 Subject: [PATCH 42/67] [Fix] Readme indentation --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index ea17644..19ddd24 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,28 @@ This library is the abstraction of Xendit API for access from applications writt **Note**: This library is only meant for usage from server-side with Xendit secret API key. For PCI compliance to be maintained, tokenization of credt cards info should be done on client side with [Xendit.js](https://docs.xendit.co/xenpayments/payments-credit-cards-overview/credit-cards-integration-and-testing/collecting-card-details-tokenization/index.html). + + +- [API Documentation](#api-documentation) +- [Installation](#installation) +- [Usage](#usage) + * [Card Services](#card-services) + + [Methods](#methods) + * [Virtual Account Services](#virtual-account-services) + + [Methods](#methods-1) + * [Disbursement Services](#disbursement-services) + + [Methods](#methods-2) + * [Invoice Services](#invoice-services) + + [Methods](#methods-3) + * [EWallet Services](#ewallet-services) + + [OVO](#ovo) + - [Methods](#methods-4) + + [Dana](#dana) + - [Methods](#methods-5) + + [LinkAja](#linkaja) + - [Methods](#methods-6) +- [Contributing](#contributing) + - [API Documentation](#api-documentation) From 54b8497e45f700bd62844d086f5c0197140d0ff7 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 14:38:08 +0700 Subject: [PATCH 43/67] [Fix] TS Linter --- src/ewallet/linkaja.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ewallet/linkaja.d.ts b/src/ewallet/linkaja.d.ts index 6cb32a1..8fd9824 100644 --- a/src/ewallet/linkaja.d.ts +++ b/src/ewallet/linkaja.d.ts @@ -1,6 +1,6 @@ import { EWalletOptions } from './ewallet_opts'; -interface paymentItem { +interface PaymentItem { id: string; name: string; price: number; @@ -17,7 +17,7 @@ export = class LinkAja { externalID: string; phone: string; amount: number; - items: paymentItem[]; + items: PaymentItem[]; callbackURL: string; redirectURL: string; }): Promise; From 1b0d1ecafb422a55afe7bc6896816c93d5fc3e45 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 14:55:35 +0700 Subject: [PATCH 44/67] [Fix] Ewallet integration test --- integration_test/ewallet.test.js | 11 ++++++----- integration_test/index.js | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/integration_test/ewallet.test.js b/integration_test/ewallet.test.js index 82ea77c..b727910 100644 --- a/integration_test/ewallet.test.js +++ b/integration_test/ewallet.test.js @@ -1,17 +1,18 @@ const x = require('./xendit.test'); const { EWallet } = x; -const e = new EWallet({}); +const ew = new EWallet({}); module.exports = function() { - return e - .createOVOPayment({ + return ew.ovo + .createPayment({ externalID: Date.now().toString(), phone: '081234567890', - amount: 100000, + amount: 1, }) + .then(r => ew.ovo.getPaymentStatusByExtID({ externalID: r.external_id })) .then(() => { // eslint-disable-next-line no-console - console.log('Invoice integration test done...'); + console.log('EWallet integration test done...'); }); }; diff --git a/integration_test/index.js b/integration_test/index.js index 98da880..90ba0e4 100644 --- a/integration_test/index.js +++ b/integration_test/index.js @@ -4,6 +4,7 @@ Promise.all([ require('./disbursement.test')(), require('./invoice.test')(), require('./va.test')(), + require('./ewallet.test')(), ]) .then(() => { // eslint-disable-next-line no-console From cef6cffab50fa115cd244dff240a74922ee46eec Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 20:24:58 +0700 Subject: [PATCH 45/67] [Update] Simplify Ewallet Service --- integration_test/ewallet.test.js | 12 ++++++--- integration_test/index.js | 8 +++--- src/ewallet/ewallet.d.ts | 15 +++++++---- src/ewallet/ewallet.js | 45 ++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 12 deletions(-) diff --git a/integration_test/ewallet.test.js b/integration_test/ewallet.test.js index b727910..4665935 100644 --- a/integration_test/ewallet.test.js +++ b/integration_test/ewallet.test.js @@ -4,13 +4,19 @@ const { EWallet } = x; const ew = new EWallet({}); module.exports = function() { - return ew.ovo + return ew .createPayment({ externalID: Date.now().toString(), - phone: '081234567890', + phone: '087877971875', amount: 1, + ewalletType: 'OVO', }) - .then(r => ew.ovo.getPaymentStatusByExtID({ externalID: r.external_id })) + .then(r => + ew.getPayment({ + externalID: r.external_id, + ewalletType: r.ewallet_type, + }), + ) .then(() => { // eslint-disable-next-line no-console console.log('EWallet integration test done...'); diff --git a/integration_test/index.js b/integration_test/index.js index 90ba0e4..42b2bfa 100644 --- a/integration_test/index.js +++ b/integration_test/index.js @@ -1,9 +1,9 @@ console.log('Starting integration test...'); // eslint-disable-line no-console Promise.all([ - require('./card.test')(), - require('./disbursement.test')(), - require('./invoice.test')(), - require('./va.test')(), + // require('./card.test')(), + // require('./disbursement.test')(), + // require('./invoice.test')(), + // require('./va.test')(), require('./ewallet.test')(), ]) .then(() => { diff --git a/src/ewallet/ewallet.d.ts b/src/ewallet/ewallet.d.ts index 804ff89..abe7c13 100644 --- a/src/ewallet/ewallet.d.ts +++ b/src/ewallet/ewallet.d.ts @@ -8,9 +8,14 @@ export = class EWallet { static _constructorWithInjectedXenditOpts: ( opts: XenditOptions, ) => typeof EWallet; - - ovo: typeof ovo; - createDanaPayment = dana.createPayment; - getDanaPaymentStatusByExtID = dana.getByExtID; - createLinkAjaPayment = linkaja.createPayment; + createPayment(data: { + externalID: string; + amount: number; + phone: string; + ewalletType: string; + }): Promise; + getPayment(data: { + externalID: string; + ewalletType: string; + }): Promise; }; diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index 91f19a0..9e381e2 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -1,3 +1,4 @@ +const { Validate, Auth, fetchWithHTTPErr, promWithJsErr } = require('../utils'); const OVO = require('./ovo'); const Dana = require('./dana'); const LinkAja = require('./linkaja'); @@ -12,6 +13,7 @@ function EWallet(options) { this.opts = aggOpts; this.opts.eWalletURL = this.opts.xenditURL + EWALLET_PATH; + this.API_ENDPOINT = this.opts.xenditURL + EWALLET_PATH; let ovo = OVO._constructorWithInjectedEWalletOpts(this.opts); let dana = Dana._constructorWithInjectedEWalletOpts(this.opts); @@ -28,4 +30,47 @@ EWallet._constructorWithInjectedXenditOpts = function(options) { return EWallet; }; +EWallet.prototype.createPayment = function(data) { + return promWithJsErr((resolve, reject) => { + Validate.rejectOnMissingFields( + ['externalID', 'amount', 'ewalletType'], + data, + reject, + ); + + fetchWithHTTPErr(`${this.API_ENDPOINT}`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: Auth.basicAuthHeader(this.opts.secretKey), + }, + body: JSON.stringify({ + external_id: data.externalID, + amount: data.amount, + phone: data.phone, + ewallet_type: data.ewalletType, + }), + }) + .then(resolve) + .catch(reject); + }); +}; + +EWallet.prototype.getPayment = function(data) { + return promWithJsErr((resolve, reject) => { + Validate.rejectOnMissingFields(['externalID', 'ewalletType'], data, reject); + fetchWithHTTPErr( + `${this.API_ENDPOINT}?external_id=${data.externalID}&ewallet_type=${data.ewalletType}`, + { + method: 'GET', + headers: { + Authorization: Auth.basicAuthHeader(this.opts.secretKey), + }, + }, + ) + .then(resolve) + .catch(reject); + }); +}; + module.exports = EWallet; From 99b815c1c8c5dd3e896285bd0a875e32aa91c73a Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 20:42:46 +0700 Subject: [PATCH 46/67] [Update] Delete Unused OVO flie --- examples/ewallet.js | 77 ++++++------------------------ src/ewallet/ewallet.js | 5 +- src/ewallet/ovo.d.ts | 14 ------ src/ewallet/ovo.js | 65 -------------------------- test/ewallet/ewallet.test.js | 90 ++++++++++++++++++++++++++++++++---- test/ewallet/ovo.test.js | 85 ---------------------------------- 6 files changed, 96 insertions(+), 240 deletions(-) delete mode 100644 src/ewallet/ovo.d.ts delete mode 100644 src/ewallet/ovo.js delete mode 100644 test/ewallet/ovo.test.js diff --git a/examples/ewallet.js b/examples/ewallet.js index 74f2a2f..c792880 100644 --- a/examples/ewallet.js +++ b/examples/ewallet.js @@ -3,75 +3,24 @@ const x = require('./xendit'); const EWallet = x.EWallet; const ew = new EWallet({}); -ew.ovo - .createPayment({ - externalID: new Date(), - amount: 1, - phone: '081234567890', - }) +ew.createPayment({ + externalID: new Date(), + amount: 1, + phone: '081234567890', + ewalletType: 'OVO', +}) .then(r => { - console.log('create OVO payment detail:', r); // eslint-disable-line no-console + console.log('create payment detail:', r); // eslint-disable-line no-console return r; }) - .then(({ external_id }) => - ew.ovo.getPaymentStatusByExtID({ externalID: external_id }), + .then(({ external_id, ewallet_type }) => + ew.ovo.getPaymentStatusByExtID({ + externalID: external_id, + ewalletType: ewallet_type, + }), ) .then(r => { - console.log('OVO payment status detail:', r); // eslint-disable-line no-console - return r; - }) - .catch(e => { - console.error(e); // eslint-disable-line no-console - process.exit(1); - }); - -ew.dana - .createPayment({ - externalID: new Date(), - amount: 1, - callbackURL: 'https://my-shop.com/callbacks', - redirectURL: 'https://my-shop.com/home', - }) - .then(r => { - console.log('create dana payment detail:', r); // eslint-disable-line no-console - return r; - }) - .then(({ external_id }) => - ew.dana.getPaymentStatusByExtID({ externalID: external_id }), - ) - .then(r => { - console.log('Dana payment status detail:', r); // eslint-disable-line no-console - return r; - }) - .catch(e => { - console.error(e); // eslint-disable-line no-console - process.exit(1); - }); - -ew.linkaja - .createPayment({ - externalID: new Date(), - phone: '081234567890', - amount: 30000, - items: [ - { - id: '123123', - name: 'Phone Case', - price: 100000, - quantity: 1, - }, - { - id: '345678', - name: 'Powerbank', - price: 200000, - quantity: 1, - }, - ], - callbackURL: 'https://yourwebsite.com/callback', - redirectURL: 'https://yourwebsite.com/home', - }) - .then(r => { - console.log('create linkAja payment detail:', r); // eslint-disable-line no-console + console.log('EWallet payment detail:', r); // eslint-disable-line no-console return r; }) .catch(e => { diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index 9e381e2..c474658 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -1,5 +1,4 @@ -const { Validate, Auth, fetchWithHTTPErr, promWithJsErr } = require('../utils'); -const OVO = require('./ovo'); +const { promWithJsErr, Auth, Validate, fetchWithHTTPErr } = require('../utils'); const Dana = require('./dana'); const LinkAja = require('./linkaja'); @@ -15,11 +14,9 @@ function EWallet(options) { this.opts.eWalletURL = this.opts.xenditURL + EWALLET_PATH; this.API_ENDPOINT = this.opts.xenditURL + EWALLET_PATH; - let ovo = OVO._constructorWithInjectedEWalletOpts(this.opts); let dana = Dana._constructorWithInjectedEWalletOpts(this.opts); let linkaja = LinkAja._constructorWithInjectedEWalletOpts(this.opts); - this.ovo = new ovo({}); this.dana = new dana({}); this.linkaja = new linkaja({}); } diff --git a/src/ewallet/ovo.d.ts b/src/ewallet/ovo.d.ts deleted file mode 100644 index 3b0d526..0000000 --- a/src/ewallet/ovo.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { EWalletOptions } from './ewallet_opts'; - -export = class OVO { - constructor({}); - static _constructorWithInjectedEWalletOpts: ( - opts: EWalletOptions, - ) => typeof OVO; - createPayment(data: { - externalID: string; - amount: number; - phone: string; - }): Promise; - getPaymentStatusByExtID(data: { externalID: string }): Promise; -}; diff --git a/src/ewallet/ovo.js b/src/ewallet/ovo.js deleted file mode 100644 index 63ee117..0000000 --- a/src/ewallet/ovo.js +++ /dev/null @@ -1,65 +0,0 @@ -const { Validate, Auth, fetchWithHTTPErr, promWithJsErr } = require('../utils'); - -const OVO_EWALLET_PATH = ''; - -function OVO(options) { - let aggOpts = options; - if (OVO._injectedOpts && Object.keys(OVO._injectedOpts).length > 0) { - aggOpts = Object.assign({}, options, OVO._injectedOpts); - } - - this.opts = aggOpts; - this.API_ENDPOINT = this.opts.eWalletURL + OVO_EWALLET_PATH; - this.EWALLET_TYPE = 'OVO'; -} - -OVO._injectedOpts = {}; -OVO._constructorWithInjectedEWalletOpts = function(options) { - OVO._injectedOpts = options; - return OVO; -}; - -OVO.prototype.createPayment = function(data) { - return promWithJsErr((resolve, reject) => { - Validate.rejectOnMissingFields( - ['externalID', 'amount', 'phone'], - data, - reject, - ); - - fetchWithHTTPErr(`${this.API_ENDPOINT}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: Auth.basicAuthHeader(this.opts.secretKey), - }, - body: JSON.stringify({ - external_id: data.externalID, - amount: data.amount, - phone: data.phone, - ewallet_type: this.EWALLET_TYPE, - }), - }) - .then(resolve) - .catch(reject); - }); -}; - -OVO.prototype.getPaymentStatusByExtID = function(data) { - return promWithJsErr((resolve, reject) => { - Validate.rejectOnMissingFields(['externalID'], data, reject); - fetchWithHTTPErr( - `${this.API_ENDPOINT}?external_id=${data.externalID}&ewallet_type=${this.EWALLET_TYPE}`, - { - method: 'GET', - headers: { - Authorization: Auth.basicAuthHeader(this.opts.secretKey), - }, - }, - ) - .then(resolve) - .catch(reject); - }); -}; - -module.exports = OVO; diff --git a/test/ewallet/ewallet.test.js b/test/ewallet/ewallet.test.js index 2b617f9..ca84cbe 100644 --- a/test/ewallet/ewallet.test.js +++ b/test/ewallet/ewallet.test.js @@ -1,17 +1,91 @@ -process.env.NODE_ENV = 'test'; - +const chai = require('chai'); +const chaiAsProm = require('chai-as-promised'); +const TestConstants = require('./constants'); +const { expect } = chai; +const nock = require('nock'); +const { Errors } = require('../../src/xendit'); const Xendit = require('../../src/xendit'); -const ovo = require('./ovo.test'); -const dana = require('./dana.test'); -const linkaja = require('./linkaja.test'); const x = new Xendit({ publicKey: 'fake_public_key', secretKey: 'fake_secret_key', }); +chai.use(chaiAsProm); + +const { EWallet } = x; +let ewallet; +beforeEach(function() { + ewallet = new EWallet({}); +}); +before(function() { + nock(x.opts.xenditURL) + .post('/ewallets', { + external_id: TestConstants.EXT_ID, + phone: TestConstants.PHONE, + amount: TestConstants.AMOUNT, + ewallet_type: TestConstants.OVO_EWALLET_TYPE, + }) + .reply(200, TestConstants.VALID_CREATE_OVO_RESPONSE); + nock(x.opts.xenditURL) + .get( + `/ewallets?external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.OVO_EWALLET_TYPE}`, + ) + .reply(200, TestConstants.VALID_GET_OVO_PAYMENT_STATUS_RESPONSE); +}); + describe('EWallet Service', function() { - ovo(x); - dana(x); - linkaja(x); + describe('createPayment', () => { + it('should create an OVO Payment', done => { + expect( + ewallet.createPayment({ + externalID: TestConstants.EXT_ID, + phone: TestConstants.PHONE, + amount: TestConstants.AMOUNT, + ewalletType: TestConstants.OVO_EWALLET_TYPE, + }), + ) + .to.eventually.deep.equal(TestConstants.VALID_CREATE_OVO_RESPONSE) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing required fields', done => { + expect(ewallet.createPayment({})) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); + }); + + describe('getPayment', () => { + it('should get OVO Payment Status', done => { + expect( + ewallet.getPayment({ + externalID: TestConstants.EXT_ID, + ewalletType: TestConstants.OVO_EWALLET_TYPE, + }), + ) + .to.eventually.deep.equal( + TestConstants.VALID_GET_OVO_PAYMENT_STATUS_RESPONSE, + ) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing required fields', done => { + expect(ewallet.getPayment({})) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); + }); }); diff --git a/test/ewallet/ovo.test.js b/test/ewallet/ovo.test.js deleted file mode 100644 index ddabc42..0000000 --- a/test/ewallet/ovo.test.js +++ /dev/null @@ -1,85 +0,0 @@ -const chai = require('chai'); -const chaiAsProm = require('chai-as-promised'); -const TestConstants = require('./constants'); -const { expect } = chai; -const nock = require('nock'); -const { Errors } = require('../../src/xendit'); - -chai.use(chaiAsProm); - -module.exports = function(x) { - describe('OVO', () => { - const { EWallet } = x; - let ewallet; - beforeEach(function() { - ewallet = new EWallet({}); - }); - before(function() { - nock(x.opts.xenditURL) - .post('/ewallets', { - external_id: TestConstants.EXT_ID, - phone: TestConstants.PHONE, - amount: TestConstants.AMOUNT, - ewallet_type: TestConstants.OVO_EWALLET_TYPE, - }) - .reply(200, TestConstants.VALID_CREATE_OVO_RESPONSE); - nock(x.opts.xenditURL) - .get( - `/ewallets?external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.OVO_EWALLET_TYPE}`, - ) - .reply(200, TestConstants.VALID_GET_OVO_PAYMENT_STATUS_RESPONSE); - }); - - describe('createPayment', () => { - it('should create an OVO Payment', done => { - expect( - ewallet.ovo.createPayment({ - externalID: TestConstants.EXT_ID, - phone: TestConstants.PHONE, - amount: TestConstants.AMOUNT, - }), - ) - .to.eventually.deep.equal(TestConstants.VALID_CREATE_OVO_RESPONSE) - .then(() => done()) - .catch(e => done(e)); - }); - it('should report missing required fields', done => { - expect(ewallet.ovo.createPayment({})) - .to.eventually.to.be.rejected.then(e => - Promise.all([ - expect(e).to.have.property('status', 400), - expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), - ]), - ) - .then(() => done()) - .catch(e => done(e)); - }); - }); - - describe('getPaymentStatusByExtID', () => { - it('should get OVO Payment Status', done => { - expect( - ewallet.ovo.getPaymentStatusByExtID({ - externalID: TestConstants.EXT_ID, - }), - ) - .to.eventually.deep.equal( - TestConstants.VALID_GET_OVO_PAYMENT_STATUS_RESPONSE, - ) - .then(() => done()) - .catch(e => done(e)); - }); - it('should report missing required fields', done => { - expect(ewallet.ovo.getPaymentStatusByExtID({})) - .to.eventually.to.be.rejected.then(e => - Promise.all([ - expect(e).to.have.property('status', 400), - expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), - ]), - ) - .then(() => done()) - .catch(e => done(e)); - }); - }); - }); -}; From aad814320035cc4989a791c322421cb8b4ea99b8 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 20:44:26 +0700 Subject: [PATCH 47/67] Remove unused test file --- test/ewallet/dana.test.js | 87 ------------------------------------ test/ewallet/linkaja.test.js | 60 ------------------------- 2 files changed, 147 deletions(-) delete mode 100644 test/ewallet/dana.test.js delete mode 100644 test/ewallet/linkaja.test.js diff --git a/test/ewallet/dana.test.js b/test/ewallet/dana.test.js deleted file mode 100644 index 00cace3..0000000 --- a/test/ewallet/dana.test.js +++ /dev/null @@ -1,87 +0,0 @@ -const chai = require('chai'); -const chaiAsProm = require('chai-as-promised'); -const TestConstants = require('./constants'); -const { expect } = chai; -const nock = require('nock'); -const { Errors } = require('../../src/xendit'); - -chai.use(chaiAsProm); - -module.exports = function(x) { - describe('Dana', () => { - const { EWallet } = x; - let ewallet; - beforeEach(function() { - ewallet = new EWallet({}); - }); - before(function() { - nock(x.opts.xenditURL) - .post('/ewallets', { - external_id: TestConstants.EXT_ID, - amount: TestConstants.AMOUNT, - callback_url: TestConstants.CALLBACK_URL, - redirect_url: TestConstants.REDIRECT_URL, - ewallet_type: TestConstants.DANA_EWALLET_TYPE, - }) - .reply(200, TestConstants.VALID_CREATE_DANA_RESPONSE); - nock(x.opts.xenditURL) - .get( - `/ewallets?external_id=${TestConstants.EXT_ID}&ewallet_type=${TestConstants.DANA_EWALLET_TYPE}`, - ) - .reply(200, TestConstants.VALID_GET_DANA_PAYMENT_STATUS_RESPONSE); - }); - - describe('createPayment', () => { - it('should create an Dana Payment', done => { - expect( - ewallet.dana.createPayment({ - externalID: TestConstants.EXT_ID, - amount: TestConstants.AMOUNT, - callbackURL: TestConstants.CALLBACK_URL, - redirectURL: TestConstants.REDIRECT_URL, - }), - ) - .to.eventually.deep.equal(TestConstants.VALID_CREATE_DANA_RESPONSE) - .then(() => done()) - .catch(e => done(e)); - }); - it('should report missing required fields', done => { - expect(ewallet.dana.createPayment({})) - .to.eventually.to.be.rejected.then(e => - Promise.all([ - expect(e).to.have.property('status', 400), - expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), - ]), - ) - .then(() => done()) - .catch(e => done(e)); - }); - }); - - describe('getPaymentStatusByExtID', () => { - it('should get Dana Payment Status', done => { - expect( - ewallet.dana.getPaymentStatusByExtID({ - externalID: TestConstants.EXT_ID, - }), - ) - .to.eventually.deep.equal( - TestConstants.VALID_GET_DANA_PAYMENT_STATUS_RESPONSE, - ) - .then(() => done()) - .catch(e => done(e)); - }); - it('should report missing required fields', done => { - expect(ewallet.dana.getPaymentStatusByExtID({})) - .to.eventually.to.be.rejected.then(e => - Promise.all([ - expect(e).to.have.property('status', 400), - expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), - ]), - ) - .then(() => done()) - .catch(e => done(e)); - }); - }); - }); -}; diff --git a/test/ewallet/linkaja.test.js b/test/ewallet/linkaja.test.js deleted file mode 100644 index 80c5523..0000000 --- a/test/ewallet/linkaja.test.js +++ /dev/null @@ -1,60 +0,0 @@ -const chai = require('chai'); -const chaiAsProm = require('chai-as-promised'); -const TestConstants = require('./constants'); -const { expect } = chai; -const nock = require('nock'); -const { Errors } = require('../../src/xendit'); - -chai.use(chaiAsProm); - -module.exports = function(x) { - describe('LinkAja', () => { - const { EWallet } = x; - let ewallet; - beforeEach(function() { - ewallet = new EWallet({}); - }); - before(function() { - nock(x.opts.xenditURL) - .post('/ewallets', { - external_id: TestConstants.EXT_ID, - phone: TestConstants.PHONE, - amount: TestConstants.AMOUNT, - items: TestConstants.ITEMS, - callback_url: TestConstants.CALLBACK_URL, - redirect_url: TestConstants.REDIRECT_URL, - ewallet_type: TestConstants.LINKAJA_EWALLET_TYPE, - }) - .reply(200, TestConstants.VALID_CREATE_LINKAJA_RESPONSE); - }); - - describe('createPayment', () => { - it('should create an linkAja Payment', done => { - expect( - ewallet.linkaja.createPayment({ - externalID: TestConstants.EXT_ID, - phone: TestConstants.PHONE, - amount: TestConstants.AMOUNT, - items: TestConstants.ITEMS, - callbackURL: TestConstants.CALLBACK_URL, - redirectURL: TestConstants.REDIRECT_URL, - }), - ) - .to.eventually.deep.equal(TestConstants.VALID_CREATE_LINKAJA_RESPONSE) - .then(() => done()) - .catch(e => done(e)); - }); - it('should report missing required fields', done => { - expect(ewallet.linkaja.createPayment({})) - .to.eventually.to.be.rejected.then(e => - Promise.all([ - expect(e).to.have.property('status', 400), - expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), - ]), - ) - .then(() => done()) - .catch(e => done(e)); - }); - }); - }); -}; From 471cb06eecd5a4c14e9e362ee816293321ab41a1 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 20:56:47 +0700 Subject: [PATCH 48/67] [Update] Delete Unused Dana flie --- src/ewallet/dana.d.ts | 17 ---------- src/ewallet/dana.js | 67 ---------------------------------------- src/ewallet/ewallet.d.ts | 8 +++-- src/ewallet/ewallet.js | 6 ++-- 4 files changed, 8 insertions(+), 90 deletions(-) delete mode 100644 src/ewallet/dana.d.ts delete mode 100644 src/ewallet/dana.js diff --git a/src/ewallet/dana.d.ts b/src/ewallet/dana.d.ts deleted file mode 100644 index 32512c5..0000000 --- a/src/ewallet/dana.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { EWalletOptions } from './ewallet_opts'; - -export = class OVO { - constructor({}); - static _constructorWithInjectedEWalletOpts: ( - opts: EWalletOptions, - ) => typeof OVO; - createPayment(data: { - externalID: string; - amount: number; - expirationDate?: string; - callbackURL: string; - redirectURL: string; - }): Promise; - getPaymentStatusByExtID(data: { externalID: string }): Promise; -}; - \ No newline at end of file diff --git a/src/ewallet/dana.js b/src/ewallet/dana.js deleted file mode 100644 index 3a1610c..0000000 --- a/src/ewallet/dana.js +++ /dev/null @@ -1,67 +0,0 @@ -const { Validate, Auth, fetchWithHTTPErr, promWithJsErr } = require('../utils'); - -const DANA_EWALLET_PATH = ''; - -function Dana(options) { - let aggOpts = options; - if (Dana._injectedOpts && Object.keys(Dana._injectedOpts).length > 0) { - aggOpts = Object.assign({}, options, Dana._injectedOpts); - } - - this.opts = aggOpts; - this.API_ENDPOINT = this.opts.eWalletURL + DANA_EWALLET_PATH; - this.EWALLET_TYPE = 'DANA'; -} - -Dana._injectedOpts = {}; -Dana._constructorWithInjectedEWalletOpts = function(options) { - Dana._injectedOpts = options; - return Dana; -}; - -Dana.prototype.createPayment = function(data) { - return promWithJsErr((resolve, reject) => { - Validate.rejectOnMissingFields( - ['externalID', 'amount', 'callbackURL', 'redirectURL'], - data, - reject, - ); - - fetchWithHTTPErr(`${this.API_ENDPOINT}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: Auth.basicAuthHeader(this.opts.secretKey), - }, - body: JSON.stringify({ - external_id: data.externalID, - amount: data.amount, - expiration_date: data.expirationDate, - callback_url: data.callbackURL, - redirect_url: data.redirectURL, - ewallet_type: this.EWALLET_TYPE, - }), - }) - .then(resolve) - .catch(reject); - }); -}; - -Dana.prototype.getPaymentStatusByExtID = function(data) { - return promWithJsErr((resolve, reject) => { - Validate.rejectOnMissingFields(['externalID'], data, reject); - fetchWithHTTPErr( - `${this.API_ENDPOINT}?external_id=${data.externalID}&ewallet_type=${this.EWALLET_TYPE}`, - { - method: 'GET', - headers: { - Authorization: Auth.basicAuthHeader(this.opts.secretKey), - }, - }, - ) - .then(resolve) - .catch(reject); - }); -}; - -module.exports = Dana; diff --git a/src/ewallet/ewallet.d.ts b/src/ewallet/ewallet.d.ts index abe7c13..12396e6 100644 --- a/src/ewallet/ewallet.d.ts +++ b/src/ewallet/ewallet.d.ts @@ -1,5 +1,4 @@ -import ovo from './ovo'; -import dana from './dana'; + import linkaja from './linkaja'; import { XenditOptions } from '../xendit_opts'; @@ -11,7 +10,10 @@ export = class EWallet { createPayment(data: { externalID: string; amount: number; - phone: string; + phone?: string; + expirationDate?: string; + callbackURL?: string; + redirectURL?: string; ewalletType: string; }): Promise; getPayment(data: { diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index c474658..d3c64cc 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -1,5 +1,4 @@ const { promWithJsErr, Auth, Validate, fetchWithHTTPErr } = require('../utils'); -const Dana = require('./dana'); const LinkAja = require('./linkaja'); const EWALLET_PATH = '/ewallets'; @@ -14,10 +13,8 @@ function EWallet(options) { this.opts.eWalletURL = this.opts.xenditURL + EWALLET_PATH; this.API_ENDPOINT = this.opts.xenditURL + EWALLET_PATH; - let dana = Dana._constructorWithInjectedEWalletOpts(this.opts); let linkaja = LinkAja._constructorWithInjectedEWalletOpts(this.opts); - this.dana = new dana({}); this.linkaja = new linkaja({}); } @@ -45,6 +42,9 @@ EWallet.prototype.createPayment = function(data) { external_id: data.externalID, amount: data.amount, phone: data.phone, + expiration_date: data.expirationDate, + callback_url: data.callbackURL, + redirec_url: data.redirecURL, ewallet_type: data.ewalletType, }), }) From 42cdbf26b50648fbddfea74f509c53dc4ea1278e Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 21:03:29 +0700 Subject: [PATCH 49/67] [Update] Delete Unused linkaja flie --- src/ewallet/ewallet.d.ts | 8 ++++++ src/ewallet/ewallet.js | 9 ++----- src/ewallet/ewallet_opts.d.ts | 7 ----- src/ewallet/linkaja.d.ts | 24 ----------------- src/ewallet/linkaja.js | 51 ----------------------------------- 5 files changed, 10 insertions(+), 89 deletions(-) delete mode 100644 src/ewallet/ewallet_opts.d.ts delete mode 100644 src/ewallet/linkaja.d.ts delete mode 100644 src/ewallet/linkaja.js diff --git a/src/ewallet/ewallet.d.ts b/src/ewallet/ewallet.d.ts index 12396e6..2340ac0 100644 --- a/src/ewallet/ewallet.d.ts +++ b/src/ewallet/ewallet.d.ts @@ -2,6 +2,13 @@ import linkaja from './linkaja'; import { XenditOptions } from '../xendit_opts'; +interface PaymentItem { + id: string; + name: string; + price: number; + quantity: number; +} + export = class EWallet { constructor({}); static _constructorWithInjectedXenditOpts: ( @@ -14,6 +21,7 @@ export = class EWallet { expirationDate?: string; callbackURL?: string; redirectURL?: string; + items?: PaymentItem[]; ewalletType: string; }): Promise; getPayment(data: { diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index d3c64cc..9c061e4 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -1,5 +1,4 @@ const { promWithJsErr, Auth, Validate, fetchWithHTTPErr } = require('../utils'); -const LinkAja = require('./linkaja'); const EWALLET_PATH = '/ewallets'; @@ -10,12 +9,7 @@ function EWallet(options) { } this.opts = aggOpts; - this.opts.eWalletURL = this.opts.xenditURL + EWALLET_PATH; this.API_ENDPOINT = this.opts.xenditURL + EWALLET_PATH; - - let linkaja = LinkAja._constructorWithInjectedEWalletOpts(this.opts); - - this.linkaja = new linkaja({}); } EWallet._injectedOpts = {}; @@ -44,7 +38,8 @@ EWallet.prototype.createPayment = function(data) { phone: data.phone, expiration_date: data.expirationDate, callback_url: data.callbackURL, - redirec_url: data.redirecURL, + redirect_url: data.redirectURL, + items: data.items, ewallet_type: data.ewalletType, }), }) diff --git a/src/ewallet/ewallet_opts.d.ts b/src/ewallet/ewallet_opts.d.ts deleted file mode 100644 index afcc977..0000000 --- a/src/ewallet/ewallet_opts.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface XenditOptions { - publicKey?: string; - secretKey: string; - xenditURL?: string; - eWalletURL: string; -} - \ No newline at end of file diff --git a/src/ewallet/linkaja.d.ts b/src/ewallet/linkaja.d.ts deleted file mode 100644 index 8fd9824..0000000 --- a/src/ewallet/linkaja.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { EWalletOptions } from './ewallet_opts'; - -interface PaymentItem { - id: string; - name: string; - price: number; - quantity: number; -} - - -export = class LinkAja { - constructor({}); - static _constructorWithInjectedEWalletOpts: ( - opts: EWalletOptions, - ) => typeof LinkAja; - createPayment(data: { - externalID: string; - phone: string; - amount: number; - items: PaymentItem[]; - callbackURL: string; - redirectURL: string; - }): Promise; -}; diff --git a/src/ewallet/linkaja.js b/src/ewallet/linkaja.js deleted file mode 100644 index 10e4577..0000000 --- a/src/ewallet/linkaja.js +++ /dev/null @@ -1,51 +0,0 @@ -const { Validate, Auth, fetchWithHTTPErr, promWithJsErr } = require('../utils'); - -const LINKAJA_EWALLET_PATH = ''; - -function LinkAja(options) { - let aggOpts = options; - if (LinkAja._injectedOpts && Object.keys(LinkAja._injectedOpts).length > 0) { - aggOpts = Object.assign({}, options, LinkAja._injectedOpts); - } - - this.opts = aggOpts; - this.API_ENDPOINT = this.opts.eWalletURL + LINKAJA_EWALLET_PATH; - this.EWALLET_TYPE = 'LINKAJA'; -} - -LinkAja._injectedOpts = {}; -LinkAja._constructorWithInjectedEWalletOpts = function(options) { - LinkAja._injectedOpts = options; - return LinkAja; -}; - -LinkAja.prototype.createPayment = function(data) { - return promWithJsErr((resolve, reject) => { - Validate.rejectOnMissingFields( - ['externalID', 'phone', 'amount', 'items', 'callbackURL', 'redirectURL'], - data, - reject, - ); - - fetchWithHTTPErr(`${this.API_ENDPOINT}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - Authorization: Auth.basicAuthHeader(this.opts.secretKey), - }, - body: JSON.stringify({ - external_id: data.externalID, - phone: data.phone, - amount: data.amount, - items: data.items, - callback_url: data.callbackURL, - redirect_url: data.redirectURL, - ewallet_type: this.EWALLET_TYPE, - }), - }) - .then(resolve) - .catch(reject); - }); -}; - -module.exports = LinkAja; From 8c66873638e39cdcc173860d2e7fb5945e792450 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 21:47:52 +0700 Subject: [PATCH 50/67] [Update] Simplify query string --- integration_test/ewallet.test.js | 2 +- src/ewallet/ewallet.js | 31 +++++++++++++++++++++---------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/integration_test/ewallet.test.js b/integration_test/ewallet.test.js index 4665935..ee788dc 100644 --- a/integration_test/ewallet.test.js +++ b/integration_test/ewallet.test.js @@ -7,7 +7,7 @@ module.exports = function() { return ew .createPayment({ externalID: Date.now().toString(), - phone: '087877971875', + phone: '081234567890', amount: 1, ewalletType: 'OVO', }) diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index 9c061e4..7d9366c 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -1,4 +1,10 @@ -const { promWithJsErr, Auth, Validate, fetchWithHTTPErr } = require('../utils'); +const { + promWithJsErr, + Auth, + Validate, + fetchWithHTTPErr, + queryStringWithoutUndefined, +} = require('../utils'); const EWALLET_PATH = '/ewallets'; @@ -26,7 +32,7 @@ EWallet.prototype.createPayment = function(data) { reject, ); - fetchWithHTTPErr(`${this.API_ENDPOINT}`, { + fetchWithHTTPErr(this.API_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -51,15 +57,20 @@ EWallet.prototype.createPayment = function(data) { EWallet.prototype.getPayment = function(data) { return promWithJsErr((resolve, reject) => { Validate.rejectOnMissingFields(['externalID', 'ewalletType'], data, reject); - fetchWithHTTPErr( - `${this.API_ENDPOINT}?external_id=${data.externalID}&ewallet_type=${data.ewalletType}`, - { - method: 'GET', - headers: { - Authorization: Auth.basicAuthHeader(this.opts.secretKey), - }, + + const queryStr = data + ? queryStringWithoutUndefined({ + external_id: data.externalID, + ewallet_type: data.ewalletType, + }) + : ''; + + fetchWithHTTPErr(`${this.API_ENDPOINT}?${queryStr}`, { + method: 'GET', + headers: { + Authorization: Auth.basicAuthHeader(this.opts.secretKey), }, - ) + }) .then(resolve) .catch(reject); }); From 8fb497e6be9f94d9eea34657aa904fe0bb092c47 Mon Sep 17 00:00:00 2001 From: Ervan Date: Sun, 29 Dec 2019 21:55:46 +0700 Subject: [PATCH 51/67] [Update] Remove Granular Ewallet type from readme --- README.md | 131 +++++++++--------------------------------------------- 1 file changed, 22 insertions(+), 109 deletions(-) diff --git a/README.md b/README.md index 19ddd24..2e30f7d 100644 --- a/README.md +++ b/README.md @@ -5,28 +5,6 @@ This library is the abstraction of Xendit API for access from applications writt **Note**: This library is only meant for usage from server-side with Xendit secret API key. For PCI compliance to be maintained, tokenization of credt cards info should be done on client side with [Xendit.js](https://docs.xendit.co/xenpayments/payments-credit-cards-overview/credit-cards-integration-and-testing/collecting-card-details-tokenization/index.html). - - -- [API Documentation](#api-documentation) -- [Installation](#installation) -- [Usage](#usage) - * [Card Services](#card-services) - + [Methods](#methods) - * [Virtual Account Services](#virtual-account-services) - + [Methods](#methods-1) - * [Disbursement Services](#disbursement-services) - + [Methods](#methods-2) - * [Invoice Services](#invoice-services) - + [Methods](#methods-3) - * [EWallet Services](#ewallet-services) - + [OVO](#ovo) - - [Methods](#methods-4) - + [Dana](#dana) - - [Methods](#methods-5) - + [LinkAja](#linkaja) - - [Methods](#methods-6) -- [Contributing](#contributing) - - [API Documentation](#api-documentation) @@ -41,12 +19,7 @@ For PCI compliance to be maintained, tokenization of credt cards info should be * [Invoice Services](#invoice-services) + [Methods](#methods-3) * [EWallet Services](#ewallet-services) - + [OVO](#ovo) - + [Methods](#methods-4) - + [Dana](#dana) - + [Methods](#methods-5) - + [LinkAja](#linkaja) - + [Methods](#methods-6) + + [Method](#method) - [Contributing](#contributing) @@ -430,7 +403,7 @@ i.getAllInvoices(data?: { ### EWallet Services -Instanitiate Invoice service using constructor that has been injected with Xendit keys +Instanitiate EWallet service using constructor that has been injected with Xendit keys ```js const { EWallet } = x; @@ -438,107 +411,47 @@ const ewalletSpecificOptions = {}; const ew = new EWallet(ewalletSpecificOptions); ``` -- #### OVO - - Example: Create an OVO payment + Example: Create an ewallet payment ```js ew.ovo.createPayment({ externalID: 'my-ovo-payment', amount: 1, phone: '081234567890', + ewalletType: 'OVO', }) .then(r => { - console.log('create OVO payment detail:', r); - return r; - }) -``` - - #### Methods - - - Create an OVO payment -```ts -ew.ovo.createPayment(data: { - externalID: string; - amount: number; - phone: string; -}) -``` - - - Get an OVO Payment Status -```ts -ew.ovo.getPaymentStatusByExtID(data: { externalID: string }) -``` - -- #### Dana - - Example: Create a dana payment - -```js -ew.dana.createPayment({ - externalID: 'my-dana-payment', - amount: 1, - callbackURL: 'https://my-shop.com/callbacks', - redirectURL: 'https://my-shop.com/home', - }) - .then(r => { - console.log('create Dana payment detail:', r); + console.log('create ewallet payment detail:', r); return r; }) ``` - #### Methods +#### Method - - Create an Dana payment +- Create an ewallet payment ```ts -ew.dana.createPayment(data: { +ew.createPayment(data: { externalID: string; amount: number; + phone?: string; expirationDate?: string; - callbackURL: string; - redirectURL: string; + callbackURL?: string; + redirectURL?: string; + items?: Array<{ + id: string; + name: string; + price: number; + quantity: number; + }>; + ewalletType: string; }) ``` -- #### LinkAja - - Example: Create a linkAja payment - -```js -ew.linkaja.createPayment({ - externalID: 'my-linkaja-payment', - phone: '081234567890', - amount: 30000, - items: [ - { - id: '123123', - name: 'Phone Case', - price: 100000, - quantity: 1, - }, - { - id: '345678', - name: 'Powerbank', - price: 200000, - quantity: 1, - }, - ], - callbackURL: 'https://yourwebsite.com/callback', - redirectURL: 'https://yourwebsite.com/home', - }) -``` - - #### Methods - - - Create an Dana payment +- Get an ewallet Payment Status ```ts -ew.linkaja.createPayment(data: { - externalID: string; - phone: string; - amount: number; - items: paymentItem[]; - callbackURL: string; - redirectURL: string; +ew.ovo.getPayment(data: { + externalID: string: + ewallet: string; }) ``` From ce756f9a6317d68ebb996d395a64994b9089594a Mon Sep 17 00:00:00 2001 From: Ervan Date: Mon, 30 Dec 2019 00:38:37 +0700 Subject: [PATCH 52/67] [Update] Add enum for ewallet type --- src/ewallet/ewallet.d.ts | 15 +++++++++++++-- src/ewallet/ewallet.js | 41 +++++++++++++++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/ewallet/ewallet.d.ts b/src/ewallet/ewallet.d.ts index 78f3737..6a89635 100644 --- a/src/ewallet/ewallet.d.ts +++ b/src/ewallet/ewallet.d.ts @@ -1,5 +1,16 @@ import { XenditOptions } from '../xendit_opts'; +enum CreateSupportWalletTypes { + OVO = 'OVO', + Dana = 'Dana', + Linkaja = 'LINKAJA', +} + +enum GetSupportWalletTypes { + OVO = 'OVO', + Dana = 'Dana', +} + interface PaymentItem { id: string; name: string; @@ -20,10 +31,10 @@ export = class EWallet { callbackURL?: string; redirectURL?: string; items?: PaymentItem[]; - ewalletType: string; + ewalletType: CreateSupportWalletTypes; }): Promise; getPayment(data: { externalID: string; - ewalletType: string; + ewalletType: GetSupportWalletTypes; }): Promise; }; diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index 7d9366c..1bd84ce 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -23,14 +23,45 @@ EWallet._constructorWithInjectedXenditOpts = function(options) { EWallet._injectedOpts = options; return EWallet; }; +EWallet.EWalletType = { + OVO: 'OVO', + Dana: 'DANA', + LinkAja: 'LINKAJA', +}; EWallet.prototype.createPayment = function(data) { return promWithJsErr((resolve, reject) => { - Validate.rejectOnMissingFields( - ['externalID', 'amount', 'ewalletType'], - data, - reject, - ); + let compulsoryFields = ['ewalletType']; + + if (data.ewalletType) { + switch (data.ewalletType) { + case 'OVO': + compulsoryFields = ['externalID', 'amount', 'ewalletType']; + break; + case 'DANA': + compulsoryFields = [ + 'externalID', + 'amount', + 'callbackURL', + 'redirectURL', + 'ewalletType', + ]; + break; + case 'LINKAJA': + compulsoryFields = [ + 'externalID', + 'phone', + 'amount', + 'items', + 'callbackURL', + 'redirectURL', + 'ewalletType', + ]; + break; + } + } + + Validate.rejectOnMissingFields(compulsoryFields, data, reject); fetchWithHTTPErr(this.API_ENDPOINT, { method: 'POST', From 8d3072bfe44cce7ce2e2ee6189d8706a7bc91101 Mon Sep 17 00:00:00 2001 From: Ervan Date: Mon, 30 Dec 2019 01:37:59 +0700 Subject: [PATCH 53/67] [Update] Ewallet unit test --- src/ewallet/ewallet.js | 2 +- test/ewallet/ewallet.test.js | 51 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index 1bd84ce..0401968 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -36,7 +36,7 @@ EWallet.prototype.createPayment = function(data) { if (data.ewalletType) { switch (data.ewalletType) { case 'OVO': - compulsoryFields = ['externalID', 'amount', 'ewalletType']; + compulsoryFields = ['externalID', 'amount', 'phone', 'ewalletType']; break; case 'DANA': compulsoryFields = [ diff --git a/test/ewallet/ewallet.test.js b/test/ewallet/ewallet.test.js index ca84cbe..a0be9ce 100644 --- a/test/ewallet/ewallet.test.js +++ b/test/ewallet/ewallet.test.js @@ -60,6 +60,57 @@ describe('EWallet Service', function() { .then(() => done()) .catch(e => done(e)); }); + it('should report missing OVO required fields', done => { + expect( + ewallet.createPayment({ + external_id: TestConstants.EXT_ID, + amount: TestConstants.AMOUNT, + ewallet_type: TestConstants.OVO_EWALLET_TYPE, + }), + ) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing Dana required fields', done => { + expect( + ewallet.createPayment({ + external_id: TestConstants.EXT_ID, + amount: TestConstants.AMOUNT, + ewallet_type: TestConstants.DANA_EWALLET_TYPE, + }), + ) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); + it('should report missing LinkAja required fields', done => { + expect( + ewallet.createPayment({ + external_id: TestConstants.EXT_ID, + amount: TestConstants.AMOUNT, + ewallet_type: TestConstants.LINKAJA_EWALLET_TYPE, + }), + ) + .to.eventually.to.be.rejected.then(e => + Promise.all([ + expect(e).to.have.property('status', 400), + expect(e).to.have.property('code', Errors.API_VALIDATION_ERROR), + ]), + ) + .then(() => done()) + .catch(e => done(e)); + }); }); describe('getPayment', () => { From 8bb5e3206669d5bfc15fec817b0ec9d968f7e55d Mon Sep 17 00:00:00 2001 From: Ervan Date: Mon, 30 Dec 2019 01:46:56 +0700 Subject: [PATCH 54/67] [Fix] Wrong Parameter --- README.md | 6 +++--- examples/ewallet.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8f35547..a66fd6f 100644 --- a/README.md +++ b/README.md @@ -535,7 +535,7 @@ ew.ovo.createPayment({ externalID: 'my-ovo-payment', amount: 1, phone: '081234567890', - ewalletType: 'OVO', + ewalletType: EWallet.EWalletType.OVO, }) .then(r => { console.log('create ewallet payment detail:', r); @@ -560,7 +560,7 @@ ew.createPayment(data: { price: number; quantity: number; }>; - ewalletType: string; + ewalletType: CreateSupportWalletTypes; }) ``` @@ -568,7 +568,7 @@ ew.createPayment(data: { ```ts ew.ovo.getPayment(data: { externalID: string: - ewallet: string; + ewalletType: GetSupportWalletTypes; }) ``` diff --git a/examples/ewallet.js b/examples/ewallet.js index c792880..d9a1b89 100644 --- a/examples/ewallet.js +++ b/examples/ewallet.js @@ -7,7 +7,7 @@ ew.createPayment({ externalID: new Date(), amount: 1, phone: '081234567890', - ewalletType: 'OVO', + ewalletType: EWallet.EWalletType.OVO, }) .then(r => { console.log('create payment detail:', r); // eslint-disable-line no-console From 2ba6514766bc2ccf919d38e0de829dbea63a3e57 Mon Sep 17 00:00:00 2001 From: Ervan Date: Mon, 30 Dec 2019 01:47:35 +0700 Subject: [PATCH 55/67] [Fix] Wrong method calling --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a66fd6f..66b8af0 100644 --- a/README.md +++ b/README.md @@ -566,7 +566,7 @@ ew.createPayment(data: { - Get an ewallet Payment Status ```ts -ew.ovo.getPayment(data: { +ew.getPayment(data: { externalID: string: ewalletType: GetSupportWalletTypes; }) From f01706cdde664f6adbcd8e7f282753e6d282f190 Mon Sep 17 00:00:00 2001 From: Ervan Date: Mon, 30 Dec 2019 01:52:50 +0700 Subject: [PATCH 56/67] [Fix] Change method params calling --- integration_test/ewallet.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_test/ewallet.test.js b/integration_test/ewallet.test.js index ee788dc..ec0a172 100644 --- a/integration_test/ewallet.test.js +++ b/integration_test/ewallet.test.js @@ -9,7 +9,7 @@ module.exports = function() { externalID: Date.now().toString(), phone: '081234567890', amount: 1, - ewalletType: 'OVO', + ewalletType: EWallet.EWalletType.OVO, }) .then(r => ew.getPayment({ From 92c49878ed64bbe4aa9e1cee0089fdf0483b5450 Mon Sep 17 00:00:00 2001 From: Ervan Date: Mon, 30 Dec 2019 01:58:33 +0700 Subject: [PATCH 57/67] [Update] Improve ewallet unit test --- test/ewallet/constants.js | 28 ---------------------------- test/ewallet/ewallet.test.js | 9 ++++++--- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/test/ewallet/constants.js b/test/ewallet/constants.js index d5284ee..a538696 100644 --- a/test/ewallet/constants.js +++ b/test/ewallet/constants.js @@ -39,31 +39,6 @@ const VALID_GET_OVO_PAYMENT_STATUS_RESPONSE = { status: 'COMPLETED', }; -const VALID_CREATE_DANA_RESPONSE = { - external_id: EXT_ID, - checkout_url: - 'https://dana.id/m/portal/cashier/checkout?id=a1b2c3d4e5f6g7h8i9j10k11', - amount: AMOUNT, - ewallet_type: DANA_EWALLET_TYPE, -}; - -const VALID_GET_DANA_PAYMENT_STATUS_RESPONSE = { - amount: EXT_ID, - external_id: EXT_ID, - expiration_date: String(new Date()), - business_id: '12121212', - status: 'PAID', -}; - -const VALID_CREATE_LINKAJA_RESPONSE = { - checkout_url: - 'https://ewallet-linkaja.xendit.co/checkouts/75d64796-c9e7-46e9-8c96-3edeacf3817b', - transaction_date: String(new Date()), - amount: 30000, - external_id: EXT_ID, - ewallet_type: LINKAJA_EWALLET_TYPE, -}; - module.exports = { OVO_EWALLET_TYPE, DANA_EWALLET_TYPE, @@ -76,7 +51,4 @@ module.exports = { ITEMS, VALID_CREATE_OVO_RESPONSE, VALID_GET_OVO_PAYMENT_STATUS_RESPONSE, - VALID_CREATE_DANA_RESPONSE, - VALID_GET_DANA_PAYMENT_STATUS_RESPONSE, - VALID_CREATE_LINKAJA_RESPONSE, }; diff --git a/test/ewallet/ewallet.test.js b/test/ewallet/ewallet.test.js index a0be9ce..2d2dc28 100644 --- a/test/ewallet/ewallet.test.js +++ b/test/ewallet/ewallet.test.js @@ -80,8 +80,9 @@ describe('EWallet Service', function() { it('should report missing Dana required fields', done => { expect( ewallet.createPayment({ - external_id: TestConstants.EXT_ID, + externalID: TestConstants.EXT_ID, amount: TestConstants.AMOUNT, + redirectURL: TestConstants.REDIRECT_URL, ewallet_type: TestConstants.DANA_EWALLET_TYPE, }), ) @@ -97,9 +98,11 @@ describe('EWallet Service', function() { it('should report missing LinkAja required fields', done => { expect( ewallet.createPayment({ - external_id: TestConstants.EXT_ID, + externalID: TestConstants.EXT_ID, + phone: TestConstants.PHONE, amount: TestConstants.AMOUNT, - ewallet_type: TestConstants.LINKAJA_EWALLET_TYPE, + callbackURL: TestConstants.CALLBACK_URL, + redirectURL: TestConstants.REDIRECT_URL, }), ) .to.eventually.to.be.rejected.then(e => From a9329a22115aef56622ad4c4b15854076ff4a027 Mon Sep 17 00:00:00 2001 From: Ervan Date: Mon, 30 Dec 2019 02:12:36 +0700 Subject: [PATCH 58/67] [Fix] Wrong ExpirationDate Type --- README.md | 4 ++-- src/ewallet/ewallet.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 66b8af0..01180d0 100644 --- a/README.md +++ b/README.md @@ -528,7 +528,7 @@ const ewalletSpecificOptions = {}; const ew = new EWallet(ewalletSpecificOptions); ``` - Example: Create an ewallet payment +Example: Create an ewallet payment ```js ew.ovo.createPayment({ @@ -551,7 +551,7 @@ ew.createPayment(data: { externalID: string; amount: number; phone?: string; - expirationDate?: string; + expirationDate?: Date; callbackURL?: string; redirectURL?: string; items?: Array<{ diff --git a/src/ewallet/ewallet.d.ts b/src/ewallet/ewallet.d.ts index 6a89635..2998bd4 100644 --- a/src/ewallet/ewallet.d.ts +++ b/src/ewallet/ewallet.d.ts @@ -27,7 +27,7 @@ export = class EWallet { externalID: string; amount: number; phone?: string; - expirationDate?: string; + expirationDate?: Date; callbackURL?: string; redirectURL?: string; items?: PaymentItem[]; From 6cc5c0b369ecdb09e011c6a9a2cc13731f6aae1b Mon Sep 17 00:00:00 2001 From: Ervan Date: Mon, 30 Dec 2019 02:14:22 +0700 Subject: [PATCH 59/67] [Fix] Wrong method calling in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 01180d0..404ee47 100644 --- a/README.md +++ b/README.md @@ -531,7 +531,7 @@ const ew = new EWallet(ewalletSpecificOptions); Example: Create an ewallet payment ```js -ew.ovo.createPayment({ +ew.createPayment({ externalID: 'my-ovo-payment', amount: 1, phone: '081234567890', From 93549ca23b92d1328236f012e215450e13dd6b44 Mon Sep 17 00:00:00 2001 From: Ervan Date: Mon, 30 Dec 2019 02:19:39 +0700 Subject: [PATCH 60/67] [Update] Change integration test with dana --- integration_test/ewallet.test.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/integration_test/ewallet.test.js b/integration_test/ewallet.test.js index ec0a172..b08bfd7 100644 --- a/integration_test/ewallet.test.js +++ b/integration_test/ewallet.test.js @@ -7,9 +7,11 @@ module.exports = function() { return ew .createPayment({ externalID: Date.now().toString(), - phone: '081234567890', - amount: 1, - ewalletType: EWallet.EWalletType.OVO, + amount: 11000, + expiration_date: '2020-02-20T00:00:00.000Z', + callback_url: 'https://my-shop.com/callbacks', + redirect_url: 'https://my-shop.com/home', + ewalletType: EWallet.EWalletType.DANA, }) .then(r => ew.getPayment({ From 11428ccf283f7bbcfc3f536eae1c701137b6d669 Mon Sep 17 00:00:00 2001 From: Ervan Date: Mon, 30 Dec 2019 02:23:53 +0700 Subject: [PATCH 61/67] [Fix] EWallet Integration Test Params --- integration_test/ewallet.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integration_test/ewallet.test.js b/integration_test/ewallet.test.js index b08bfd7..4447881 100644 --- a/integration_test/ewallet.test.js +++ b/integration_test/ewallet.test.js @@ -8,10 +8,10 @@ module.exports = function() { .createPayment({ externalID: Date.now().toString(), amount: 11000, - expiration_date: '2020-02-20T00:00:00.000Z', - callback_url: 'https://my-shop.com/callbacks', - redirect_url: 'https://my-shop.com/home', - ewalletType: EWallet.EWalletType.DANA, + expirationDate: '2020-02-20T00:00:00.000Z', + callbackURL: 'https://my-shop.com/callbacks', + redirectURL: 'https://my-shop.com/home', + ewalletType: EWallet.EWalletType.Dana, }) .then(r => ew.getPayment({ From 5584dfb8233fad5ac582a458fd4fc573bd93f833 Mon Sep 17 00:00:00 2001 From: Stanley Nguyen Date: Mon, 30 Dec 2019 12:24:54 +0800 Subject: [PATCH 62/67] feat(ewallet) add EWalletType static prop --- src/ewallet/ewallet.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ewallet/ewallet.d.ts b/src/ewallet/ewallet.d.ts index 2998bd4..2807eb1 100644 --- a/src/ewallet/ewallet.d.ts +++ b/src/ewallet/ewallet.d.ts @@ -2,13 +2,13 @@ import { XenditOptions } from '../xendit_opts'; enum CreateSupportWalletTypes { OVO = 'OVO', - Dana = 'Dana', + Dana = 'DANA', Linkaja = 'LINKAJA', } enum GetSupportWalletTypes { OVO = 'OVO', - Dana = 'Dana', + Dana = 'DANA', } interface PaymentItem { @@ -23,6 +23,11 @@ export = class EWallet { static _constructorWithInjectedXenditOpts: ( opts: XenditOptions, ) => typeof EWallet; + static EwalletType: { + OVO: string; + Dana: string; + LinkAja: string; + }; createPayment(data: { externalID: string; amount: number; From 238735e615e29780ef5572f9ca24d27d16647c3d Mon Sep 17 00:00:00 2001 From: Stanley Nguyen Date: Mon, 30 Dec 2019 12:29:42 +0800 Subject: [PATCH 63/67] feat(ewallet) Shorten EWallet Type prop name --- README.md | 2 +- examples/ewallet.js | 2 +- integration_test/ewallet.test.js | 2 +- src/ewallet/ewallet.d.ts | 2 +- src/ewallet/ewallet.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 404ee47..9cd83db 100644 --- a/README.md +++ b/README.md @@ -535,7 +535,7 @@ ew.createPayment({ externalID: 'my-ovo-payment', amount: 1, phone: '081234567890', - ewalletType: EWallet.EWalletType.OVO, + ewalletType: EWallet.Type.OVO, }) .then(r => { console.log('create ewallet payment detail:', r); diff --git a/examples/ewallet.js b/examples/ewallet.js index d9a1b89..2a8bad4 100644 --- a/examples/ewallet.js +++ b/examples/ewallet.js @@ -7,7 +7,7 @@ ew.createPayment({ externalID: new Date(), amount: 1, phone: '081234567890', - ewalletType: EWallet.EWalletType.OVO, + ewalletType: EWallet.Type.OVO, }) .then(r => { console.log('create payment detail:', r); // eslint-disable-line no-console diff --git a/integration_test/ewallet.test.js b/integration_test/ewallet.test.js index 4447881..957db20 100644 --- a/integration_test/ewallet.test.js +++ b/integration_test/ewallet.test.js @@ -11,7 +11,7 @@ module.exports = function() { expirationDate: '2020-02-20T00:00:00.000Z', callbackURL: 'https://my-shop.com/callbacks', redirectURL: 'https://my-shop.com/home', - ewalletType: EWallet.EWalletType.Dana, + ewalletType: EWallet.Type.Dana, }) .then(r => ew.getPayment({ diff --git a/src/ewallet/ewallet.d.ts b/src/ewallet/ewallet.d.ts index 2807eb1..33494e6 100644 --- a/src/ewallet/ewallet.d.ts +++ b/src/ewallet/ewallet.d.ts @@ -23,7 +23,7 @@ export = class EWallet { static _constructorWithInjectedXenditOpts: ( opts: XenditOptions, ) => typeof EWallet; - static EwalletType: { + static Type: { OVO: string; Dana: string; LinkAja: string; diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index 0401968..787f810 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -23,7 +23,7 @@ EWallet._constructorWithInjectedXenditOpts = function(options) { EWallet._injectedOpts = options; return EWallet; }; -EWallet.EWalletType = { +EWallet.Type = { OVO: 'OVO', Dana: 'DANA', LinkAja: 'LINKAJA', From 3dfa782bff97283d223b06d2ce267efd532c2d0d Mon Sep 17 00:00:00 2001 From: Stanley Nguyen Date: Mon, 30 Dec 2019 12:35:08 +0800 Subject: [PATCH 64/67] fix(xendit.d.ts) Fix Xendit Ewallet prop declaration --- src/xendit.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xendit.d.ts b/src/xendit.d.ts index a1873c1..a908588 100644 --- a/src/xendit.d.ts +++ b/src/xendit.d.ts @@ -17,5 +17,5 @@ export = class Xendit { Invoice: typeof InvoiceService; Payout: typeof PayoutService; RecurringPayment: typeof RecurringPayment; - EWalletService: typeof EWalletService; + EWallet: typeof EWalletService; }; From 36dbbcb0d30649953cc4281fd6efe2f9e5bc017d Mon Sep 17 00:00:00 2001 From: Stanley Nguyen Date: Fri, 3 Jan 2020 10:03:55 +0800 Subject: [PATCH 65/67] chore(changelog) Add project CHANGELOG.md --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..260ef7c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,35 @@ +# CHANGELOG + +## 2019-12-29 + +- [#16](https://github.com/xendit/xendit-node/pull/16) (feature) Recurring Payments +- [#18](https://github.com/xendit/xendit-node/pull/18) (feature) Payouts +- [#20](https://github.com/xendit/xendit-node/pull/20) (feature) EWallets + +## 2019-12-28 + +- [#19](https://github.com/xendit/xendit-node/pull/19) Add linting for ts files + +## 2019-12-26 + +- [#15](https://github.com/xendit/xendit-node/pull/15) Remove tokenization & authentication from Card + +## 2019-12-16 + +- [#13](https://github.com/xendit/xendit-node/pull/13) Add integration tests + +## 2019-11-28 + +- (feature) Invoices + +## 2019-11-26 + +- (bugfix) `createdFixedVA` on nil expirationDate +- (bugfix) `updateFixedVA` on nul expirationDate + +## 2019-11-03 + +- (feature) Credit Cards +- (feature) Virtual Accounts +- (feature) Disbursements +- (feature) Batch Disbursements From bb9287c507dfb4ee44afab978c23c72f49942995 Mon Sep 17 00:00:00 2001 From: Stanley Nguyen Date: Fri, 3 Jan 2020 10:14:17 +0800 Subject: [PATCH 66/67] feat(ewallet) Improve ewallet validation guard --- src/ewallet/ewallet.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ewallet/ewallet.js b/src/ewallet/ewallet.js index 787f810..2a320ea 100644 --- a/src/ewallet/ewallet.js +++ b/src/ewallet/ewallet.js @@ -5,6 +5,7 @@ const { fetchWithHTTPErr, queryStringWithoutUndefined, } = require('../utils'); +const errors = require('../errors'); const EWALLET_PATH = '/ewallets'; @@ -35,10 +36,10 @@ EWallet.prototype.createPayment = function(data) { if (data.ewalletType) { switch (data.ewalletType) { - case 'OVO': + case EWallet.Type.OVO: compulsoryFields = ['externalID', 'amount', 'phone', 'ewalletType']; break; - case 'DANA': + case EWallet.Type.Dana: compulsoryFields = [ 'externalID', 'amount', @@ -47,7 +48,7 @@ EWallet.prototype.createPayment = function(data) { 'ewalletType', ]; break; - case 'LINKAJA': + case EWallet.Type.LinkAja: compulsoryFields = [ 'externalID', 'phone', @@ -58,6 +59,12 @@ EWallet.prototype.createPayment = function(data) { 'ewalletType', ]; break; + default: + reject({ + status: 400, + code: errors.API_VALIDATION_ERROR, + message: 'Invalid EWallet Type', + }); } } From ce3e5def5c155a2b2c5b15d5a0ca8ad95bc98c7c Mon Sep 17 00:00:00 2001 From: Stanley Nguyen Date: Fri, 3 Jan 2020 10:19:46 +0800 Subject: [PATCH 67/67] (refactor) Remove ewallet from integration tests This is because there's no sandbox env for eWalelt for integration tests to be run --- integration_test/ewallet.test.js | 26 -------------------------- integration_test/index.js | 1 - 2 files changed, 27 deletions(-) delete mode 100644 integration_test/ewallet.test.js diff --git a/integration_test/ewallet.test.js b/integration_test/ewallet.test.js deleted file mode 100644 index 957db20..0000000 --- a/integration_test/ewallet.test.js +++ /dev/null @@ -1,26 +0,0 @@ -const x = require('./xendit.test'); - -const { EWallet } = x; -const ew = new EWallet({}); - -module.exports = function() { - return ew - .createPayment({ - externalID: Date.now().toString(), - amount: 11000, - expirationDate: '2020-02-20T00:00:00.000Z', - callbackURL: 'https://my-shop.com/callbacks', - redirectURL: 'https://my-shop.com/home', - ewalletType: EWallet.Type.Dana, - }) - .then(r => - ew.getPayment({ - externalID: r.external_id, - ewalletType: r.ewallet_type, - }), - ) - .then(() => { - // eslint-disable-next-line no-console - console.log('EWallet integration test done...'); - }); -}; diff --git a/integration_test/index.js b/integration_test/index.js index 2f1bb5b..c32c9d4 100644 --- a/integration_test/index.js +++ b/integration_test/index.js @@ -6,7 +6,6 @@ Promise.all([ require('./va.test')(), require('./payout.test')(), require('./recurring.test')(), - require('./ewallet.test')(), ]) .then(() => { // eslint-disable-next-line no-console