Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xendit-node

Package Overview
Dependencies
Maintainers
2
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xendit-node - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

39

examples/with_async/ewallet.js

@@ -15,3 +15,3 @@ const x = require('../xendit');

// eslint-disable-next-line no-console
console.log('create payment detail:', payment);
console.log('created payment detail:', payment);

@@ -25,2 +25,39 @@ const retrievedPayment = await ew.getPayment({

const charge = await ew.createEWalletCharge({
referenceID: 'test-reference-id',
currency: 'IDR',
amount: 1688,
checkoutMethod: 'ONE_TIME_PAYMENT',
channelCode: 'ID_SHOPEEPAY',
channelProperties: {
successRedirectURL: 'https://yourwebsite.com/order/123',
},
basket: [
{
referenceID: 'basket-product-ref-id',
name: 'product name',
category: 'mechanics',
currency: 'IDR',
price: 50000,
quantity: 5,
type: 'wht',
subCategory: 'evr',
metadata: {
meta: 'data',
},
},
],
metadata: {
meta2: 'data2',
},
});
// eslint-disable-next-line no-console
console.log('created ewallet payment charge:', charge);
const retrievedCharge = await ew.getEWalletChargeStatus({
chargeID: charge.id,
});
// eslint-disable-next-line no-console
console.log('retrieved ewallet payment charge:', retrievedCharge);
process.exit(0);

@@ -27,0 +64,0 @@ } catch (e) {

@@ -13,3 +13,4 @@ const x = require('../xendit');

.then(r => {
console.log('create payment detail:', r); // eslint-disable-line no-console
// eslint-disable-next-line no-console
console.log('created payment detail:', r);
return r;

@@ -24,5 +25,51 @@ })

.then(r => {
console.log('EWallet payment detail:', r); // eslint-disable-line no-console
// eslint-disable-next-line no-console
console.log('EWallet payment detail:', r);
return r;
})
.then(() =>
ew.createEWalletCharge({
referenceID: 'test-reference-id',
currency: 'IDR',
amount: 1688,
checkoutMethod: 'ONE_TIME_PAYMENT',
channelCode: 'ID_SHOPEEPAY',
channelProperties: {
successRedirectURL: 'https://yourwebsite.com/order/123',
},
basket: [
{
referenceID: 'basket-product-ref-id',
name: 'product name',
category: 'mechanics',
currency: 'IDR',
price: 50000,
quantity: 5,
type: 'wht',
subCategory: 'evr',
metadata: {
meta: 'data',
},
},
],
metadata: {
meta2: 'data2',
},
}),
)
.then(r => {
// eslint-disable-next-line no-console
console.log('created ewallet payment charge:', r);
return r;
})
.then(r =>
ew.getEWalletChargeStatus({
chargeID: r.id,
}),
)
.then(r => {
// eslint-disable-next-line no-console
console.log('retrieved ewallet payment charge:', r);
return r;
})
.catch(e => {

@@ -29,0 +76,0 @@ console.error(e); // eslint-disable-line no-console

@@ -20,2 +20,37 @@ const x = require('./xendit.test');

)
.then(() =>
ew.createEWalletCharge({
referenceID: 'test-reference-id',
currency: 'IDR',
amount: 1688,
checkoutMethod: 'ONE_TIME_PAYMENT',
channelCode: 'ID_SHOPEEPAY',
channelProperties: {
successRedirectURL: 'https://yourwebsite.com/order/123',
},
basket: [
{
referenceID: 'basket-product-ref-id',
name: 'product name',
category: 'mechanics',
currency: 'IDR',
price: 50000,
quantity: 5,
type: 'wht',
subCategory: 'evr',
metadata: {
meta: 'data',
},
},
],
metadata: {
meta2: 'data2',
},
}),
)
.then(r =>
ew.getEWalletChargeStatus({
chargeID: r.id,
}),
)
.then(() => {

@@ -22,0 +57,0 @@ // eslint-disable-next-line no-console

2

package.json
{
"name": "xendit-node",
"version": "1.7.0",
"version": "1.8.0",
"description": "NodeJS client for Xendit API",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -54,4 +54,4 @@ # Xendit API Node.js Client

* [EWallet Services](#ewallet-services)
+ [Create an ewallet payment](#create-an-ewallet-payment)
+ [Get an ewallet Payment Status](#get-an-ewallet-payment-status)
+ [Create an ewallet charge](#create-an-ewallet-charge)
+ [Get an ewallet charge status](#get-an-ewallet-charge-status)
* [Balance Services](#balance-services)

@@ -610,12 +610,16 @@ + [Get balance](#get-balance)

Example: Create an ewallet payment
Example: Create an ewallet charge
```js
ew.createPayment({
externalID: 'my-ovo-payment',
amount: 1,
phone: '081234567890',
ewalletType: EWallet.Type.OVO,
ew.createEWalletCharge({
referenceID: 'test-reference-id',
currency: 'IDR',
amount: 50000,
checkoutMethod: 'ONE_TIME_PAYMENT',
channelCode: 'ID_SHOPEEPAY',
channelProperties: {
successRedirectURL: 'https://yourwebsite.com/order/123',
},
}).then(r => {
console.log('create ewallet payment detail:', r);
console.log('created ewallet payment charge:', r);
return r;

@@ -627,28 +631,26 @@ });

#### Create an ewallet payment
#### Create an ewallet charge
```ts
ew.createPayment(data: {
externalID: string;
ew.createEWalletCharge(data: {
referenceID: string;
currency: Currency;
amount: number;
phone?: string;
expirationDate?: Date;
callbackURL?: string;
redirectURL?: string;
items?: Array<{
id: string;
name: string;
price: number;
quantity: number;
}>;
ewalletType: CreateSupportWalletTypes;
checkoutMethod: string;
channelCode?: ChannelCode;
channelProperties?: OVOChannelProps | PaymayaChannelProps | OtherChannelProps;
customerID?: string;
basket?: Basket[];
metadata?: object;
forUserID?: string;
withFeeRule?: string;
})
```
#### Get an ewallet Payment Status
#### Get an ewallet charge status
```ts
ew.getPayment(data: {
externalID: string:
ewalletType: GetSupportWalletTypes;
ew.getEWalletChargeStatus(data: {
chargeID: string;
forUserID?: string;
})

@@ -655,0 +657,0 @@ ```

@@ -21,2 +21,43 @@ import { XenditOptions } from '../xendit_opts';

enum Currency {
IDR = 'IDR',
PHP = 'PHP',
}
enum ChannelCode {
ID_OVO = 'ID_OVO',
ID_DANA = 'ID_DANA',
ID_LINKAJA = 'ID_LINKAJA',
ID_SHOPEEPAY = 'ID_SHOPEEPAY',
PH_PAYMAYA = 'PH_PAYMAYA',
}
interface OVOChannelProps {
mobileNumber: string;
}
interface PaymayaChannelProps {
successRedirectURL: string;
failureRedirectURL: string;
cancelRedirectURL: string;
}
interface OtherChannelProps {
successRedirectURL: string;
}
interface Basket {
referenceID: string;
name: string;
category: string;
currency: string;
price: number;
quantity: number;
type: string;
url?: string;
description?: string;
subCategory?: string;
metadata?: object;
}
export = class EWallet {

@@ -47,2 +88,22 @@ constructor({});

}): Promise<object>;
createEWalletCharge(data: {
referenceID: string;
currency: Currency;
amount: number;
checkoutMethod: string;
channelCode?: ChannelCode;
channelProperties?:
| OVOChannelProps
| PaymayaChannelProps
| OtherChannelProps;
customerID?: string;
basket?: Basket[];
metadata?: object;
forUserID?: string;
withFeeRule?: string;
}): Promise<object>;
getEWalletChargeStatus(data: {
chargeID: string;
forUserID?: string;
}): Promise<object>;
};

@@ -124,2 +124,93 @@ const {

EWallet.prototype.createEWalletCharge = function(data) {
return promWithJsErr((resolve, reject) => {
let compulsoryFields = [
'referenceID',
'currency',
'amount',
'checkoutMethod',
];
Validate.rejectOnMissingFields(compulsoryFields, data, reject);
let headers = {
Authorization: Auth.basicAuthHeader(this.opts.secretKey),
'Content-Type': 'application/json',
};
if (data.forUserID) {
headers['for-user-id'] = data.forUserID;
}
if (data.withFeeRule) {
headers['with-fee-rule'] = data.withFeeRule;
}
fetchWithHTTPErr(`${this.API_ENDPOINT}/charges`, {
method: 'POST',
headers: headers,
body: JSON.stringify({
reference_id: data.referenceID,
currency: data.currency,
amount: data.amount,
checkout_method: data.checkoutMethod,
channel_code: data.channelCode,
channel_properties:
data.channelCode === 'ID_OVO'
? {
mobile_number: data.channelProperties.mobileNumber,
}
: data.channelCode === 'PH_PAYMAYA'
? {
success_redirect_url: data.channelProperties.successRedirectURL,
failure_redirect_url: data.channelProperties.failureRedirectURL,
cancel_redirect_url: data.channelProperties.cancelRedirectURL,
}
: {
success_redirect_url: data.channelProperties.successRedirectURL,
},
customer_id: data.customerID,
basket: data.basket
? data.basket.map(product => ({
reference_id: product.referenceID,
name: product.name,
category: product.category,
currency: product.currency,
price: product.price,
quantity: product.quantity,
type: product.type,
url: product.url,
description: product.description,
sub_category: product.subCategory,
metadata: product.metadata,
}))
: null,
metadata: data.metadata,
}),
})
.then(resolve)
.catch(reject);
});
};
EWallet.prototype.getEWalletChargeStatus = function(data) {
return promWithJsErr((resolve, reject) => {
Validate.rejectOnMissingFields(['chargeID'], data, reject);
let headers = {
Authorization: Auth.basicAuthHeader(this.opts.secretKey),
};
if (data.forUserID) {
headers['for-user-id'] = data.forUserID;
}
fetchWithHTTPErr(`${this.API_ENDPOINT}/charges/${data.chargeID}`, {
method: 'GET',
headers: headers,
})
.then(resolve)
.catch(reject);
});
};
module.exports = EWallet;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc