1.0.6 • Published 8 years ago
icpay v1.0.6
Installation
Install the package with:
npm install icpay --saveUsage
var icpay = require('icpay')(appId, secretKey, dev);var icpay = require('icpay')("demo", "demo", true);
icpay.charges.create({
description: "Pay for demo@gmai.com",
amount: 5000,
customer_id: "i-1405656951",
destination: {
account: "i-100000",
amount: 4600,
},
metadata: {
order_id: "1",
}
}).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
listTransactions(params)get(id)getTransaction(id)
- payouts
list(params)get(id)create(params)
- refunds
list(params)get(id)create(params)