Skip to content

One-time payment ​

The flow ​

  1. The customer clicks “Pay” on your site.
  2. Your server calls startPayment(). The SDK sends a signed request to SimplePay's /start endpoint.
  3. You redirect the customer to the returned paymentUrl.
  4. The customer pays on SimplePay's page.
  5. SimplePay redirects the customer to your back URL and sends your server a separate IPN.

Start a payment ​

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

const response = await startPayment({
  orderRef: 'order-12',          // required, unique
  total: 1212,                   // required, number or string
  customerEmail: '[email protected]', // required
  currency: 'HUF',               // optional: HUF | HUF_SZEP | EUR | USD, default HUF
  language: 'EN',                // optional, default HU
  method: 'CARD',                // optional: CARD | WIRE, default CARD
  invoice: {                     // optional
    name: 'Test Customer',
    country: 'HU',
    state: 'Budapest',
    city: 'Budapest',
    zip: '1111',
    address: 'Fő utca 1.',
    address2: '2nd floor',       // optional
    phone: '+36301234567',       // optional
  },
}, {
  redirectUrl: 'https://example.com/payment/back', // optional, overrides SIMPLEPAY_REDIRECT_URL
})

// redirect
return Response.redirect(response.paymentUrl, 303)

Parameters ​

FieldTypeRequiredDescription
orderRefstringyesYour order reference. Must be unique within the merchant account.
totalnumber | stringyesAmount to charge. The SDK converts it to a string.
customerEmailstringyesCustomer's email address.
currencyCurrencynoHUF, HUF_SZEP, EUR or USD. Default HUF.
languageLanguagenoPayment page language. Default HU.
method'CARD' | 'WIRE'noCard or wire transfer. Default CARD.
invoiceobjectnoBilling data, see Types.
itemsPaymentItem[]noLine items: ref, title, desc, amount (quantity), price (unit price), tax (VAT %). When sent, SimplePay ignores total and computes the amount from the items.
shippingCostnumbernoShipping cost.
discountnumbernoDiscount amount.
deliveryobjectnoDelivery address (name, company, country, state, city, zip, address, address2, phone).
customerstringnoCustomer name, if it differs from invoice.name.
extraobjectnoYour own extra data.
maySelectEmailbooleannoThe customer may change the email address on the payment page.
maySelectInvoicebooleannoThe customer may enter the billing data on the payment page.
maySelectDeliverystring[]noCountry codes the customer may pick a delivery address in on the payment page, e.g. ['HU', 'AT'].
timeoutDate | stringnoPayment deadline (Date or ISO 8601). Default: now + 30 minutes.
threeDSReqAuthMethod'01' | '02' | '05'noHow you identified the customer: 01 guest, 02 registered with you, 05 registered with a third-party identifier. For one-time payments it is sent only when set.

invoice fields: name, company, fiscalCode (tax number), country, state, city, zip, address, address2, phone. Set at least one of name or company.

Second argument (StartPaymentConfig, optional):

FieldTypeDescription
redirectUrlstringReturn URL for this payment. Must be absolute https in production.
urls{ success, fail, cancel, timeout }A separate return URL per outcome. When given, it is sent instead of url, and neither redirectUrl nor SIMPLEPAY_REDIRECT_URL is needed. In production all four must be absolute https.
ts
await startPayment(paymentData, {
  urls: {
    success: 'https://example.com/payment/success',
    fail: 'https://example.com/payment/fail',
    cancel: 'https://example.com/payment/cancel',
    timeout: 'https://example.com/payment/timeout',
  },
})

The customer arrives at each of them with the same r and s parameters, which getPaymentResponse verifies.

Supported languages: AR, BG, CS, DE, EN, ES, FR, IT, HR, HU, PL, RO, RU, SK, TR, ZH.

Filled in by the SDK ​

  • salt: 16 random bytes, hex
  • merchant: the currency's SIMPLEPAY_MERCHANT_ID_*
  • timeout: the given timeout, or now + 30 minutes, ISO 8601
  • url: redirectUrl or SIMPLEPAY_REDIRECT_URL (when there is no urls)
  • sdkVersion, methods
  • Signature HTTP header: HMAC-SHA384, Base64, over the request body

The response ​

startPayment resolves to a SimplePayResponse:

ts
{
  salt: '...',
  merchant: 'P123456',
  orderRef: 'order-12',
  currency: 'HUF',
  transactionId: '504233881',
  timeout: '2026-12-02T10:30:00+00:00',
  total: '1212',
  paymentUrl: 'https://sandbox.simplepay.hu/pay/pay/pspHU/...',
}

Store transactionId with the order: SimplePay's admin and the IPN identify the payment by it.

SZÉP card ​

ts
await startPayment({
  orderRef: 'order-13',
  total: 5000,
  currency: 'HUF_SZEP',
  customerEmail: '[email protected]',
})

Needs SIMPLEPAY_MERCHANT_ID_HUF_SZEP and SIMPLEPAY_MERCHANT_KEY_HUF_SZEP. The request currency is HUF.

Error handling ​

startPayment throws when:

  • the currency has no keys: Missing SimplePay configuration for HUF
  • the currency is unknown: Unsupported currency: XYZ
  • in production the return URL is missing or not https
  • SimplePay answers with a non-2xx status: SimplePay API error: 500
  • the response signature is missing or wrong: Missing response signature, Invalid response signature
  • SimplePay returns error codes: SimplePay API error: 5321 (several codes are comma-separated)
  • no answer within 30 seconds (TimeoutError)
ts
try {
  const { paymentUrl } = await startPayment(data)
  return redirect(paymentUrl)
} catch (error) {
  console.error('SimplePay payment start failed', error)
  // show an error page; the order stays unpaid
}

What the codes mean: Error codes.

Always compute the amount on the server

Read total from the order on the server, not from data the browser sent.

Next ​

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