- Cập nhật lần cuối
STOVE Payment Window Integration Guide
With Chrome disabling the
document.domainsetter, cross-origin policies restrict interaction between subdomains.
If you need to refresh the balance or handle payment completion based on the payment popup's state,
you can receivepostMessageevents sent from the popup to its parent window.
Required Changes for Pages Using the Existing Billing Popup
- Remove the
document.domain = "onstove.com";declaration from the window. - Implement a
postMessageevent listener for the actions your page needs to handle.
document.domain and postMessage Are Used Together Due to Chrome's Delayed Deprecation Schedule (September 2022)
- September 14, 2022: Deployed
postMessagesupport. - Items related to
document.domainwill be removed later.
Related links:
document.domain setter deprecated
postMessage Types
A postMessage event is sent when payment completes in the top-up window and when that window closes.
After adding an event listener to receive these messages, implement the actions required by the calling window, such as refreshing the balance without reloading the entire page or reloading the full page.
postMessage When Payment Completes
When payment completes:
{
"source": "bill",
"action": "request_balance_refresh"
}
postMessage When the User Clicks OK After Payment Completes
If no redirect URL is provided:
{
"source": "bill",
"action": "request_reload"
}
If a redirect URL is provided (redirect_url is the destination URL):
{
"source": "bill",
"action": "request_redirect",
"message": redirect_url
}
Receiving postMessage Events
Origin URL
| event.origin | - Live: https://pay.onstove.com - Sandbox: https://pay.gate8.com |
|---|
Adding an Event Listener
Check that event.origin matches the billing origin before handling each action.
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event)
{
if (event.origin !== "https://pay.onstove.com")
return;
// ...
}
Contact Us
If you have any questions, please contact us on Discord or by email at store.support@smilegate.com.