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
fetchandAbortSignal.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
npm install simplepay-js-sdkyarn add simplepay-js-sdkpnpm add simplepay-js-sdk2. 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:
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
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:
| Endpoint | What it does | Guide |
|---|---|---|
| Start payment | startPayment(), then redirect to paymentUrl | One-time payment |
| Back URL | getPaymentResponse(r, s) when the customer returns | Back URL |
| IPN | handleIpnRequest() for SimplePay's server-to-server notification | IPN |
Mark the order as paid from the IPN, not from the back URL: the customer may close the browser before returning.
Next
- Framework recipes: Nuxt / Nitro, Express, Next.js
- API reference
- Go-live checklist
