Skip to content

Commit

Permalink
Merge pull request #172 from xendit/APPL-1038/PaymentMethodV2
Browse files Browse the repository at this point in the history
APPL-1038/PaymentMethodV2
  • Loading branch information
dharmasatrya authored Nov 8, 2022
2 parents 2ceccc8 + 250e0f2 commit 89bcb65
Show file tree
Hide file tree
Showing 13 changed files with 1,127 additions and 5 deletions.
48 changes: 48 additions & 0 deletions examples/with_async/payment_method_v2.js
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);
}
})();
37 changes: 37 additions & 0 deletions examples/with_promises/payment_methods_v2.js
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}`,
);
});
8 changes: 4 additions & 4 deletions integration_test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ Promise.all([
// require('./ewallet.test')(),
require('./qr_code.test')(),
require('./platform.test')(),
require('./regional_retail_outlet.test'),
require('./customer.test')(),
require('./direct_debit.test')(),
require('./report.test')(),
require('./transaction.test')(),
require('./payment_method_v2.test'),
// require('./refund.test')() //test disabled until refunds endpoint is fixed
])
.then(() => {
Promise.all([require('./regional_retail_outlet.test')()]).then(() =>
// eslint-disable-next-line no-console
console.log('Successful Integration Test!'),
);
// eslint-disable-next-line no-console
console.log('Successful Integration Test!');
})
.catch(e => {
console.error(e); // eslint-disable-line no-console
Expand Down
44 changes: 44 additions & 0 deletions integration_test/payment_method_v2.test.js
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}`,
);
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xendit-node",
"version": "1.21.8",
"version": "1.21.9",
"description": "NodeJS client for Xendit API",
"main": "index.js",
"types": "index.d.ts",
Expand Down
3 changes: 3 additions & 0 deletions src/payment_method_v2/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import PaymentMethodV2Service from './payment_method_v2';

export { PaymentMethodV2Service };
3 changes: 3 additions & 0 deletions src/payment_method_v2/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const PaymentMethodV2Service = require('./payment_method_v2');

module.exports = { PaymentMethodV2Service };
Loading

0 comments on commit 89bcb65

Please sign in to comment.