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).
When the payment is finished, the customer is taken to the StagePay result page, /return. As soon as this page loads, it sends the payment result over multiple channels at once, so your app only needs to implement the channel that suits it.
The result message is for UI handling only
Use the /return message only for UI handling, such as closing the checkout and showing a "Confirming payment" screen. Always grant items based on the signed callback received by your server. Client messages can be forged.
Result message format
{
"type": "STAGEPAY_RESULT",
"action": "payment_complete",
"status": "success",
"title": "결제 성공",
"message": "결제가 성공적으로 완료되었습니다.",
"transactionId": "KCP-20260101090000123456-a1b2c3-9f8e7d6c",
"details": "Transaction ID: KCP-20260101090000123456-a1b2c3-9f8e7d6c",
"timestamp": "2026-01-01T09:00:12+09:00"
}| Field | Value |
|---|---|
type | Always STAGEPAY_RESULT (the close button message is STAGEPAY_CLOSE for popups and iframes) |
action | payment_complete (on page load) or close (close button) |
status | success · pending · failed. pending means the PG returned before final approval (e.g. some card or bank account payments); the final result is reflected via the callback |
transactionId | StagePay tid |
title / message | Display text in the browser language (ko/en/ja/zh) |
Delivery channels
| Environment | Channel |
|---|---|
| React Native WebView | window.ReactNativeWebView.postMessage(JSON.stringify(result)) |
| iOS WKWebView | window.webkit.messageHandlers.GamePotStagePay.postMessage(result) |
| Android WebView | window.GamePotStagePay.onPaymentResult(JSON.stringify(result)) |
| Popup (window.open) | window.opener.postMessage(result, '*') |
| iframe | window.parent.postMessage(result, '*') |
When the close button is pressed, React Native receives an action: "close" message, iOS receives { action: 'close' }, and Android receives a GamePotStagePay.close() call.
Platform examples
import { WebView } from 'react-native-webview';
export function CheckoutScreen({ checkoutUrl, onDone }: { checkoutUrl: string; onDone: (s: string) => void }) {
return (
<WebView
source={{ uri: checkoutUrl }}
onMessage={(event) => {
let data: { type?: string; action?: string; status?: string; transactionId?: string };
try {
data = JSON.parse(event.nativeEvent.data);
} catch {
return;
}
if (data.type !== 'STAGEPAY_RESULT') return;
// Only update the UI; decide whether to grant by querying the server (callback) status
onDone(data.status ?? 'failed');
}}
/>
);
}Recommended flow
- The client sends a purchase request to the merchant server → the server calls the payment creation API or builds a checkout URL.
- The client opens
checkoutUrlin a WebView. - On receiving
STAGEPAY_RESULT, close the WebView and show "Confirming payment". - The merchant server grants the item after receiving the callback. The client queries the merchant server for the order status (polling or push) and displays the result.
- If
statusispending, wait until the callback arrives (USDT, virtual accounts, and similar methods can take from several minutes to several hours).
WebView configuration tips
- JavaScript and DOM Storage must be enabled.
- Some payment methods (card issuer apps, easy pay apps) open apps via external schemes such as
intent://orkakaotalk://. In your WebView's URL loading handler, pass non-http(s)schemes to the OS so it launches the external app. - If third-party cookies are blocked, some PG authentication can fail. On Android, set
CookieManager.setAcceptThirdPartyCookies(webView, true).
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.
Payment Methods and Country Support
The PGs, regions, payment methods, and currencies available in StagePay v2, and how to look up the payment methods actually available to your app.