Connect ticketing to your existing website (with code examples)

Already have a website for your association, sports club or organisation? Then you don't have to send visitors away to buy tickets. MijnEvent runs as a drop-in on your own site: you paste one script line and a div, and the ticket widget appears — including checkout, without the visitor leaving your site. The most powerful part is the member connection: because the member is already logged in on your website, that website can pass a signed token with each purchase that says "this is a member". MijnEvent then applies the member price or free entry automatically, while non-members pay the regular rate. Nothing is synchronised or copied — your member administration stays the source of truth and the status is always correct at the moment of purchase. Below we show how to apply it, with a working code example for developers. The step-by-step setup guide for admins is in the knowledge base article Members free, non-members pay.

1. The widget on your site (recommended: the script embed)

In your admin under Integrations the embed code is ready. The recommended option is one script line plus one div — the widget measures its own height and resizes the iframe automatically, so you don't have to guess a fixed height:

<div data-mijnevent-event="summer-festival-2026"></div>
<script src="https://yourclub.mijnevent.nl/embed.js" async></script>

You can place multiple events on a single page by adding multiple divs. There is also a simple iframe variant, but it requires you to set the height yourself (with long ticket lists or the checkout step the content then gets cut off) — only use that if you can't place a script.

2. A member price or members-only ticket type

For a ticket type you set two things in the admin:

  • Access: Public or Members only (members-only ticket types are hidden from the public).
  • Member price: empty (members pay normal), 0 (free for members) or a lower amount (member discount).

3. The member token (for developers)

When a logged-in member buys tickets on your site, your server signs a short-lived JWT with the secret key from Integrations. It's a plain HS256 token; you don't need a library for it:

<?php
// On your own server, for a logged-in member:
function mijneventMemberToken(string $keyId, string $secret, array $claims): string {
    $b64 = fn ($d) => rtrim(strtr(base64_encode($d), '+/', '-_'), '=');
    $header  = $b64(json_encode(['typ' => 'JWT', 'alg' => 'HS256', 'kid' => $keyId]));
    $payload = $b64(json_encode($claims));
    $sig     = $b64(hash_hmac('sha256', "$header.$payload", $secret, true));
    return "$header.$payload.$sig";
}

$token = mijneventMemberToken('mek_...', 'msk_...', [
    'aud'     => 'yourclub',                // your organisation ID
    'sub'     => $member->id,               // membership number
    'email'   => $member->email,
    'scope'   => 'event:summer-festival-2026', // limit to one event
    'max_qty' => 2,                         // e.g. member + 1 guest
    'iat'     => time(),
    'exp'     => time() + 900,              // valid for 15 minutes
]);

Pass the token to the widget — server-side rendered, so the secret key never reaches the browser:

<div data-mijnevent-event="summer-festival-2026" data-member-token="<?= $token ?>"></div>
<script src="https://yourclub.mijnevent.nl/embed.js" async></script>

What MijnEvent checks

Both when displaying and at checkout, MijnEvent re-verifies the token: the signature (via the kid → secret key), the aud (must be your organisation), the exp (expiry), and a single-use jti against replay. In addition, scope determines which event is unlocked and max_qty how many member tickets get the member price. If the token is invalid or expired, the visitor is simply treated as a paying non-member — nothing breaks.

Endpoints

  • POST /api/members/verify-token — verify a token (read-only) to show member prices and members-only ticket types before checkout.
  • POST /api/checkout — pass the token as member_token; the member price is applied and members-only ticket types are released.

Which approach do you choose?

  • Club site with member login → the token connection (this approach). Always in sync, no member list needed.
  • No member login → unique discount codes per member (simpler, more manual).
  • Large membership system (Conscribo, AllUnited, Sportlink, LISA) → a custom connection; get in touch.

Get started

Set it up in an evening: create an API key, set a member price on a ticket type, and place the embed. The full admin guide is in the knowledge base article Members free, non-members pay; more explanation is in the knowledge base. Questions about the setup for your organisation? We're happy to help.

Back to blog
MijnEvent

Ready to get started?

Create a free account and sell your first tickets today.