-
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 #135 from xendit/feat/support-transaction-api
feat/support transaction api
- Loading branch information
Showing
17 changed files
with
3,939 additions
and
2,260 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 @@ | ||
v16.13.2 |
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,32 @@ | ||
const x = require('../xendit'); | ||
|
||
const { Transaction } = x; | ||
const t = new Transaction({}); | ||
|
||
(async function() { | ||
try { | ||
const listTransactions = await t.listTransactions({ | ||
types: ['DISBURSEMENT', 'PAYMENT'], | ||
statuses: ['PENDING', 'SUCCESS'], | ||
channelCategories: ['BANK'], | ||
createdDateFrom: new Date( | ||
new Date().getTime() - 30 * 24 * 60 * 60 * 1000, | ||
), | ||
createdDateTo: new Date(), | ||
}); | ||
// eslint-disable-next-line no-console | ||
console.log('list transactions', listTransactions); | ||
|
||
/* Will fail if there is no transaction data in the time period */ | ||
const getTransaction = await t.getTransaction({ | ||
id: listTransactions.data[0].id, | ||
}); | ||
// eslint-disable-next-line no-console | ||
console.log('get transaction', getTransaction); | ||
process.exit(0); | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.error(e); | ||
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 { Transaction } = x; | ||
const t = new Transaction({}); | ||
|
||
t.listTransactions({ | ||
types: ['DISBURSEMENT', 'PAYMENT'], | ||
statuses: ['PENDING', 'SUCCESS'], | ||
channelCategories: ['BANK'], | ||
createdDateFrom: new Date(new Date().getTime() - 30 * 24 * 60 * 60 * 1000), | ||
createdDateTo: new Date(), | ||
}) | ||
.then(res => { | ||
// eslint-disable-next-line no-console | ||
console.log('list transactions:', res); | ||
return res; | ||
}) | ||
// will fail if there are no transactions in this time period | ||
.then(res => t.getTransaction({ id: res.data[0].id })) | ||
.then(res => { | ||
// eslint-disable-next-line no-console | ||
console.log('get transaction', res); | ||
return res; | ||
}) | ||
.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,27 @@ | ||
const x = require('./xendit.test'); | ||
|
||
const { Transaction } = x; | ||
const t = new Transaction({}); | ||
|
||
module.exports = function() { | ||
return t | ||
.listTransactions({ | ||
types: ['DISBURSEMENT', 'PAYMENT'], | ||
statuses: ['PENDING', 'SUCCESS'], | ||
channelCategories: ['BANK'], | ||
createdDateFrom: new Date('2022-01-01T00:00:00.000Z'), | ||
createdDateTo: new Date('2022-02-01T00:00:00.000Z'), | ||
}) | ||
.then(res => { | ||
t.getTransaction({ id: res.data[0].id }); | ||
}) | ||
.then(() => { | ||
// eslint-disable-next-line no-console | ||
console.log('Transaction integration test done...'); | ||
}) | ||
.catch(e => { | ||
throw new Error( | ||
`Transaction integration tests failed with error: ${e.message}`, | ||
); | ||
}); | ||
}; |
Oops, something went wrong.