--- title: "Checkout - Prepare Purchase" slug: "checkout-prepare-purchase" updated: 2026-07-09T05:07:16Z published: 2026-07-09T05:07:16Z canonical: "help.frisbii.com/checkout-prepare-purchase" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.frisbii.com/llms.txt > Use this file to discover all available pages before exploring further. # Checkout - Prepare Purchase Before the JavaScript SDK can render the checkout iframe, your server must call `POST /checkout/preparePurchase` to obtain a `purchaseId`. The `purchaseId` is a short-lived token that authorises exactly one checkout session. --- ## Minimal request ```php // Detect the customer's IP address if (!empty($_SERVER['HTTP_CLIENT_IP'])) {    $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {    $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else {    $ip = $_SERVER['REMOTE_ADDR']; } $payload = [    'debugMode'         => true, // disable in production!    'customerIpAddress' => $ip,    'customerId'        => $customer->customerId, // from POST /customers    'items'             => [        [            'plenigoOfferId' => 'O_6E487EBURRY35FOD0J',            'quantity'       => 1,        ],    ], ]; $response = json_decode($client->request('POST', '/checkout/preparePurchase', [    'headers' => ['X-plenigo-token' => eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9],    'json'    => $payload, ])->getBody()->getContents()); $purchaseId = $response->purchaseId; ``` Pass `$purchaseId` to the JavaScript SDK to start the checkout. See [Checkout (JavaScript SDK)](/frisbii-media/docs/checkout-1). --- ## Required fields | Field | Description | | --- | --- | | `customerIpAddress` | The customer's IP address. Used for geo-restrictions and fraud detection. | | `customerId` | The Frisbii Media customer ID. Either from `POST /customers` or from a session. | | `items[].plenigoOfferId` | The ID of the offer to purchase. Found in the Frisbii Media backend. | | `items[].quantity` | Number of items. Almost always `1`. | --- ## debugMode Set `debugMode: true` during development to enable additional debugging output inside the checkout iframe. **Always set it to** `false` **or remove it in production.** --- ## Using a customer session instead of a customerId If you are using Frisbii Media SSO, you can pass `customerSession` instead of `customerId`: ```php $payload = [    'debugMode'         => true,    'customerIpAddress' => $ip,    'customerSession'   => $session, // Frisbii Media SSO session token    'items'             => [        [            'plenigoOfferId' => 'O_6E487EBURRY35FOD0J',            'quantity'       => 1,        ],    ], ]; ``` --- ## Full HTML example Once you have the `purchaseId`, render the checkout on your page: ```xml
``` ---