Tutorial
Build an eSIM store with Next.js.
The store can be your page. The API key stays in a server route or a server action. The browser asks your route for plans and, after the shopper commits, for a fulfilment.
Code and responses on this page are illustrative. They show the shape of an integration. Confirm the production schema in your Cuppa account before you ship.
List plans on the server
A server component or route reads the catalogue and renders the allowance and validity. Do not ship a hardcoded price from this marketing site. If you resell, apply your retail price in your own code after you know the account cost.
Provision after the order exists
Create the fulfilment only once you have an order reference. The route below is the illustrative call. Wrap it in whatever auth your store already uses for customers.
const res = await fetch(`${CUPPA_API_URL}/v1/fulfilments`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CUPPA_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
product_id: "example_plan",
reference: "booking_4821",
}),
});
const fulfilment = await res.json();