# node-paytr

> A node package for PayTR payment gateway

Latest version **1.1.0** (published 2022-10-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install node-paytr
pnpm add node-paytr
yarn add node-paytr
bun add node-paytr
```

## 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.1.0 |
| Published | 2022-10-14 |
| First published | 2022-10-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 27.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | sametcodes |
| Maintainers | sametcodes |
| Keywords | paytr, node, payment, gateway |

## Links

- npm: https://www.npmjs.com/package/node-paytr
- Repository: https://github.com/sametcodes/node-paytr
- Homepage: https://github.com/sametcodes/node-paytr#readme
- Issues: https://github.com/sametcodes/node-paytr/issues
- npm.io page: https://npm.io/package/node-paytr

## Dependencies (3)

- [jssha](https://npm.io/package/jssha.md) ^2.3.1
- [form-data](https://npm.io/package/form-data.md) ^4.0.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.7

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2022-10-14
- 1.0.91 — 2022-10-12

## README

## node-paytr

> It's not an official package of PayTR.

This package provides to get an iframe token for your payment gateway and receive the POST requests from PayTR to your callback URL.

### Install

```
npm install node-paytr
```

### Pseudo-code

```javascript
import PayTR from 'node-paytr';
import express from 'express';

const app = express();
app.use(express.json())

const paytr = new PayTR(merchant_params);

app.post('/get_token', (req, res) => {
    const user_params = req.body;
    res.send(paytr.getToken(user_params));
})

app.post('/callback', (req, res) => {
  paytr.getPost(req.body, ({merchant_oid, status}) => {
    // do your db lookups and updates here
  });
  res.send("OK"); // this line notifies PayTR that you got the callback data
})
```

### Parameters

Take a look to the official PayTR docs to get more details about parameters and [type declarations](/dist/index.d.ts).

| Mercant | type
| --------          | -----------
| merchant_id       | string
| merchant_key      | string
| merchant_salt     | string
| debug_on          | 1 or 0 as number
| no_installment    | 1 or 0 as number
| max_installment   | number
| timeout_limit     | number
| test_mode         | 1 or 0 as number
| lang              | string

| Transaction | type
| --------       | -----------
| user_ip        | string
| user_name      | string
| user_address   | string
| user_phone     | string
| payment_amount | integer
| user_basket    | array
| email          | string
| merchant_oid   | string
| currency       | string
| merchant_ok_url   | string
| merchant_fail_url | string

| POST Callback Data | type
| --------       | -----------
| body           | object
| callback       | function

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