1. Prepare credentials
In the merchant cabinet, switch to Test mode and:- On API keys, create or rotate the test key. The full
test_…key is shown once; store it in your server’s secret store. - On Webhooks, set the test endpoint URL and issue the test signing secret (
whsec_…). Test events go only to this test endpoint, signed with this test secret: thecallbackUrlof an individual test sale cannot redirect them, and without a test endpoint no test webhook is sent.
ORSUNPAY_API_KEY and ORSUNPAY_MERCHANT_ID from your server’s configuration. Set ORSUNPAY_API_BASE_URL to your assigned origin, for example https://r1-api.orsunpay.com for R1. Use public HTTPS URLs belonging to your store in place of merchant.example. The request below shows the wire format; replace mr_example with the ID belonging to your key and supply your own order ID and saved idempotency key.
2. Create a sale
Generate an idempotency key once for this payment attempt and store it with the order before sending. Reuse the same key and body if you need to retry.paymentMethod, so the buyer chooses a method on the hosted payment page when
hosted checkout is enabled for your deployment. Check the response body, not only the HTTP status:
status: truewithpaymentPageUrl(or a providerurl) means the sale was created; redirect the buyer.status: falsewith anerroris a business rejection, even with HTTP 201. See errors.pending: trueandtransaction.errorCode: "PSP_OUTCOME_UNKNOWN"means the outcome is not yet known: keep the order pending and do not create another sale.
3. Redirect the buyer
SendpaymentPageUrl (or url) unchanged to your frontend and redirect the buyer. The buyer
eventually returns to your successUrl, failureUrl or returnUrl. A browser return is not
proof of payment. See hosted payment page.
4. Verify the webhook
OrsunPay POSTs atransaction.updated event to your test endpoint. Verify the
OrsunPay-Signature header against the exact raw body bytes before parsing JSON.
id and apply the change in one database transaction, then
return 2xx. Fulfil the order only for data.transaction.status: "SUCCESS". Full rules, including
retries and the downloadable examples, are in webhooks.
5. Read the status if needed
If the webhook has not arrived, read the stored state; this does not contact the provider:Next steps
- Test in sandbox before switching to your
live_…key. - Learn the payment states and error handling.
- Add refunds and payouts.