Create session from widget
Creates a Glide session from a widget session, with the user's chosen payment method and currency. Use it to build your own payment UI on top of widget sessions instead of using the pre-built widget.
Import
import { createSessionFromWidget } from "@paywithglide/glide-js";Usage
import { createSessionFromWidget } from "@paywithglide/glide-js";
import { base } from "@paywithglide/glide-js/chains";
import { usdc } from "@paywithglide/glide-js/currencies";
import { config } from "./config";
const widgetSessionId = "c165e159-1f0e-44a1-8fa8-8c963444752e";
const userWalletAddress = "0xc6FfEB1298Eb33Da430d14e5Eb789256ec344625";
const session = await createSessionFromWidget(config, {
sessionId: widgetSessionId,
account: userWalletAddress,
paymentMethod: "wallet",
paymentCurrency: usdc.on(base),
});Parameters
The unique identifier of the widget session, from createWidgetSession.
The wallet address that will pay for the session.
How the user pays: wallet, transfer, coinbase_onramp, coinbase_app, moonpay, onramp, or onramper.
The currency the user pays with, in CAIP-19 format.
When set to true and if supported by the payment currency, the user pays with a signature only, requiring no gas. Defaults to false.
The amount to pay. Defaults to the amount configured on the widget session.
When set to true, the widget session's stableDepositAddressKey is not applied, so a fresh deposit address is generated.
The wallet address that owns the deposit. Used with transfer payments to attribute the deposit address to a specific user.
Configuration for Glide-hosted payment pages. Contains an optional appMetadata object (name, logoUrl, faviconUrl) and an optional theme object with custom theme values.