-
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 #172 from xendit/APPL-1038/PaymentMethodV2
APPL-1038/PaymentMethodV2
- Loading branch information
Showing
13 changed files
with
1,127 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const x = require('../xendit'); | ||
|
||
const { PaymentMethodV2 } = x; | ||
const pm = new PaymentMethodV2({}); | ||
|
||
(async function() { | ||
try { | ||
let createdPaymentMethod = await pm.createPaymentMethodV2({ | ||
type: 'DIRECT_DEBIT', | ||
reusability: 'ONE_TIME_USE', | ||
customer_id: '16f72571-9b3a-43dc-b241-5b71f470202f', | ||
country: 'ID', | ||
direct_debit: { | ||
channel_code: 'BRI', | ||
channel_properties: { | ||
mobile_number: '+6281299640904', | ||
card_last_four: '8888', | ||
card_expiry: '10/29', | ||
email: '[email protected]', | ||
}, | ||
}, | ||
}); | ||
// eslint-disable-next-line no-console | ||
console.log('created payment method', createdPaymentMethod); | ||
|
||
const paymentMethodDetailsById = await pm.getPaymentMethodByIdV2({ | ||
id: createdPaymentMethod.id, | ||
}); | ||
// eslint-disable-next-line no-console | ||
console.log('retrieved payment method', paymentMethodDetailsById); | ||
|
||
const listOfPaymentMethod = await pm.listPaymentMethodV2({}); | ||
// eslint-disable-next-line no-console | ||
console.log('retrieved payment method list', listOfPaymentMethod); | ||
|
||
const authorizedPaymentMethod = await pm.authorizePaymentMethodV2({ | ||
id: createdPaymentMethod.id, | ||
auth_code: '333000', | ||
}); | ||
// eslint-disable-next-line no-console | ||
console.log('authorized payment method', authorizedPaymentMethod); | ||
|
||
process.exit(0); | ||
} 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const x = require('../xendit'); | ||
|
||
const PaymentMethodV2 = x.PaymentMethodV2; | ||
const pm = new PaymentMethodV2(); | ||
|
||
pm.createPaymentMethodV2({ | ||
type: 'DIRECT_DEBIT', | ||
reusability: 'ONE_TIME_USE', | ||
customer_id: '16f72571-9b3a-43dc-b241-5b71f470202f', | ||
country: 'ID', | ||
direct_debit: { | ||
channel_code: 'BRI', | ||
channel_properties: { | ||
mobile_number: '+6281299640904', | ||
card_last_four: '8888', | ||
card_expiry: '10/29', | ||
email: '[email protected]', | ||
}, | ||
}, | ||
}) | ||
.then(id => { | ||
pm.authorizePaymentMethodV2({ | ||
id, | ||
auth_code: '333000', | ||
}); | ||
}) | ||
.then(id => { | ||
pm.getPaymentMethodByIdV2({ id }); | ||
}) | ||
.then(() => { | ||
pm.listPaymentMethodV2({}); | ||
}) | ||
.catch(e => { | ||
throw new Error( | ||
`payment method integration tests failed with error: ${e.message}`, | ||
); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const x = require('./xendit.test'); | ||
|
||
const { PaymentMethodV2 } = x; | ||
const pm = new PaymentMethodV2({}); | ||
|
||
module.exports = function() { | ||
return pm | ||
.createPaymentMethodV2({ | ||
type: 'DIRECT_DEBIT', | ||
reusability: 'ONE_TIME_USE', | ||
customer_id: '16f72571-9b3a-43dc-b241-5b71f470202f', | ||
country: 'ID', | ||
direct_debit: { | ||
channel_code: 'BRI', | ||
channel_properties: { | ||
mobile_number: '+6281299640904', | ||
card_last_four: '8888', | ||
card_expiry: '10/29', | ||
email: '[email protected]', | ||
}, | ||
}, | ||
}) | ||
.then(id => { | ||
pm.authorizePaymentMethodV2({ | ||
id, | ||
auth_code: '333000', | ||
}); | ||
}) | ||
.then(id => { | ||
pm.getPaymentMethodByIdV2({ id }); | ||
}) | ||
.then(() => { | ||
pm.listPaymentMethodV2({}); | ||
}) | ||
.then(() => { | ||
// eslint-disable-next-line no-console | ||
console.log('payment method integration test done...'); | ||
}) | ||
.catch(e => { | ||
throw new Error( | ||
`payment method integration tests failed with error: ${e.message}`, | ||
); | ||
}); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import PaymentMethodV2Service from './payment_method_v2'; | ||
|
||
export { PaymentMethodV2Service }; |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const PaymentMethodV2Service = require('./payment_method_v2'); | ||
|
||
module.exports = { PaymentMethodV2Service }; |
Oops, something went wrong.