# tinkoff-merchant-api

> Tinkoff Merchant API

Latest version **3.1.0** (published 2018-05-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install tinkoff-merchant-api
pnpm add tinkoff-merchant-api
yarn add tinkoff-merchant-api
bun add tinkoff-merchant-api
```

## 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 | 3.1.0 |
| Published | 2018-05-29 |
| First published | 2017-01-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 17 |
| Maintainers | rakchaev |

## Links

- npm: https://www.npmjs.com/package/tinkoff-merchant-api
- Repository: https://github.com/rakchaev/tinkoff-merchant-api
- Homepage: https://github.com/rakchaev/tinkoff-merchant-api#readme
- Issues: https://github.com/rakchaev/tinkoff-merchant-api/issues
- npm.io page: https://npm.io/package/tinkoff-merchant-api

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^2.6.8
- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [request](https://npm.io/package/request.md) ^2.79.0

## Recent versions

- 3.1.0 (latest) — 2018-05-29
- 3.0.0 — 2017-07-15
- 2.0.1 — 2017-06-15
- 2.0.0 — 2017-05-08
- 1.1.1 — 2017-01-22
- 1.1.0 — 2017-01-14
- 1.0.0 — 2017-01-06

## README

# Tinkoff Merchant API

Node.js implementation of [Tinkoff Merchant API v2](https://oplata.tinkoff.ru/documentation/).

## Installation

```
npm i tinkoff-merchant-api
```

## How to use

```js
const TinkoffMerchantAPI = require('tinkoff-merchant-api');
const bankApi = new TinkoffMerchantAPI(process.env.TINKOFF_TERMINAL_KEY, process.env.TINKOFF_SECRET_KEY);

// Pass params for API method except TerminalKey and Token (they will be added automatically)
bankApi.init({
    Amount: '200000',
    OrderId: '123',
    DATA: {
        Email: 'user@ya.ru',
        Phone: '+71234567890'
    },
    Receipt: {
        Email: 'user@ya.ru',
        Phone: '+71234567890',
        Taxation: 'osn',
        Items: [
            {
                Name: 'Наименование товара 1',
                Price: 100.00,
                Quantity: 1.00,
                Amount: 100.00,
                Tax: 'vat10',
                Ean13: '0123456789'
            },
            {
                Name: 'Наименование товара 2',
                Price: 200.00,
                Quantity: 2.00,
                Amount: 400.00,
                Tax: 'vat18'
            }
        ]
    }
}).then(res => {
    console.log(res)
}).catch(err => {
    console.log(err.stack)
});
```

You can use another implemented [methods](index.js).

Also you can check if notification request is valid

```js
// Use Express req object or your own express-like object with ip and request params:
// const req = {
//     ip: '91.194.226.1',
//     body: {
//         "Amount":"100000",
//         "CardId":"751596",
//         "ErrorCode":"0",
//         "OrderId":"1",
//         "Pan":"430000******0777",
//         "PaymentId":"1671111",
//         "RebillId":"",
//         "Status":"AUTHORIZED",
//         "Success":"true",
//         "TerminalKey":"1234567890123",
//         "Token":"239ea18cfd5dfcc72423778c0634bcf90987af8600fc835b8f7d7657cc95c69b"
//     }
// };
const isValidNotificationRequest = bankApi.checkNotificationRequest(req).success;
console.log(isValidNotificationRequest);
```
### Debug
```
DEBUG=tinkoff-merchant
```
Also see [debug](https://www.npmjs.com/package/debug) module

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