Skip to content

Commit

Permalink
Add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Vigar committed Jan 21, 2022
1 parent 72a92ff commit ab15a94
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/with_async/retail_outlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ const ro = new RetailOutlet({});
// eslint-disable-next-line no-console
console.log('updated payment code details:', updatedPmCode);

await ro.simulatePayment({
retailOutletName: 'ALFAMART',
paymentCode: updatedPmCode.payment_code,
transferAmount: 12000,
});
// eslint-disable-next-line no-console
console.log('simulated payment:', updatedPmCode);

const paymentsByCodeId = await ro.getPaymentsByFixedPaymentCodeId({ id });
// eslint-disable-next-line no-console
console.log('payments by fixed payment code ID:', paymentsByCodeId);

process.exit(0);
} catch (e) {
console.error(e); // eslint-disable-line no-console
Expand Down
21 changes: 21 additions & 0 deletions examples/with_promises/retail_outlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ ro.createFixedPaymentCode({
console.log('updated payment code details:', r);
return r;
})
.then(({ id, payment_code }) =>
Promise.all([
id,
ro.simulatePayment({
retailOutletName: 'ALFAMART',
paymentCode: payment_code,
transferAmount: 12000,
}),
]),
)
.then(r => {
// eslint-disable-next-line no-console
console.log('simulated payment:', r);
return r;
})
.then(([id]) => ro.getPaymentsByFixedPaymentCodeId({ id }))
.then(r => {
// eslint-disable-next-line no-console
console.log('payments by fixed payment code ID:', r);
return r;
})
.catch(e => {
console.error(e); // eslint-disable-line no-console
process.exit(1);
Expand Down

0 comments on commit ab15a94

Please sign in to comment.