Return to merchant (returnUrl)
Send customers back to your page or app after payment — register addresses in the console, pass returnUrl, and handle the return page.
When checkout runs in the same window (mobile web, an external browser), the customer ends on the StagePay result screen (/return). Pass returnUrl in the payment request and that screen shows a Back to merchant button that goes to your address with the result appended.
Your page ── requestPayment({ returnUrl }) ──▶ StagePay checkout ──▶ PG payment
▲ │
└── /orders/A-1001?stagepay_tid=…&stagepay_status=success ◀── result screen [Back to merchant]Returned values are for display only
stagepay_tid and stagepay_status are query values anyone can change. Decide fulfilment only from the signed callback or a server-side transaction lookup.
When the button appears
| How checkout was opened | Result screen | How you get the result |
|---|---|---|
Mobile web (redirect) | Back to merchant | Navigates to returnUrl |
| App → external browser | Back to merchant (app deep link) | Back to the app via mygame://… |
| PC popup · layer (iframe) | Close | postMessage → SDK Promise |
| App WebView native bridge | Close | Bridge message (In-app / WebView) |
Inside a popup, layer or WebView the result arrives as a message, so a Close button is shown instead — your page is never opened inside that window.
Setup
Register addresses in the console
In the console, go to Apps → Edit app → Return addresses after payment, enter one per line and save (up to 10).
https://shop.example.com
https://m.shop.example.com
mygame://- For the web, enter the origin only, no path. Register other ports separately (
https://shop.example.com:8443). - http works only for development hosts
localhost,127.0.0.1and[::1]. - For an app deep link enter the scheme only (
mygame://). Schemes such asjavascript:,data:andintent:cannot be registered. - Case, the default port (
:443) and a trailing/are normalized on save.
Pass returnUrl in the payment request
Any path, query or # under a registered origin is fine.
StagePay.requestPayment({
pg: 'KCP', method: 'card',
productId: 'gem_100', currency: 'KRW', userId: 'user_42',
uniqueId: 'A-1001',
returnUrl: 'https://shop.example.com/orders/A-1001',
});Handle the return page
The button goes to returnUrl with stagepay_tid (the StagePay transaction ID) and stagepay_status (success, pending, failed) appended. Your own query and # are kept.
const back = StagePay.getReturnResult({ clean: true }); // removes stagepay_* from the address bar
if (back) {
// { transactionId: 'KCP-…', status: 'success', verified: false }
showSpinner('Checking payment…');
const order = await fetch('/api/orders/A-1001').then((r) => r.json()); // your server decides
render(order);
}const res = await fetch(`https://api.stagepay.io/api/v1/transactions/${tid}`, {
headers: { Authorization: `Bearer ${process.env.STAGEPAY_KEY_ID}:${process.env.STAGEPAY_KEY_SECRET}` },
});
const { data } = await res.json(); // fulfil only when data.status is success (usually the callback already did)pending (a virtual account was issued, for example) is not final. Show "checking" until the callback arrives.
Matching rules
With https://shop.example.com and mygame:// registered:
| returnUrl | Result |
|---|---|
https://shop.example.com/orders/7?x=1#top | Allowed |
https://SHOP.example.com:443/ | Allowed (case and default port ignored) |
mygame://pay/done | Allowed |
https://m.shop.example.com/ | Rejected — register subdomains separately |
https://shop.example.com:8443/ | Rejected — different port |
http://shop.example.com/ | Rejected — http |
https://shop.example.com@evil.com/ | Rejected — user info (@) |
/orders/7, //shop.example.com/ | Rejected — not an absolute URL |
javascript:…, data:… | Rejected |
- Values over 2048 characters, or with whitespace, control characters or backslashes, are rejected.
- The result screen re-checks against the current app settings every time it is shown. Removing an address in the console also removes the button from payments already created.
Errors
| Where | Code / screen | Cause |
|---|---|---|
Checkout (/request, /inapp) | "This return address (returnUrl) is not registered" (errors.invalid_return_url) | Origin or scheme not registered on the app |
POST /api/v1/payments | 400 INVALID_RETURN_URL | Same as above |
| Console save | "Invalid return address" | Address with a path, public http, a dangerous scheme, more than 10 |
| JS SDK | INVALID_PARAMS | Not an absolute URL or contains whitespace (rejected before reaching the server) |
Testing locally
- Register
http://localhost:3000(your dev server) in the console. - Use a mobile viewport, or force same-window navigation with
mode: 'redirect'.
StagePay.requestPayment({
...params,
returnUrl: 'http://localhost:3000/orders/A-1001',
mode: 'redirect', // same-window navigation on PC too
});- Complete a test payment, press Back to merchant on the result screen, and check
StagePay.getReturnResult()on the page you land on.
JavaScript SDK
Launch any PG, payment method or easy pay (Kakao Pay, Naver Pay, Toss Pay) from a merchant web page with one script tag and one call — on PC, mobile web and in-app WebViews.
In-App / WebView Integration
How to open the checkout in a mobile game or app WebView and receive the payment result message sent by /return in React Native, iOS, Android, and the web (popup/iframe).