DocumentationHosted checkout

Accept payments

Hosted checkout

Create checkout on your server, then open it from your website.

Markdown

Create a checkout session

Use POST /checkout/sessions with a server key that has payments:write. The session fixes the amount on the server. Save the returned data.id against the order.

curl https://api.veyqo.org/api/v1/checkout/sessions \
  -H "Authorization: Bearer $VEYQO_SECRET_KEY" \
  -H "Idempotency-Key: $ORDER_PAYMENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 50000,
    "currency": "NGN",
    "reference": "ORDER-1001",
    "provider": "paystack",
    "customer": { "email": "customer@example.com" },
    "success_url": "https://shop.example.com/thanks",
    "cancel_url": "https://shop.example.com/cart"
  }'

Open checkout in the browser

Expose your own authenticated /create-checkout endpoint that looks up the order, creates the session and returns { id: result.data.id }. Check that the signed-in customer owns the order.

<script src="https://veyqo.org/sdk/v1/checkout.js"></script>
<button id="pay">Pay now</button>
<script>
  document.getElementById("pay").onclick = async () => {
    try {
      const response = await fetch("/create-checkout", { method: "POST" });
      if (!response.ok) throw new Error("Could not create checkout");
      const { id } = await response.json();
      VeyqoCheckout.open({
        session: id,
        onSuccess: () => location.assign("/thanks"),
        onClose: () => console.log("Checkout closed"),
      });
    } catch (error) {
      alert("Unable to open checkout. Please try again.");
    }
  };
</script>