# icpay

> ICPay SDK for nodejs

Latest version **1.0.6** (published 2018-01-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install icpay
pnpm add icpay
yarn add icpay
bun add icpay
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2018-01-19 |
| First published | 2017-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| Author | thangn.1411@gmail.com |
| Maintainers | icpay |
| Keywords | ICPay, SDK |

## Links

- npm: https://www.npmjs.com/package/icpay
- Repository: http://gitlab.icheck.com.vn/thangnguyen/icpay-node
- npm.io page: https://npm.io/package/icpay

## Dependencies (4)

- [qs](https://npm.io/package/qs.md) ~6.0.4
- [bluebird](https://npm.io/package/bluebird.md) ^2.10.2
- [object-assign](https://npm.io/package/object-assign.md) ^4.1.0
- [lodash.isplainobject](https://npm.io/package/lodash.isplainobject.md) ^4.0.6

## Recent versions

- 1.0.6 (latest) — 2018-01-19
- 1.0.5 — 2017-08-23
- 1.0.4 — 2017-08-22
- 1.0.2 — 2017-08-12
- 1.0.0 — 2017-08-10

## README

## Installation

Install the package with:

    npm install icpay --save

## Usage


```js
var icpay = require('icpay')(appId, secretKey, dev);
```
```js
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
```js
icpay.refunds.create({
    charge_id: "ch_id",
    amount: 5000
}).then(charge => {
    //asynchronously called
}).catch(err => {
    //asynchronously called
});
```
Create transfer
```js
icpay.transfers.create({
    recipient: "ac_id",
    amount: 5000,
}).then(charge => {
    //asynchronously called
}).catch(err => {
    //asynchronously called
});
```
Balance history
```js
icpay.balance.listTransactions({
    limit: 10,
}).then(charge => {
    //asynchronously called
}).catch(err => {
    //asynchronously called
});
```

### Error handling
```js
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)`

---
_Source: https://npm.io/package/icpay · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
