Accept a one-time payment

  1. Create a product or reuse an existing one.
  2. Create a checkout session.
  3. Redirect your customer to the checkout URL.
  4. Handle the checkout.paid webhook.
  5. Grant access.
const checkout = await accend.checkout.createSession({
  mode: "payment",
  customerId: "cus_123",
  productId: "prod_123",
  amount: "97.00",
  currency: "BRL",
  successUrl: "https://yourapp.com/success",
  cancelUrl: "https://yourapp.com/cancel"
});

redirect(checkout.data.checkoutUrl);
app.post("/webhooks/accend", async (req, res) => {
  if (req.body.type === "checkout.paid") {
    await grantAccess(req.body.data.customerId, req.body.data.productId);
  }

  res.sendStatus(200);
});
Use a key with checkout:write for the service that creates checkout sessions.