forked from xendit/xendit-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
611 additions
and
10 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
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,47 @@ | ||
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]', | ||
}, | ||
}, | ||
}); | ||
console.log('created payment method', createdPaymentMethod); // eslint-disable-line no-console | ||
|
||
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,28 @@ | ||
const x = require('../xendit'); | ||
|
||
const { Refund } = x; | ||
const r = new Refund({}); | ||
|
||
(async function() { | ||
try { | ||
let refund = await r.createRefund({ | ||
invoice_id: '63676ed0eb10cf38ce0550b7', | ||
reason: 'OTHERS', | ||
amount: 1, | ||
}); | ||
console.log('created refund', refund); // eslint-disable-line no-console | ||
|
||
const refundDetails = await r.getRefundById({ id: refund.id }); | ||
// eslint-disable-next-line no-console | ||
console.log('retrieved refund', refundDetails); | ||
|
||
const refundList = await r.listRefunds({}); | ||
// eslint-disable-next-line no-console | ||
console.log('list of refunds', refundList); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const x = require('../xendit'); | ||
|
||
const Refund = x.Refund; | ||
const ref = new Refund(); | ||
|
||
ref | ||
.createRefund({ | ||
invoice_id: '63676ed0eb10cf38ce0550b7', | ||
reason: 'OTHERS', | ||
amount: 1, | ||
}) | ||
.then(r => { | ||
// eslint-disable-next-line no-console | ||
console.log('refund created:', r); | ||
return r; | ||
}) | ||
.then(({ id }) => ref.getRefundById({ id })) | ||
.then(r => { | ||
// eslint-disable-next-line no-console | ||
console.log('refund details:', r); | ||
return r; | ||
}) | ||
.then(() => { | ||
return ref.listRefunds({}); | ||
}) | ||
.then(r => { | ||
// eslint-disable-next-line no-console | ||
console.log(':', 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const x = require('./xendit.test'); | ||
|
||
const { Refund } = x; | ||
const r = new Refund({}); | ||
|
||
module.exports = function() { | ||
return r | ||
.createRefund({ | ||
invoice_id: '63676ed0eb10cf38ce0550b7', | ||
reason: 'FRAUDULENT', | ||
amount: 1, | ||
}) | ||
.then(id => { | ||
r.getRefundById({ id }); | ||
}) | ||
.then(() => { | ||
r.listRefunds({}); | ||
}) | ||
.then(() => { | ||
// eslint-disable-next-line no-console | ||
console.log('QR Code integration test done...'); | ||
}) | ||
.catch(e => { | ||
throw new Error( | ||
`Recurring 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 RefundService from './refund'; | ||
|
||
export { RefundService }; |
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 RefundService = require('./refund'); | ||
|
||
module.exports = { RefundService }; |
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,39 @@ | ||
enum RefundReasons { | ||
Fraudulent = 'FRAUDULENT', | ||
Duplicate = 'DUPLICATE', | ||
RequestedByCustomer = 'REQUESTED_BY_CUSTOMER', | ||
Cancellation = 'CANCELLATION', | ||
Others = 'OTHERS', | ||
} | ||
|
||
export = class Refund { | ||
constructor({}); | ||
static _constructorWithInjectedXenditOpts: ( | ||
opts: XenditOptions, | ||
) => typeof Refund; | ||
|
||
createRefund(data: { | ||
payment_request_id?: string; | ||
reference_id?: string; | ||
invoice_id?: string; | ||
currency?: string; | ||
amount?: number; | ||
reason: RefundReasons; | ||
metadata?: object; | ||
idempotencty_key?: string; | ||
for_user_id?: string; | ||
}): Promise<object>; | ||
|
||
listRefunds(data: { | ||
payment_request_id?: string; | ||
invoice_id?: string; | ||
payment_method_type?: string; | ||
channel_code?: string; | ||
limit?: number; | ||
after_id?: string; | ||
before_id?: string; | ||
for_user_id?: string; | ||
}): Promise<object>; | ||
|
||
getRefundById(data: { id: string }): Promise<object>; | ||
}; |
Oops, something went wrong.