The SDK exposes a single global, window.Playto, with two methods. It has no dependencies and is loaded from:

Playto.checkout(options)

Opens the embedded checkout modal.

Options

string
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 id of an invoice. It is the paymentLinkId in the invoice’s checkout_url.
string
default:"current page URL"
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.
string
default:"production"
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”.
function
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 a close() method to dismiss the modal programmatically:
While a modal is open, calling checkout() again returns the open handle. It does not open a second modal, and the new options are ignored.
Playto.checkout() only calls onClose. It does not call onSuccess or onError, so passing them has no effect. React to the result with Playto.handleReturn() on the page at your returnUrl.

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

function
Called with { status, sessionId } when playto_status=success.
function
Called with { status, sessionId } when playto_status is failed or cancelled.
boolean
default:"true"
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

Both onSuccess 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.