Skip to content

Configuration ​

The SDK has no configuration object: it reads everything from environment variables, on every call. The same code runs in sandbox and production; only the .env differs.

Keys per currency ​

SimplePay gives you a separate merchant account per currency. The variable name contains the currency code:

CurrencyMerchant IDSecret key
HUF (default)SIMPLEPAY_MERCHANT_ID_HUFSIMPLEPAY_MERCHANT_KEY_HUF
HUF_SZEP (SZÉP card)SIMPLEPAY_MERCHANT_ID_HUF_SZEPSIMPLEPAY_MERCHANT_KEY_HUF_SZEP
EURSIMPLEPAY_MERCHANT_ID_EURSIMPLEPAY_MERCHANT_KEY_EUR
USDSIMPLEPAY_MERCHANT_ID_USDSIMPLEPAY_MERCHANT_KEY_USD

Only set the currencies you use. If a payment starts in a currency with no keys, the SDK throws Missing SimplePay configuration for <currency>.

HUF_SZEP is a separate account but is sent to SimplePay as HUF: the SDK strips the _SZEP suffix in the request and signs with the SZÉP account's key.

The back URL is matched by merchant ID

getPaymentResponse looks up which SIMPLEPAY_MERCHANT_ID_* variable holds the returned merchant ID and verifies with that currency's key. Don't use the same merchant ID for two currencies.

Sandbox and production ​

bash
SIMPLEPAY_PRODUCTION=true
  • If the value is exactly true, calls go to https://secure.simplepay.hu/payment/v2.
  • Anything else (unset, false, 1 …) uses the sandbox: https://sandbox.simplepay.hu/payment/v2.

Sandbox and live accounts have different keys. Swap the keys when you go live.

Return URL ​

bash
SIMPLEPAY_REDIRECT_URL=https://example.com/payment/back

SimplePay sends the customer back here with the r and s parameters. For one-time and recurring payments, token charges and Google Pay you can also pass a per-payment redirectUrl option, which overrides the variable. The urls option of startPayment and startRecurringPayment sets a separate address per outcome; then the variable is not needed.

EnvironmentWhen not setWhen not https
Sandboxuses the placeholder http://url.to.redirectaccepted
Production (SIMPLEPAY_PRODUCTION=true)throwsthrows

In production the error is SimplePay return url must be absolute https in production.

Logging ​

bash
SIMPLEPAY_LOGGER=true

Turns on the SDK's debug log (console.log): function name, API URL, order reference, HTTP status and error codes. It never logs the secret key or the customer's email. Turn it off in production.

Timeouts ​

Built in, not configurable:

  • Every SimplePay call is aborted after 30 seconds (AbortSignal.timeout).
  • The payment page (timeout field) is valid for 30 minutes from the start of the payment.

Example .env ​

bash
# sandbox
SIMPLEPAY_MERCHANT_ID_HUF=P123456
SIMPLEPAY_MERCHANT_KEY_HUF=sandbox-secret-key
SIMPLEPAY_MERCHANT_ID_HUF_SZEP=P123457
SIMPLEPAY_MERCHANT_KEY_HUF_SZEP=sandbox-szep-key
SIMPLEPAY_REDIRECT_URL=https://example.com/payment/back
SIMPLEPAY_LOGGER=true

All variables in one table: Environment variables.

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