# pay-comrade

> Node module for Artpay API.

Latest version **1.0.3** (published 2020-07-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install pay-comrade
pnpm add pay-comrade
yarn add pay-comrade
bun add pay-comrade
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-07-25 |
| First published | 2020-05-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 71.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | totoblabla |
| Maintainers | totoblabla3 |
| Keywords | artpay |

## Links

- npm: https://www.npmjs.com/package/pay-comrade
- npm.io page: https://npm.io/package/pay-comrade

## Dependencies (3)

- [crypto](https://npm.io/package/crypto.md) ^1.0.1
- [@types/url-parse](https://npm.io/package/@types/url-parse.md) ^1.4.3
- [@types/node-fetch](https://npm.io/package/@types/node-fetch.md) ^2.5.7

## Recent versions

- 1.0.3 (latest) — 2020-07-25
- 1.0.2 — 2020-07-24
- 1.0.1 — 2020-07-21
- 1.0.0 — 2020-07-17
- 0.1.1 — 2020-05-29
- 0.1.0 — 2020-05-29

## README

## pay-comrade

Node module for Artpay API.

### Install

``` 
npm i pay-comrade
```

### Import 

``` javascript
import Pay from 'pay-comrade'
const Pay = require('pay-comrade')
```

### Default Settings 

``` javascript
Pay.set(Pay.API_URL, api_url)
Pay.set(Pay.AGREGGATOR_ID, agreggator_id)
Pay.set(Pay.SECRET_1, secret_1)
Pay.set(Pay.SECRET_2, secret_2)
Pay.set(Pay.ALGO_KEY, algo_key)
```

### Аuthorization

AuthUser
``` javascript
const user = await Pay.authUser(uid)
```

SessionStorage
``` javascript
const storage = Pay.getSessionStorage()
let user = storage.findByUID(uid)

if (!user) {
    user = await Pay.authUser(uid)
    storage.put(user)
}
```

Session identification
``` javascript
const storage = Pay.getSessionStorage()
const session = storage.findByAuthId(req.query.eaid)

if (!session) {
    res.send('<h2>403 Forbidden</h2>')
    return
}

const isQueryValid = Pay.verifyQuery(
    req.query.elsgn,
    session.ap_ext_auth_id,
    session.ap_user_ext_id
)
if (!isQueryValid) {
    res.send('<h2>403 Forbidden</h2>')
    return
}

const url = session.getSignUrl()
res.redirect(url)
```

### Session

GetWallets
``` javascript
const wallets = await user.getWallets()
```

SetPrimaryWallet
``` javascript
const isSuccessfully = await user.setPrimaryWallet(ap_wallet_id)
```

GetPrimaryWallet
``` javascript
const primaryWallet = await user.getPrimaryWallet()
```

RemoveWallet
``` javascript
const isRemoved = await user.removeWallet(ap_wallet_id)
```

### RegisterOrder

AutoexecOrder
``` javascript
const order = Pay.createAutoexecOrder(
    '10.00',
    Pay.BYN,
    'Test payment'
)

const result = await Pay.registerAutoexecOrder(
    uid,
    primaryWallet.ap_wallet_id,
    order
)
```

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