window.Playto, with two methods. It has no
dependencies and is loaded from:
Playto.checkout(options)
Opens the embedded checkout modal.
Options
The
id of a product (payment link) to charge for. Provide one of
productId or paymentLinkId. checkout() throws an error if neither is set.The URL to send the customer to after payment, such as
https://example.com/thanks. A relative URL such as /thanks is resolved
against the current page. When payment ends, the modal closes and your
window goes to this URL with the result appended as query params (see
handleReturn). It can be on any host; only
the page that opens the checkout needs an
approved domain
in Live.Set to
"sandbox" to run against the test environment. Required when you
use a sandbox (test) id: without it, the id shows “Link Not Found”.Called when the modal closes, with a
reason string. See
onClose reasons.onClose reasons
onClose can also fire when payment ends. With "iframe" it runs just before
the window goes to returnUrl, so don’t treat every close as an abandoned
checkout.
Don’t rely on onClose to detect a finished payment. When a payment provider
moves the whole tab (Whop does this after a completed payment), your page is
replaced and onClose doesn’t fire. Read the result with handleReturn() on
the returnUrl page instead.
Returns
A handle with aclose() method to dismiss the modal programmatically:
checkout() again returns the open handle. It does
not open a second modal, and the new options are ignored.
Playto.handleReturn(options)
Call this on the page the customer returns to (often the same page). It reads the
result Playto appended to the URL and fires the matching callback.
Options
Remove Playto’s params (
playto_status, playto_session_id) from the URL bar
after reading. The #hash is kept. Set false to keep the params.Returns
The parsed result{ status, sessionId }, or null if there were no Playto
params on the URL (i.e. this wasn’t a return navigation).
The result object
BothonSuccess and onError receive:
Use
sessionId for display and idempotency, but grant entitlements from the
signed webhook, not the browser callback — the URL can be tampered with. See
Going live.