Skip to content
Store Dev
Last Updated

STOVE Payment Window Integration Guide

With Chrome disabling the document.domain setter, 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 receive postMessage events sent from the popup to its parent window.

Required Changes for Pages Using the Existing Billing Popup

  1. Remove the document.domain = "onstove.com"; declaration from the window.
  2. Implement a postMessage event 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 postMessage support.
  • Items related to document.domain will be removed later.

Related links:

document.domain setter deprecated

Window.postMessage

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:

json
{
    "source": "bill",
    "action": "request_balance_refresh"
}

postMessage When the User Clicks OK After Payment Completes

If no redirect URL is provided:

json
{
    "source": "bill",
    "action": "request_reload"
}

If a redirect URL is provided (redirect_url is the destination URL):

javascript
{
    "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.

javascript
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.