---
url: https://simplepay.webmania.cc/en/guide/testing.md
description: >-
  SimplePay sandbox test cards (successful, failed, 3DS, SZÉP, card
  registration), testing the IPN locally, and using simplepay-js-sdk in unit
  tests.
---

# Testing (sandbox)

Until `SIMPLEPAY_PRODUCTION` is `true`, the SDK calls the SimplePay sandbox (`https://sandbox.simplepay.hu/payment/v2`). The sandbox has its own merchant account and keys.

## Test cards

Source: [SimplePay – test card numbers](https://docs.simplepay.hu/hu/developer-tools/testing/test-card-numbers). Every card uses expiry **12/28** and CVC **123**; any cardholder name works.

| Card number | Type | Result |
|---|---|---|
| `4908 3660 9990 0425` | Visa | Successful payment |
| `5587 4020 0001 2011` | Mastercard | Successful payment |
| `4111 1111 1111 1111` | Visa | Failed payment |
| `4000 0010 0000 0042` | Visa | 3DS challenge |
| `6101 3242 9669 0851` | SZÉP | Successful SZÉP card payment |
| `6101 3242 1723 7212` | SZÉP | Failed SZÉP card payment |
| `5437 5884 9903 4193` | Mastercard | Card registration succeeds, payment fails |
| `6757 6192 9705 7001` | Maestro | Card registration fails, payment succeeds |

The 3DS card shows a simulated challenge page: code `000` succeeds, anything else fails. No real SMS or push notification is sent.

::: tip Check the source
SimplePay can change the test cards at any time. If one stops working, check the official page.
:::

## What to try

* \[ ] Successful payment → `SUCCESS` on the back URL, `FINISHED` IPN, order paid
* \[ ] Failed payment → `FAIL`, the customer sees the transaction ID
* \[ ] Cancel on the payment page → `CANCEL`
* \[ ] 3DS card with `000` and with a wrong code
* \[ ] SZÉP card (if you use it)
* \[ ] Same IPN twice → the order is fulfilled once
* \[ ] IPN with a bad `Signature` header → 400, order unchanged
* \[ ] Recurring: registration, token charge, card removal

## IPN locally

The sandbox only sends IPNs to a public address. For local development use a tunnel (`cloudflared`, `ngrok` or similar) and set the resulting `https` address as the IPN URL in the sandbox merchant admin.

## Unit tests

The SDK uses the global `fetch`, so replace that in tests. The SDK's own tests do the same (Vitest):

```ts
import { vi, it, expect } from 'vitest'
import { startPayment, generateSignature } from 'simplepay-js-sdk'

it('starts a payment', async () => {
  process.env.SIMPLEPAY_MERCHANT_ID_HUF = 'testId'
  process.env.SIMPLEPAY_MERCHANT_KEY_HUF = 'testKey'

  const body = JSON.stringify({ transactionId: '123', paymentUrl: 'https://sandbox.simplepay.hu/pay/x' })
  global.fetch = vi.fn().mockResolvedValue({
    ok: true,
    headers: { get: () => generateSignature(body, 'testKey') }, // validly signed response
    text: async () => body,
  }) as unknown as typeof fetch

  const response = await startPayment({ orderRef: 'T1', total: 100, customerEmail: 'a@b.com' })
  expect(response.paymentUrl).toContain('sandbox')
})
```

To test an IPN endpoint, put `generateSignature(ipnBody, key)` in the `Signature` header.
