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 Workflow Page

Prev Next

A checkout workflow page is a dedicated URL on your website that handles the complete checkout process — receiving the offer ID via query parameter, preparing the purchase server-side, and rendering the checkout iframe. This pattern keeps checkout logic in one place and makes it easy to link to a specific offer from any article paywall, email campaign, or marketing page.


URL pattern

https://www.example.com/checkout?offer=O_6E487EBURRY35FOD0J

The offer ID is passed as a query parameter. Your checkout page reads it, calls preparePurchase, and renders the checkout.


Server-side: validate and prepare

// checkout.php
$offerId = $_GET['offer'] ?? null;
if (empty($offerId)) {
    // No offer ID — redirect to your products overview
    header('Location: /products/');
    exit;
}
// Retrieve or create the customer
// (See Customer Management or Sessions & Transfer Tokens, depending on your SSO setup)
$customerId = $_SESSION['plenigo_customer_id'] ?? null;
if (empty($customerId)) {
    // Not logged in — redirect to login with returnTo
    $returnTo = '/checkout?offer=' . urlencode($offerId);
    header('Location: /login?returnTo=' . urlencode($returnTo));
    exit;
}
// Detect IP
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
    $ip = $_SERVER['REMOTE_ADDR'];
}
// Prepare the purchase
$payload = [
    'debugMode'         => false,
    'customerIpAddress' => $ip,
    'customerId'        => $customerId,
    'items'             => [
        ['plenigoOfferId' => $offerId, 'quantity' => 1],
    ],
];
$response = json_decode($client->request('POST', '/checkout/preparePurchase', [
    'headers' => ['X-plenigo-token' => eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9],
    'json'    => $payload,
])->getBody()->getContents());
$purchaseId = $response->purchaseId;

Frontend: render the checkout iframe

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Checkout</title>
</head>
<body>
    <div id="plenigoCheckout"></div>
    <script src="https://static.frisbii-media.com/web/v1/frisbii_media.min.js"
            data-company-id="{YourCompanyId}"
            data-lang="en"></script>
    <script>
        new plenigo.Checkout("<?php echo $purchaseId; ?>", {
            elementId: "plenigoCheckout",
            returnUrl: "<?php echo 'https://www.example.com/checkout?offer=' . htmlspecialchars($offerId); ?>"
        }).start();
        document.addEventListener("plenigo.PurchaseSuccess", function(e) {
            if (e.type !== "plenigo.PurchaseSuccess") return false;
            var orderId = parseInt(e.detail.orderId);
            if (orderId > 0) {
                location.href = "/checkout/success/?order=" + orderId +"&offer=<?php echo urlencode($offerId); ?>";
            } else {
                location.href = "/already-subscribed/";
            }
        });
        document.addEventListener("plenigo.PurchaseFailed", function(e) {
            if (e.type !== "plenigo.PurchaseFailed") return false;
            location.href = "/checkout/failed/";
        });
    </script>
</body>
</html>

Per-offer custom CSS

If different offers need different checkout styling (e.g. a premium offer with a distinct look), pass a custom CSS URL that includes the offer ID:

new plenigo.Checkout("<?php echo $purchaseId; ?>", {
    elementId: "plenigoCheckout",
    customCSS: "https://www.example.com/assets/checkout/<?php echo urlencode($offerId); ?>.css"
}).start();

Each offer gets its own CSS file. If no per-offer file exists, fall back to a default. See Custom CSS for CORS requirements.


Linking to the checkout page from a paywall

On any article page, the paywall "Subscribe" button simply links to the checkout page with the relevant offer ID:

<a href="/checkout?offer=O_6E487EBURRY35FOD0J" class="cta-button">
    Subscribe now
</a>

From email campaigns, you can link directly:

https://www.example.com/checkout?offer=O_6E487EBURRY35FOD0J

Success page

After a successful purchase, redirect to a dedicated success page. At minimum, re-check access and show a confirmation. If the offer grants access to a specific article, redirect there:

// /checkout/success/
$offerId = $_GET['offer'] ?? null;
$orderId = $_GET['order'] ?? null;
// Optionally: look up the order to find the article URL
// For now, show a generic success message
echo "Thank you! Your subscription is now active.";