https://github.com/smartpay-co/sdk-node
https://github.com/smartpay-co/sdk-node
node-js smartpay smartpay-sdk
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/smartpay-co/sdk-node
- Owner: smartpay-co
- License: mit
- Created: 2021-08-03T02:39:34.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-06-17T12:25:38.000Z (almost 2 years ago)
- Last Synced: 2025-10-18T01:13:16.196Z (8 months ago)
- Topics: node-js, smartpay, smartpay-sdk
- Language: TypeScript
- Homepage: https://smartpay.co
- Size: 409 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# 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('', {
publicKey: '',
});
```
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.