@0xpay/sdk
v0.0.12
Published
SDK for 0xPay API
Downloads
467
Readme
@0xpay/sdk
Node.js 0xPay integration package
Overview
SDK for 0xPay Merchant API which allows merchants to accept and manage payments on various blockchain networks and fiat assets via integration options.
Getting started
Prerequisites
To start using 0xPay SDK you need to register your personal account and then create merchant at 0xPay to obtain your merchant id and private key and provide it to SDK.
Installation
// NPM
npm install @0xpay/sdk
// Yarn
yarn add @0xpay/sdk
Create instance
import { XPay } from '@0xpay/sdk'
const MERCHANT_ID = 'your-merchant-id'
const MERCHANT_PRIVATE_KEY = 'your-merchant-private-key'
// Create XPay instance
const xpay = new XPay(MERCHANT_ID, MERCHANT_PRIVATE_KEY)
Get available crypto assets
import { XPay } from '@0xpay/sdk'
import express from 'express'
// Create XPay instance
const xpay = new XPay(...)
express().post('/ipn', express.raw(), (req, res) => {
const validationError = xpay.validateWebhookRequest({ ...req, ...req.headers })
if (validationError) throw new Error(validationError.description)
// processing your ipn...
res.send('OK')
})