Embedded Checkout
Server-side payment and session
Create the payment first
POST /v1/payments is merchant-authenticated. Always send Idempotency-Key. The SDK never creates payments.
Node
const payment = await fetch("https://sandbox-api.vestonix.io/v1/payments", {
method: "POST",
headers: {
Authorization: "Bearer vsk_test_YOUR_KEY",
"Content-Type": "application/json",
"Idempotency-Key": crypto.randomUUID(),
},
body: JSON.stringify({ amount: "18.00", currency: "USD" }),
}).then((r) => r.json());
const session = await fetch(
`https://sandbox-api.vestonix.io/v1/payments/${payment.id}/client-sessions`,
{
method: "POST",
headers: {
Authorization: "Bearer vsk_test_YOUR_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({ platform: "web" }),
},
).then((r) => r.json());
// Send only session.client_secret to the app.