Skip to content

Getting started ​

simplepay-js-sdk is a small TypeScript package with no runtime dependencies. It starts SimplePay payments from a Node.js app and verifies the back-URL redirect and the IPN notification.

Unofficial SDK

This package is a community project, not a SimplePay Zrt. product. SimplePay's rules and API behaviour are described in the official documentation.

Requirements ​

  • Node.js 20 or newer (the package uses the built-in fetch and AbortSignal.timeout)
  • A SimplePay merchant account. A sandbox account is enough for testing.
  • An ESM project (import). The package ships as an ES module only.

1. Install ​

bash
npm install simplepay-js-sdk
bash
yarn add simplepay-js-sdk
bash
pnpm add simplepay-js-sdk

2. Set up your keys ​

In the SimplePay merchant admin each account (one per currency) has a merchant ID and a secret key. The SDK reads them from environment variables named after the currency:

bash
SIMPLEPAY_MERCHANT_ID_HUF=P123456
SIMPLEPAY_MERCHANT_KEY_HUF=your-secret-key
SIMPLEPAY_REDIRECT_URL=https://example.com/payment/back
# SIMPLEPAY_PRODUCTION=true   # live only!

Until SIMPLEPAY_PRODUCTION is true, every call goes to the sandbox (https://sandbox.simplepay.hu/payment/v2). All variables: Configuration.

Keep the secret key on the server

Anyone with a SIMPLEPAY_MERCHANT_KEY_* value can send signed requests in your name. Keep it out of the browser, git and logs.

3. First sandbox payment ​

ts
import { startPayment } from 'simplepay-js-sdk'

const response = await startPayment({
  orderRef: `order-${Date.now()}`, // unique order reference
  total: 1212,
  customerEmail: '[email protected]',
  invoice: {
    name: 'Test Customer',
    country: 'HU',
    state: 'Budapest',
    city: 'Budapest',
    zip: '1111',
    address: 'Fő utca 1.',
  },
})

console.log(response.paymentUrl)

Open paymentUrl and pay with a sandbox test card, for example 4908 3660 9990 0425, expiry 12/28, CVC 123.

4. The three endpoints ​

A complete SimplePay integration needs three server endpoints:

EndpointWhat it doesGuide
Start paymentstartPayment(), then redirect to paymentUrlOne-time payment
Back URLgetPaymentResponse(r, s) when the customer returnsBack URL
IPNhandleIpnRequest() for SimplePay's server-to-server notificationIPN

Mark the order as paid from the IPN, not from the back URL: the customer may close the browser before returning.

Next ​

Unofficial community SDK. Not affiliated with or endorsed by SimplePay Zrt. MIT License.