# nodejs-payment

> nodejs payment lib

Latest version **1.0.3** (published 2020-03-10) · UNLICENSED license · 0 weekly downloads

## Install

```sh
npm install nodejs-payment
pnpm add nodejs-payment
yarn add nodejs-payment
bun add nodejs-payment
```

## 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.3 |
| Published | 2020-03-10 |
| First published | 2020-03-10 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10 |
| Dependencies | 2 |
| Unpacked size | 19.4 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | liangmayong |
| Maintainers | liangmayong |
| Keywords | nodejs-payment |

## Links

- npm: https://www.npmjs.com/package/nodejs-payment
- Repository: https://github.com/whoopschat/nodejs-payment
- Homepage: https://github.com/whoopschat/nodejs-payment#readme
- Issues: https://github.com/whoopschat/nodejs-payment/issues
- npm.io page: https://npm.io/package/nodejs-payment

## Dependencies (2)

- [xml2js](https://npm.io/package/xml2js.md) 0.4.19
- [request](https://npm.io/package/request.md) ^2.88.0

## Recent versions

- 1.0.3 (latest) — 2020-03-10

## README

# nodejs-payment
> payment nodejs library

## Install
```
> npm install nodejs-payment --save-dev
```

## Usage

### app.js
```js
// app.js
const config = require('./config.js');
const Payment = require('nodejs-payment');
let type = "wepay"; // or "alipay"
let client_ip = "127.0.0.1";
let order_id = Date.now();
let title = "payment test";
let amount = 1;
// create payment url
new Payment(config).webPay(type, order_id, title, amount, client_ip).then(url => {
    // open this url go pay
});
```

### config.js
```js
// config.js
'use strict';

module.exports = {
    alipay: {
        sandbox: false,
        appId: "--appId--",
        publicKey: "--publicKey--",
        privateKey: "--privateKey--",
        notifyUrl: "--notifyUrl--",
        returnUrl: "--returnUrl--",
        signType: "RSA2"
    },
    wepay: {
        mchId: "--mchId--",
        appId: "--appId--",
        appKey: "--appKey--",
        notifyUrl: "--notifyUrl--",
        redirectUrl: "--redirectUrl--",
        certPem: "--publicKey--",
        keyPem: "--privateKey--"
    }
}
```


## Features

Api | Status
-|-
`webPay(out_trade_id, title, amount, client_ip)` | ✔ |
`queryPay(trade_id)` | ✔  |
`transfers(trans_trade_id, account, realname, title, amount, client_ip)` | ✔ |
`queryTransfers(trans_trade_id)` | ✔ |

## Docs

[wepay docs](https://pay.weixin.qq.com/wiki/doc/api/index.html)

[alipay docs](https://open.alipay.com/developmentDocument.htm)

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