# @smartpay/sdk-node

> Smartpay SDK NodeJS

Latest version **0.9.1** (published 2023-02-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @smartpay/sdk-node
pnpm add @smartpay/sdk-node
yarn add @smartpay/sdk-node
bun add @smartpay/sdk-node
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.1 |
| Published | 2023-02-22 |
| First published | 2021-09-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 6 |
| Unpacked size | 284.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Smartpay Co. Ltd. |
| Maintainers | nnabinh, othree, linmic |
| Keywords | bnpl, smartpay, sdk, node |

## Links

- npm: https://www.npmjs.com/package/@smartpay/sdk-node
- Repository: https://github.com/smartpay-co/sdk-node
- Homepage: https://github.com/smartpay-co/sdk-node#readme
- Issues: https://github.com/smartpay-co/sdk-node/issues
- npm.io page: https://npm.io/package/@smartpay/sdk-node

## Dependencies (6)

- [jtd](https://npm.io/package/jtd.md) ^0.1.1
- [base-x](https://npm.io/package/base-x.md) ^4.0.0
- [fetch-retry](https://npm.io/package/fetch-retry.md) ^5.0.2
- [query-string](https://npm.io/package/query-string.md) ^7.0.1
- [randomstring](https://npm.io/package/randomstring.md) ^1.2.2
- [isomorphic-unfetch](https://npm.io/package/isomorphic-unfetch.md) ^3.1.0

## 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

- 0.9.1 (latest) — 2023-02-22
- 0.9.0 — 2022-12-21
- 0.8.0 — 2022-09-22
- 0.7.0 — 2022-06-13
- 0.6.0 — 2022-04-18
- 0.5.1 — 2022-03-10
- 0.5.0 — 2022-03-10
- 0.4.0 — 2022-02-16
- 0.3.2 — 2022-02-11
- 0.3.1 — 2022-02-11
- 0.3.0 — 2022-01-24
- 0.2.1 — 2022-01-12
- 0.2.0 — 2021-11-26
- 0.1.8 — 2021-11-26
- 0.1.7 — 2021-10-27
- … 16 more at https://npm.io/package/@smartpay/sdk-node/versions

## README

<div id="top"></div>

<br />
<div align="center">
  <a href="https://github.com/smartpay-co/sdk-node">
		<picture>
			<source media="(prefers-color-scheme: dark)" srcset="https://assets.smartpay.co/logo/banner/smartpay-logo-dark.png" />
			<source media="(prefers-color-scheme: light)" srcset="https://assets.smartpay.co/logo/banner/smartpay-logo.png" />
			<img alt="Smartpay" src="https://assets.smartpay.co/logo/banner/smartpay-logo.png" style="width: 797px;" />
		</picture>
  </a>

  <p align="center">
    <a href="https://docs.smartpay.co/"><strong>Explore the docs »</strong></a>
    <br />
    <br />
    <a href="https://github.com/smartpay-co/sdk-node/issues">Report Bug</a>
    ·
    <a href="https://github.com/smartpay-co/sdk-node/issues">Request Feature</a>
  </p>
</div>

# Smartpay Nodejs SDK

The Smartpay Nodejs SDK offers easy access to Smartpay API from applications written in Nodejs.

## Prerequisites

Nodejs v12+

## Installation

```shell
npm install --save @smartpay/sdk-node
# or
yarn add @smartpay/sdk-node
```

## Usage

The package needs to be configured with your own API keys, you can find them on your [dashboard](https://dashboard.smartpay.co/settings/credentials).

```javascript
const Smartpay = require('@smartpay/sdk-node').default;

const smartpay = new Smartpay('<YOUR_SECRET_KEY>', {
  publicKey: '<YOUR_PUBLIC_KEY>',
});
```

If you would like to know how Smartpay payment works, please see the [payment flow](https://docs.smartpay.co/#payment_flow) for more details.

### Create Checkout session

```javascript
(async () => {
  const payload = {
    items: [
      {
        name: 'レブロン 18 LOW',
        amount: 250,
        currency: 'JPY',
        quantity: 1,
      },
    ],

    shipping: {
      line1: 'line1',
      locality: 'locality',
      postalCode: '123',
      country: 'JP',
    },

    // Your internal reference of the order
    reference: 'order_ref_1234567',

    // Callback URLs
    successUrl: 'https://docs.smartpay.co/example-pages/checkout-successful',
    cancelUrl: 'https://docs.smartpay.co/example-pages/checkout-canceled',

    test: true,
  };

  const session = await smartpay.createCheckoutSession(payload);
})();
```

The shape of checkout session payload is described in the [docuement](https://en.docs.smartpay.co/reference/create-a-checkout-session).

### To retreive the session URL

```javascript
const sessionURL = smartpay.getSessionURL(session);
```

We also prepare a more [real-world example](https://github.com/smartpay-co/integration-examples/blob/main/server/node/server.js) for you to refer to.

## Reference

Please check the [reference](docs/Reference.md) document.

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