---
url: https://simplepay.webmania.cc/en/guide/one-time-payment.md
description: >-
  Start a SimplePay one-time card or wire payment from Node.js with
  startPayment. Parameters, SZÉP card, currency, language, invoice, items,
  delivery, timeout, response and error handling.
---

# 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](./back-url) and sends your server a separate [IPN](./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: 'customer@example.com', // 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

| Field | Type | Required | Description |
|---|---|---|---|
| `orderRef` | `string` | yes | Your order reference. Must be unique within the merchant account. |
| `total` | `number \| string` | yes | Amount to charge. The SDK converts it to a string. |
| `customerEmail` | `string` | yes | Customer's email address. |
| `currency` | `Currency` | no | `HUF`, `HUF_SZEP`, `EUR` or `USD`. Default `HUF`. |
| `language` | `Language` | no | Payment page language. Default `HU`. |
| `method` | `'CARD' \| 'WIRE'` | no | Card or wire transfer. Default `CARD`. |
| `invoice` | object | no | Billing data, see [Types](../reference/types#paymentdata). |
| `items` | `PaymentItem[]` | no | Line items: `ref`, `title`, `desc`, `amount` (quantity), `price` (unit price), `tax` (VAT %). When sent, SimplePay **ignores `total`** and computes the amount from the items. |
| `shippingCost` | `number` | no | Shipping cost. |
| `discount` | `number` | no | Discount amount. |
| `delivery` | object | no | Delivery address (`name`, `company`, `country`, `state`, `city`, `zip`, `address`, `address2`, `phone`). |
| `customer` | `string` | no | Customer name, if it differs from `invoice.name`. |
| `extra` | object | no | Your own extra data. |
| `maySelectEmail` | `boolean` | no | The customer may change the email address on the payment page. |
| `maySelectInvoice` | `boolean` | no | The customer may enter the billing data on the payment page. |
| `maySelectDelivery` | `string[]` | no | Country codes the customer may pick a delivery address in on the payment page, e.g. `['HU', 'AT']`. |
| `timeout` | `Date \| string` | no | Payment deadline (`Date` or ISO 8601). Default: now + 30 minutes. |
| `threeDSReqAuthMethod` | `'01' \| '02' \| '05'` | no | How 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):

| Field | Type | Description |
|---|---|---|
| `redirectUrl` | `string` | Return 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`](./back-url) 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: 'customer@example.com',
})
```

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](../reference/errors).

::: tip Always compute the amount on the server
Read `total` from the order on the server, not from data the browser sent.
:::

## Next

* [Handle the back URL](./back-url)
* [Receive the IPN](./ipn)
