-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from xendit/feat/customer-service-api-version…
…ing+ewallet-tokenization-flow Feat/customer service api versioning+ewallet tokenization flow
- Loading branch information
Showing
27 changed files
with
1,240 additions
and
554 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules/ | |
.env | ||
.nyc_output | ||
coverage | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
const x = require('../xendit'); | ||
|
||
const EWallet = x.EWallet; | ||
const { EWallet, Customer } = x; | ||
const ew = new EWallet({}); | ||
const c = new Customer({}); | ||
|
||
/* | ||
* The entire EWallet tokenization flow, at this time, | ||
* cannot be replicated through an example | ||
* This is because of the system design, | ||
* once a token is created it has | ||
* to be verified manually by using the authorizer url. | ||
* Subsequent methods `create payment method`, | ||
* `get payment by ID`, and `unlink tokenization` | ||
* can only be carried out after the manual authorization | ||
*/ | ||
|
||
(async function() { | ||
try { | ||
|
@@ -64,6 +76,31 @@ const ew = new EWallet({}); | |
// eslint-disable-next-line no-console | ||
console.log('voided ewallet payment charge:', voidedCharge); | ||
|
||
let customer = await c.createCustomer({ | ||
referenceID: new Date().toISOString(), | ||
givenNames: 'customer 1', | ||
email: '[email protected]', | ||
mobileNumber: '+6281212345678', | ||
description: 'dummy customer', | ||
middleName: 'middle', | ||
surname: 'surname', | ||
addresses: [], | ||
apiVersion: '2020-05-19', | ||
}); | ||
// eslint-disable-next-line no-console | ||
console.log('created customer', customer); | ||
|
||
let tokenization = await ew.initializeTokenization({ | ||
customerID: customer.id, | ||
channelCode: 'PH_GRABPAY', | ||
properties: { | ||
successRedirectURL: 'https://www.google.com', | ||
failureRedirectURL: 'https://www.google.com', | ||
callbackURL: 'https://www.google.com', | ||
}, | ||
}); | ||
// eslint-disable-next-line no-console | ||
console.log('initialized tokenization', tokenization); | ||
process.exit(0); | ||
} catch (e) { | ||
console.error(e); // eslint-disable-line no-console | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
const x = require('../xendit'); | ||
|
||
const EWallet = x.EWallet; | ||
const { EWallet, Customer } = x; | ||
const ew = new EWallet({}); | ||
const c = new Customer({}); | ||
|
||
/* | ||
* The entire EWallet tokenization flow, at this time, | ||
* cannot be replicated through an example | ||
* This is because of the system design, | ||
* once a token is created it has | ||
* to be verified manually by using the authorizer url. | ||
* Subsequent methods `create payment method`, | ||
* `get payment by ID`, and `unlink tokenization` | ||
* can only be carried out after the manual authorization | ||
*/ | ||
|
||
ew.createPayment({ | ||
externalID: Date.now().toString(), | ||
|
@@ -80,6 +92,40 @@ ew.createPayment({ | |
console.log('voided ewallet payment charge:', r); | ||
return r; | ||
}) | ||
.then(() => | ||
c.createCustomer({ | ||
referenceID: new Date().toISOString(), | ||
givenNames: 'customer 1', | ||
email: '[email protected]', | ||
mobileNumber: '+6281212345678', | ||
description: 'dummy customer', | ||
middleName: 'middle', | ||
surname: 'surname', | ||
addresses: [], | ||
apiVersion: '2020-05-19', | ||
}), | ||
) | ||
.then(r => { | ||
// eslint-disable-next-line no-console | ||
console.log('created customer:', r); | ||
return r; | ||
}) | ||
.then(r => | ||
ew.initializeTokenization({ | ||
customerID: r.id, | ||
channelCode: 'PH_GRABPAY', | ||
properties: { | ||
successRedirectURL: 'https://www.google.com', | ||
failureRedirectURL: 'https://www.google.com', | ||
callbackURL: 'https://www.google.com', | ||
}, | ||
}), | ||
) | ||
.then(r => { | ||
// eslint-disable-next-line no-console | ||
console.log('initialized tokenization:', r); | ||
return r; | ||
}) | ||
.catch(e => { | ||
console.error(e); // eslint-disable-line no-console | ||
process.exit(1); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
const x = require('./xendit.test'); | ||
|
||
const { EWallet } = x; | ||
const { EWallet, Customer } = x; | ||
const ew = new EWallet({}); | ||
const c = new Customer({}); | ||
|
||
/* | ||
* The entire EWallet tokenization flow, at this time, | ||
* cannot be replicated through an integration test | ||
* This is because of the system design, | ||
* once a token is created it has | ||
* to be verified manually by using the authorizer url. | ||
* Subsequent methods `create payment method`, | ||
* `get payment by ID`, and `unlink tokenization` | ||
* can only be carried out after the manual authorization | ||
*/ | ||
|
||
module.exports = function() { | ||
return ew | ||
|
@@ -57,6 +69,30 @@ module.exports = function() { | |
chargeID: r.id, | ||
}), | ||
) | ||
.then(() => | ||
c.createCustomer({ | ||
referenceID: new Date().toISOString(), | ||
givenNames: 'Test Customer', | ||
email: '[email protected]', | ||
mobileNumber: '+6281212345678', | ||
description: 'dummy customer', | ||
middleName: 'middle', | ||
surname: 'surname', | ||
addresses: [], | ||
apiVersion: '2020-05-19', | ||
}), | ||
) | ||
.then(r => | ||
ew.initializeTokenization({ | ||
customerID: r.id, | ||
channelCode: 'PH_GRABPAY', | ||
properties: { | ||
successRedirectURL: 'https://www.google.com', | ||
failureRedirectURL: 'https://www.google.com', | ||
callbackURL: 'https://www.google.com', | ||
}, | ||
}), | ||
) | ||
.then(() => { | ||
// eslint-disable-next-line no-console | ||
console.log('EWallet integration test done...'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.