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.

Quick Start: Your First Checkout

Prev Next

This guide walks you through the minimum steps to get a working Frisbii Media checkout on your page. It uses PHP for the server-side part and the Frisbii Media JavaScript SDK for the frontend.


Prerequisites

  • A Frisbii Media stage account (use stage for all development and testing)

  • Your Company ID and API Access Token from the merchant backend under Settings → Developer

  • A configured Offer in the merchant backend with a known plenigoOfferId

  • Guzzle installed in your PHP project (or any HTTP client)


Step 1 – Create or retrieve the customer

Every checkout requires a customer. If you manage users externally, create or retrieve the customer in Frisbii Media first.

$client = new GuzzleHttp\Client(['base_uri' => 'https://api.frisbii-media.com/api/v3.0/']);
$user = [
    'customerId' => "4711",               // your internal user ID
    'email'      => "user@example.com",
    'language'   => 'de',
];
$response = $client->request('POST', 'customers', [
    'headers' => ['X-plenigo-token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9'],
    'json'    => $user,
]);
$customer = json_decode($response->getBody()->getContents());

This call is idempotent — if the customer already exists it is returned without being recreated.


Step 2 – Prepare the purchase

$ip = $_SERVER['REMOTE_ADDR']; // use a proper IP detection in production
$payload = [
    'debugMode'         => true, // disable in production!
    'customerIpAddress' => $ip,
    'customerId'        => $customer->customerId,
    'items'             => [
        [
            'plenigoOfferId' => 'O_YOUR_OFFER_ID',
            'quantity'       => 1,
        ],
    ],
];
$response = json_decode($client->request('POST', '/checkout/preparePurchase', [
    'headers' => ['X-plenigo-token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9'],
    'json'    => $payload,
])->getBody()->getContents());
$purchaseId = $response->purchaseId;

Step 3 – Render the checkout on your page

Add the following HTML where you want the checkout iframe to appear. Replace {YourCompanyId} with your actual Company ID.

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Checkout</title>
</head>
<body>
    <!-- Frisbii Media injects the checkout into this element -->
    <div id="plenigoCheckout"></div>
    <!-- Load the Frisbii Media JavaScript SDK (stage) -->
    <script src="https://static.frisbii-media-stage.com/web/v1/frisbii_media.min.js"
            data-company-id="{YourCompanyId}"
            data-lang="en"></script>
    <script>
        // Start the checkout
        new plenigo.Checkout("<?php echo $purchaseId; ?>", { elementId: "plenigoCheckout" }).start();
        // Handle successful purchase
        document.addEventListener("plenigo.PurchaseSuccess", function(e) {
            if (e.type !== "plenigo.PurchaseSuccess") return false;
            var orderId = parseInt(e.detail.orderId);
            if (orderId > 0) {
                location.href = "/success-page/?order=" + orderId;
            } else {
                // orderId -1: product was already bought
                // orderId -2: product cannot be purchased due to rules
                location.href ="/customer-already-has-access/";
            }
        });
        // Handle checkout failure
        document.addEventListener("plenigo.PurchaseFailed", function(e) {
            if (e.type !== "plenigo.PurchaseFailed") return false;
            console.error("Checkout failed:", e.detail);
            location.href = "/checkout-failed/";
        });
    </script>
</body>
</html>

orderId special values:

  • -1 — customer already owns this product

  • -2 — product cannot be purchased based on configured rules


Step 4 – Verify access after purchase

Once the customer has bought a product, check access on your server before displaying protected content.

try {
    $response = json_decode($client->request('GET',
        "accessRights/{$customer->customerId}/hasAccess?accessRightUniqueIds=YOUR_ACCESS_RIGHT_ID",
        ['headers' => ['X-plenigo-token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9']]
    )->getBody()->getContents());
    $hasAccess = $response->accessGranted;
} catch (\GuzzleHttp\Exception\ClientException $e) {
    // 404: customer not found in Frisbii Media — treat as no access
    $hasAccess = false;
}