# shopier-api

> Shopier Payment Api

Latest version **1.1.4** (published 2024-01-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install shopier-api
pnpm add shopier-api
yarn add shopier-api
bun add shopier-api
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2024-01-09 |
| First published | 2022-06-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 35.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Fatih Akdogan |
| Maintainers | 0x178 |
| Keywords | shopier, payment, api, shopier api, shopier payment api |

## Links

- npm: https://www.npmjs.com/package/shopier-api
- Repository: https://github.com/0x178F/shopier-api
- Homepage: https://github.com/0x178F/shopier-api#readme
- Issues: https://github.com/0x178F/shopier-api/issues
- npm.io page: https://npm.io/package/shopier-api

## Recent versions

- 1.1.4 (latest) — 2024-01-09
- 1.1.3 — 2023-09-29
- 1.0.1 — 2022-06-10

## README

# Shopier Api

## Usage:

```bash
npm install shopier-api
```

#### Create an instance of the Shopier class.

```javascript
import { Shopier } from 'shopier-api';      //CommonJS
const { Shopier } = require('shopier-api')  //ES


const shopier = new Shopier('apiKey', 'apiSecret');
```

#### Set the buyer's information.

```javascript
shopier.setBuyer({
  buyer_id_nr: '010101',
  product_name: 'Balance',
  buyer_name: 'Fatih',
  buyer_surname: 'Akdoğan',
  buyer_email: 'mail@mail.com',
  buyer_phone: '05555555555'
});
```

#### Set buyer's billing address.

```javascript
shopier.setOrderBilling({
  billing_address: 'Kennedy Caddesi No:2592',
  billing_city: 'Istanbul',
  billing_country: 'Türkiye',
  billing_postcode: '34000'
});
```

#### Set buyer's shipping address.

```javascript
shopier.setOrderShipping({
  shipping_address: 'Kennedy Caddesi No:2592',
  shipping_city: 'Istanbul',
  shipping_country: 'Türkiye',
  shipping_postcode: '34000'
});
```

#### How much will the customer pay?

#### For 15₺:

```javascript
const paymentPage = shopier.generatePaymentHTML(15);
```

> This will return the purchase form as html.

#### If we give an example for Express JS:

```javascript
app.get('/pay', (req, res) => {
  res.end(paymentPage);
});
```

> Now that we have render the html, a callback will be required after checkout.

```javascript
app.post('/callback', (req, res) => {
  const callback = shopier.callback(req.body, 'apiSecret');
});
```

#### If payment was successful, it will return order_id, payment_id, installment.

```
{ order_id: 10592, payment_id: 413449826, installment: 0 }
```

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