Skip to content

Commit

Permalink
Merge pull request #151 from xendit/feat/update-api-key-for-examples
Browse files Browse the repository at this point in the history
Updated Examples and Tests to Pass w/ New API Key
  • Loading branch information
xen-HendryZheng authored Mar 25, 2022
2 parents da0c12d + 17ae786 commit 8f75523
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 194 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ jobs:
- run: npm test
- run: npm run test:integration
env:
SECRET_KEY: xnd_development_chBDpzjQZEI8nncBLrWtwau5r7rgiuunCJ4JCqsd68rXemDd74BnRpdO0bIZAMK
SECRET_KEY: xnd_development_oI7I6slPeYIxZPyfNxVIQt6R0JxiXGIRTBxBw5Ij26rjUwUeF29Aa9wHSETkM3
SECRET_KEY_PH: xnd_development_Va7pPIfYxIo7letKqhZCkwniwggDGyjB0sAzmOUe1mMkED4k0nLh1TvtVi0raNne
211 changes: 108 additions & 103 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,106 +16,106 @@ For PCI compliance to be maintained, tokenization of credit cards info should be
- [API Documentation](#api-documentation)
- [Installation](#installation)
- [Usage](#usage)
* [Card Services](#card-services)
+ [Create charge](#create-charge)
+ [Capture charge](#capture-charge)
+ [Get charge](#get-charge)
+ [Create authorization](#create-authorization)
+ [Reverse authorization](#reverse-authorization)
+ [Create refund](#create-refund)
+ [Create promotion](#create-promotion)
* [Virtual Account Services](#virtual-account-services)
+ [Get banks with available virtual account service](#get-banks-with-available-virtual-account-service)
+ [Create a fixed virtual account](#create-a-fixed-virtual-account)
+ [Get details of your fixed virtual account](#get-details-of-your-fixed-virtual-account)
+ [Update details of your fixed virtual account](#update-details-of-your-fixed-virtual-account)
+ [Get details of a VA payment](#get-details-of-a-va-payment)
* [Disbursement Services](#disbursement-services)
+ [Get banks with available disbursement service](#get-banks-with-available-disbursement-service)
+ [Create a disbursement](#create-a-disbursement)
+ [Create a batch of disbursements](#create-a-batch-of-disbursements)
+ [Get a disbursement by ID](#get-a-disbursement-by-id)
* [Invoice Services](#invoice-services)
+ [Create an invoice](#create-an-invoice)
+ [Get an invoice](#get-an-invoice)
+ [Expire an invoice](#expire-an-invoice)
+ [Get all invoices](#get-all-invoices)
* [Recurring Payments Services](#recurring-payments-services)
+ [Create recurring payment](#create-recurring-payment)
+ [Get recurring payment](#get-recurring-payment)
+ [Edit recurring payment](#edit-recurring-payment)
+ [Stop recurring payment](#stop-recurring-payment)
+ [Pause recurring payment](#pause-recurring-payment)
+ [Resume recurring payment](#resume-recurring-payment)
* [Recurring Services](#recurring-services)
+ [Create recurring schedule](#create-recurring-schedule)
+ [Edit recurring schedule](#edit-recurring-schedule)
+ [Get recurring schedule](#get-recurring-schedule)
+ [Create recurring plan](#create-recurring-plan)
+ [Create recurring plan with schedule](#create-recurring-plan-with-schedule)
+ [Edit recurring plan](#edit-recurring-plan)
+ [Get recurring plan](#get-recurring-plan)
+ [Deactivate recurring plan](#deactivate-recurring-plan)
+ [Edit recurring cycle](#edit-recurring-cycle)
+ [Get recurring cycle](#get-recurring-cycle)
+ [Get all recurring cycles](#get-all-recurring-cycles)
+ [Cancel recurring cycle](#cancel-recurring-cycle)
* [Payout Services](#payout-services)
+ [Create a payout](#create-a-payout)
+ [Get a payout](#get-a-payout)
+ [Void a payout](#void-a-payout)
* [EWallet Services](#ewallet-services)
+ [Create payment](#create-payment)
+ [Get payment](#get-payment)
+ [Create an ewallet charge](#create-an-ewallet-charge)
+ [Get an ewallet charge status](#get-an-ewallet-charge-status)
+ [Void an ewallet charge](#void-an-ewallet-charge)
+ [Initialize tokenization](#initialize-tokenization)
+ [Unlink tokenization](#unlink-tokenization)
+ [Create payment method (E-Wallet)](#create-payment-method-e-wallet)
+ [Get payment methods by customer ID (E-Wallet)](#get-payment-methods-by-customer-id-e-wallet)
* [Balance Services](#balance-services)
+ [Get balance](#get-balance)
* [Retail Outlet Services](#retail-outlet-services)
+ [Create fixed payment code](#create-fixed-payment-code)
+ [Get fixed payment code](#get-fixed-payment-code)
+ [Get payments by fixed payment code ID](#get-payments-by-fixed-payment-code-id)
+ [Update fixed payment code](#update-fixed-payment-code)
+ [Simulate payment for RO (only in dev mode)](#simulate-payment-for-ro-only-in-dev-mode)
* [QR Code Services](#qr-code-services)
+ [Create code](#create-code)
+ [Get code](#get-code)
+ [Simulate payment for QR (only in dev mode)](#simulate-payment-for-qr-only-in-dev-mode)
+ [Get payments by external ID](#get-payments-by-external-id)
* [Customer services](#customer-services)
+ [Create customer](#create-customer)
+ [Get customer](#get-customer)
+ [Get customer by reference ID](#get-customer-by-reference-id)
+ [Update customer](#update-customer)
* [Direct debit services](#direct-debit-services)
+ [Initialize linked account tokenization](#initialize-linked-account-tokenization)
+ [Validate OTP for Linked Account Token](#validate-otp-for-linked-account-token)
+ [Retrieve accessible accounts by linked account token](#retrieve-accessible-accounts-by-linked-account-token)
+ [Create payment method (Direct Debit)](#create-payment-method-direct-debit)
+ [Get payment methods by customer ID (Direct Debit)](#get-payment-methods-by-customer-id-direct-debit)
+ [Create direct debit payment](#create-direct-debit-payment)
+ [Validate OTP for direct debit payment](#validate-otp-for-direct-debit-payment)
+ [Get direct debit payment status by ID](#get-direct-debit-payment-status-by-id)
+ [Get direct debit payment status by reference ID](#get-direct-debit-payment-status-by-reference-id)
* [Report Service](#report-service)
+ [Generate Report](#generate-report)
+ [Get Report](#get-report)
* [Transaction Service](#transaction-service)
+ [Get Transaction](#get-transaction)
+ [List Transactions](#list-transactions)
* [XenPlatform Service](#xenplatform-service)
+ [Create sub-account](#create-sub-account)
+ [Create sub-account using V2](#create-sub-account-using-v2)
+ [Get sub-account by ID](#get-sub-account-by-id)
+ [Update sub-account](#update-sub-account)
+ [Set Callback URL](#set-callback-url)
+ [Create transfers](#create-transfers)
+ [Create fee rules](#create-fee-rules)
- [Card Services](#card-services)
- [Create charge](#create-charge)
- [Capture charge](#capture-charge)
- [Get charge](#get-charge)
- [Create authorization](#create-authorization)
- [Reverse authorization](#reverse-authorization)
- [Create refund](#create-refund)
- [Create promotion](#create-promotion)
- [Virtual Account Services](#virtual-account-services)
- [Get banks with available virtual account service](#get-banks-with-available-virtual-account-service)
- [Create a fixed virtual account](#create-a-fixed-virtual-account)
- [Get details of your fixed virtual account](#get-details-of-your-fixed-virtual-account)
- [Update details of your fixed virtual account](#update-details-of-your-fixed-virtual-account)
- [Get details of a VA payment](#get-details-of-a-va-payment)
- [Disbursement Services](#disbursement-services)
- [Get banks with available disbursement service](#get-banks-with-available-disbursement-service)
- [Create a disbursement](#create-a-disbursement)
- [Create a batch of disbursements](#create-a-batch-of-disbursements)
- [Get a disbursement by ID](#get-a-disbursement-by-id)
- [Invoice Services](#invoice-services)
- [Create an invoice](#create-an-invoice)
- [Get an invoice](#get-an-invoice)
- [Expire an invoice](#expire-an-invoice)
- [Get all invoices](#get-all-invoices)
- [Recurring Payments Services](#recurring-payments-services)
- [Create recurring payment](#create-recurring-payment)
- [Get recurring payment](#get-recurring-payment)
- [Edit recurring payment](#edit-recurring-payment)
- [Stop recurring payment](#stop-recurring-payment)
- [Pause recurring payment](#pause-recurring-payment)
- [Resume recurring payment](#resume-recurring-payment)
- [Recurring Services](#recurring-services)
- [Create recurring schedule](#create-recurring-schedule)
- [Edit recurring schedule](#edit-recurring-schedule)
- [Get recurring schedule](#get-recurring-schedule)
- [Create recurring plan](#create-recurring-plan)
- [Create recurring plan with schedule](#create-recurring-plan-with-schedule)
- [Edit recurring plan](#edit-recurring-plan)
- [Get recurring plan](#get-recurring-plan)
- [Deactivate recurring plan](#deactivate-recurring-plan)
- [Edit recurring cycle](#edit-recurring-cycle)
- [Get recurring cycle](#get-recurring-cycle)
- [Get all recurring cycles](#get-all-recurring-cycles)
- [Cancel recurring cycle](#cancel-recurring-cycle)
- [Payout Services](#payout-services)
- [Create a payout](#create-a-payout)
- [Get a payout](#get-a-payout)
- [Void a payout](#void-a-payout)
- [EWallet Services [SOON TO BE DEPRECATED - MAR 31 2022]](#ewallet-services-soon-to-be-deprecated---mar-31-2022)
- [Create payment](#create-payment)
- [Get payment](#get-payment)
- [Create an ewallet charge](#create-an-ewallet-charge)
- [Get an ewallet charge status](#get-an-ewallet-charge-status)
- [Void an ewallet charge](#void-an-ewallet-charge)
- [Initialize tokenization](#initialize-tokenization)
- [Unlink tokenization](#unlink-tokenization)
- [Create payment method (E-Wallet)](#create-payment-method-e-wallet)
- [Get payment methods by customer ID (E-Wallet)](#get-payment-methods-by-customer-id-e-wallet)
- [Balance Services](#balance-services)
- [Get balance](#get-balance)
- [Retail Outlet Services](#retail-outlet-services)
- [Create fixed payment code](#create-fixed-payment-code)
- [Get fixed payment code](#get-fixed-payment-code)
- [Get payments by fixed payment code ID](#get-payments-by-fixed-payment-code-id)
- [Update fixed payment code](#update-fixed-payment-code)
- [Simulate payment for RO (only in dev mode)](#simulate-payment-for-ro-only-in-dev-mode)
- [QR Code Services](#qr-code-services)
- [Create code](#create-code)
- [Get code](#get-code)
- [Simulate payment for QR (only in dev mode)](#simulate-payment-for-qr-only-in-dev-mode)
- [Get payments by external ID](#get-payments-by-external-id)
- [Customer services](#customer-services)
- [Create customer](#create-customer)
- [Get customer](#get-customer)
- [Get customer by reference ID](#get-customer-by-reference-id)
- [Update customer](#update-customer)
- [Direct debit services](#direct-debit-services)
- [Initialize linked account tokenization](#initialize-linked-account-tokenization)
- [Validate OTP for Linked Account Token](#validate-otp-for-linked-account-token)
- [Retrieve accessible accounts by linked account token](#retrieve-accessible-accounts-by-linked-account-token)
- [Create payment method (Direct Debit)](#create-payment-method-direct-debit)
- [Get payment methods by customer ID (Direct Debit)](#get-payment-methods-by-customer-id-direct-debit)
- [Create direct debit payment](#create-direct-debit-payment)
- [Validate OTP for direct debit payment](#validate-otp-for-direct-debit-payment)
- [Get direct debit payment status by ID](#get-direct-debit-payment-status-by-id)
- [Get direct debit payment status by reference ID](#get-direct-debit-payment-status-by-reference-id)
- [Report Service](#report-service)
- [Generate Report](#generate-report)
- [Get Report](#get-report)
- [Transaction Service](#transaction-service)
- [Get Transaction](#get-transaction)
- [List Transactions](#list-transactions)
- [XenPlatform Service](#xenplatform-service)
- [Create sub-account](#create-sub-account)
- [Create sub-account using V2](#create-sub-account-using-v2)
- [Get sub-account by ID](#get-sub-account-by-id)
- [Update sub-account](#update-sub-account)
- [Set Callback URL](#set-callback-url)
- [Create transfers](#create-transfers)
- [Create fee rules](#create-fee-rules)
- [Contributing](#contributing)

<!-- tocstop -->
Expand Down Expand Up @@ -636,6 +636,7 @@ rp.pausePayment(data: { id: string })
```ts
rp.resumePayment(data: { id: string })
```

### Recurring Services

Instantiate Recurring service using constructor that has been injected with Xendit keys
Expand Down Expand Up @@ -743,6 +744,7 @@ r.createPlan(data: {
```

#### Create recurring plan with schedule

```ts
r.createPlan(data: {
businessId: string;
Expand Down Expand Up @@ -879,7 +881,10 @@ p.getPayout(data: { id: string })
p.voidPayout(data: { id: string })
```

### EWallet Services
### EWallet Services [SOON TO BE DEPRECATED - MAR 31 2022]

Deprecation notice here: <https://docs.xendit.co/api-deprecation/2019-ewallet>
We will continue working on developing the SDK to support the new EWallet service

Instanitiate EWallet service using constructor that has been injected with Xendit keys

Expand Down Expand Up @@ -1440,14 +1445,14 @@ Example: Getting a transaction
```js
t.getTransaction({
id: "txn_123"
id: 'txn_123',
})
.then(res => {
console.log('Get Transaction:', res);
})
.catch(e => {
console.error(`Get Transaction Failed with Error: ${e.message}`);
})
});
```
#### Get Transaction
Expand Down
26 changes: 19 additions & 7 deletions examples/with_async/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ const card = new Card({});

// These IDs should be obtained using Xendit.js
// https://docs.xendit.co/xenpayments/payments-credit-cards-overview/credit-cards-integration-and-testing/collecting-card-details-tokenization/index.html
const tokenID = '5e0461a86113354249aab7ec';
const authID = '5e0461a96113354249aab7ee';
// You can generate sample token/authentication data and replace it below
// https://js.xendit.co/test_tokenize.html
// https://js.xendit.co/test_authenticate.html
const tokenID = '623d394d672113001b79c1a1';
const authID = '623d394d672113001b79c1a2';

function sleepFor(sleepDuration) {
var now = new Date().getTime();
while (new Date().getTime() < now + sleepDuration) {
/* Do nothing */
}
}

(async function() {
try {
Expand All @@ -24,14 +34,16 @@ const authID = '5e0461a96113354249aab7ee';
console.log('charge created:', charge); // eslint-disable-line no-console

const capture = await card.captureCharge({
chargeID: id,
chargeID: charge.id,
amount: 10000,
});
console.log('charge captured:', capture); // eslint-disable-line no-console

sleepFor(3000);

const refund = await card.createRefund({
chargeID: id,
externalID: external_id,
chargeID: charge.id,
externalID: charge.external_id,
amount: 5000,
});
console.log('refund created:', refund); // eslint-disable-line no-console
Expand All @@ -45,8 +57,8 @@ const authID = '5e0461a96113354249aab7ee';
currency: 'IDR',
minOriginalAmount: 25000,
maxDiscountAmount: 5000,
startTime: '2022-03-25T00:00:00.000Z',
endTime: '2022-05-25T00:00:00.000Z',
startTime: '2022-01-25T00:00:00.000Z',
endTime: '2023-01-25T00:00:00.000Z',
});
// eslint-disable-next-line max-len
console.log('promotion created:', promotion); // eslint-disable-line no-console
Expand Down
22 changes: 0 additions & 22 deletions examples/with_async/customer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,6 @@ const c = new Customer({});
});
// eslint-disable-next-line no-console
console.log('retrieved customers', customers);

customer = await c.updateCustomer({
id: customer.id,
description: 'customer dummy',
phoneNumber: '+628987654321',
nationality: 'ID',
dateOfBirth: '2000-06-13',
addresses: [
{
streetLine1: 'jalan raya',
country: 'ID',
city: 'Jakarta',
},
{
streetLine1: 'jalan raya 2',
country: 'ID',
city: 'Jakarta',
},
],
apiVersion: '2020-05-19',
});
console.log('updated customer', customer); //eslint-disable-line no-console
} catch (e) {
console.error(e); // eslint-disable-line no-console
process.exit(1);
Expand Down
1 change: 1 addition & 0 deletions examples/with_async/direct_debit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const c = new Customer({});
middleName: 'middle',
surname: 'surname',
addresses: [],
apiVersion: '2020-05-19',
});

let tokenization = await dd.initializeTokenization({
Expand Down
2 changes: 1 addition & 1 deletion examples/with_async/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const p = new Platform({});
const transfer = await p.createTransfer({
reference: `example+${Date.now().toString()}`,
amount: 1,
sourceUserID: '5df358652ebad7084a70ac6c',
sourceUserID: '623d3cda7012f7478e9a7e69',
destinationUserID: account.user_id,
});

Expand Down
15 changes: 13 additions & 2 deletions examples/with_promises/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ const card = new Card({});

// These IDs should be obtained using Xendit.js
// https://docs.xendit.co/xenpayments/payments-credit-cards-overview/credit-cards-integration-and-testing/collecting-card-details-tokenization/index.html
const tokenID = '5e0461a86113354249aab7ec';
const authID = '5e0461a96113354249aab7ee';
// You can generate sample token/authentication data and replace it below
// https://js.xendit.co/test_tokenize.html
// https://js.xendit.co/test_authenticate.html
const tokenID = '6201f056382ab2001b4bc3d6';
const authID = '6205f8dcca71c0001bc26ae6';

function sleepFor(sleepDuration) {
var now = new Date().getTime();
while (new Date().getTime() < now + sleepDuration) {
/* Do nothing */
}
}

card
.createCharge({
Expand All @@ -29,6 +39,7 @@ card
)
.then(r => {
console.log('charge captured:', r); // eslint-disable-line no-console
sleepFor(3000);
return r;
})
.then(({ id, external_id }) =>
Expand Down
Loading

0 comments on commit 8f75523

Please sign in to comment.