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:
| Currency | Merchant ID | Secret key |
|---|---|---|
HUF (default) | SIMPLEPAY_MERCHANT_ID_HUF | SIMPLEPAY_MERCHANT_KEY_HUF |
HUF_SZEP (SZÉP card) | SIMPLEPAY_MERCHANT_ID_HUF_SZEP | SIMPLEPAY_MERCHANT_KEY_HUF_SZEP |
EUR | SIMPLEPAY_MERCHANT_ID_EUR | SIMPLEPAY_MERCHANT_KEY_EUR |
USD | SIMPLEPAY_MERCHANT_ID_USD | SIMPLEPAY_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
SIMPLEPAY_PRODUCTION=true- If the value is exactly
true, calls go tohttps://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
SIMPLEPAY_REDIRECT_URL=https://example.com/payment/backSimplePay 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.
| Environment | When not set | When not https |
|---|---|---|
| Sandbox | uses the placeholder http://url.to.redirect | accepted |
Production (SIMPLEPAY_PRODUCTION=true) | throws | throws |
In production the error is SimplePay return url must be absolute https in production.
Logging
SIMPLEPAY_LOGGER=trueTurns 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 (
timeoutfield) is valid for 30 minutes from the start of the payment.
Example .env
# 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=trueAll variables in one table: Environment variables.
