Skip to content

Search documentation

Try “webhook signature” or “amountUsd”. Use Tab or arrow keys to explore results.

    Open app
    Open app

    Documentation navigation

    Hosted checkout

    Send customers to a Forwend payment page for one purchase attempt.

    On this page

    Create on the server

    Create a checkout session with a store, server-calculated amount and your order reference. The response includes payment.hostedUrl.

    Checkout sessions do not issue an invoice number or invoice document. Keep the session ID in your order record.

    JavaScript
    const response = await fetch(
      process.env.FORWEND_API_URL + "/v1/profiles/" +
        process.env.FORWEND_PROFILE_ID + "/checkout-sessions",
      {
        method: "POST",
        headers: {
          Authorization: "Bearer " + process.env.FORWEND_KEY,
          "Content-Type": "application/json",
          "Idempotency-Key": "order-1042-attempt-1",
        },
        body: JSON.stringify({
          storeId: process.env.FORWEND_STORE_ID,
          amountUsd: "1250.00",
          reference: "order-1042",
          metadata: { order_id: "1042" },
        }),
      },
    );
    if (!response.ok) throw new Error("Checkout could not be created");
    const session = await response.json();
    // Send only the hosted URL, or the pay token for an embedded checkout, to your browser.
    const hostedUrl = session.payment.hostedUrl;
    const payToken = session.payment.payToken;

    Return and confirm

    Link to the returned hosted URL. A returnUrl can take the customer back after checkout; the URL must use HTTPS and an approved store origin.

    Treat a return as navigation. Verify signed payment events and read canonical status on your server before shipping.

    Forwend documentation Test first. Confirm on your server.