1.0.0 • Published 7 years ago
icpay-node v1.0.0
Installation
Install the package with:
npm install icpay --save
Usage
var icpay = require('icpay')(appId, secretKey, dev);
icpay.charges.create({
description: "Nap tien su dung dich vu affiliate",
amount: 5000,
customer_id: "i-1405656951"
}).then(charge => {
//asynchronously called
}).catch(err => {
//asynchronously called
});
Create refund
icpay.refunds.create({
charge_id: "ch_id",
amount: 5000,
}).then(charge => {
//asynchronously called
}).catch(err => {
//asynchronously called
});
Create transfer
icpay.transfers.create({
recipient: "ac_id",
amount: 5000,
}).then(charge => {
//asynchronously called
}).catch(err => {
//asynchronously called
});
Balance history
icpay.balance.listTransactions({
limit: 10,
}).then(charge => {
//asynchronously called
}).catch(err => {
//asynchronously called
});
Error handling
switch (err.type) {
case 'IcpayCardError':
// A declined card error
err.message; // => e.g. "Your card's expiration year is invalid."
break;
case 'IcpayInvalidRequestError':
// Invalid parameters were supplied to Icpay's API
break;
case 'IcpayAPIError':
// An error occurred internally with Icpay's API
break;
case 'IcpayConnectionError':
// Some kind of error occurred during the HTTPS communication
break;
case 'IcpayAuthenticationError':
// You probably used an incorrect API key
break;
case 'IcpayRateLimitError':
// Too many requests hit the API too quickly
break;
}
Available resources and methods
charges
list(params)
get(id)
create(params)
transfers
list(params)
get(id)
create(params)
- balance-transactions
list(params)
get(id)
create(params)
- payouts
list(params)
get(id)
create(params)
- refunds
list(params)
get(id)
create(params)
1.0.0
7 years ago