Playmos
Gamehub
Make yourself at home.

Sign in to your Playmos account.

For developers
and publishers
Developers Web integration
Documentation Web integration

Put payments in your game.

Use the same SDK in a browser, HTML5 game or host page. Keep purchase state stable while the service or wallet completes the request.

Install and load#

Browser SDKTerminal
  1. npm install @playmos/sdk@0.3.20

Import Playmos from @playmos/sdk in your Vite, Phaser or other bundled app. The SDK uses viem; load it separately from the game where that improves first load on mobile. Never import @playmos/sdk/server in this bundle.

Wire the buy button#

Add the page elements and wire them to the helper:

Payment controlsHTML
  1. <button id="buy">Buy an extra life · 0.01 test USDC</button>
  2. <pre id="payment-status" aria-live="polite"></pre>

Save the helper as purchase.ts and import it into the page module. The example binds an existing button and output element. The purchase key is saved before the request, the button is disabled during submission, and a payment ID is retained even if server settlement times out.

Bind your page controlsTypeScript
  1. import { bindSandboxPurchase } from './purchase';
  2. const button = document.querySelector<HTMLButtonElement>('#buy')!;
  3. const output = document.querySelector<HTMLElement>('#payment-status')!;
  4. bindSandboxPurchase(button, output);

Make pending and recovery visible#

Show a pending state while the request runs. A timeout may contain error.detail.paymentId; keep it and call verify(id). Retry the same purchase with the original key if no ID was returned. Start a new key only for an intentional new purchase.

Choose the player experience#

The public sandbox’s settle: 'server' path uses test funds and does not ask the player to connect a wallet. For a wallet-funded payment, provide the host’s EIP-1193 provider and follow wallet and gas configuration. Server settlement is not a production wallet substitute.

Keep the grant on your backend#

The output is a display of the receipt. Send its ID to your backend, match your stored purchase and verify it under your studio before granting once. An iframe message, local receipt or disabled button is not an authorization boundary.

Use the playground to inspect actual SDK responses before wiring your game. The current portal iframe stage does not provide this payment bridge automatically.

Keep buildingYour first payment