Checkout embed SDK
The smallest integration path. One <script>, a data-soren-checkout attribute,
and a server endpoint that proxies your API key.
1. Add the script
Site headhtml
<script src="https://sorenpay.com/checkout.js"></script>2. Add a button
Anywhere on the pagehtml
<button
data-soren-checkout
data-amount-cents="2500"
data-description="Pro plan · 1 seat"
data-session-endpoint="/api/create-soren-session"
>
Pay with Soren
</button>3. Create the session endpoint (server-side)
This route lives on your server. Never expose your apk_ key in the
browser. Example for Next.js API route:
/api/create-soren-session.tstypescript
import { NextResponse } from "next/server";
export async function POST(req: Request) {
const body = await req.json();
const res = await fetch("https://api.sorenpay.com/api/v1/checkout/sessions", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SOREN_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": crypto.randomUUID(),
},
body: JSON.stringify({
amountUsdCents: body.amountUsdCents,
description: body.description,
acceptedAssets: body.acceptedAssets ?? ["USDC", "USDT"],
acceptedChains: body.acceptedChains ?? ["ethereum", "polygon", "arbitrum", "base", "solana"],
successUrl: body.successUrl ?? "https://yoursite.com/thanks",
}),
});
const json = await res.json();
return NextResponse.json(json.session);
}4. Listen for completion (optional)
The SDK fires a soren:completed CustomEvent on document after a successful payment:
document.addEventListener("soren:completed", (e) => {
console.log("Paid!", e.detail);
// Redirect to your post-purchase flow
window.location.href = "/thank-you?session=" + e.detail.id;
});
document.addEventListener("soren:failed", (e) => {
console.warn("Payment failed", e.detail);
});SDK reference
| Attribute | Required | Default |
|---|---|---|
| data-soren-checkout | Yes | — |
| data-amount-cents | Yes | — |
| data-session-endpoint | Yes | /api/create-soren-session |
| data-description | No | — |
| data-merchant-reference | No | — |
| data-assets | No | USDC,USDT |
| data-chains | No | ethereum,polygon,arbitrum,base,solana |
Manual control
Skip the button binding and call directly:
window.SorenPay.checkout({
sessionEndpoint: "/api/create-soren-session",
amountCents: 2500,
description: "Pro plan",
assets: ["USDC"],
chains: ["polygon", "base"],
}).then(({ sessionId, hostedUrl }) => {
console.log("Opened session", sessionId);
});