Bonaventure OgetoBy Bonaventure Ogeto|

Building an Events Ticketing Platform with Splits

Create an organizer subaccount at event registration. Set the split so the organizer receives the ticket price minus the platform booking fee. Initialize each ticket purchase with the organizer's subaccount and percentage_charge set to the organizer's share. On charge.success, generate and email the ticket to the buyer. Hold organizer funds until post-event to protect against cancellations.

Ticket Checkout with Split

// Sell a ticket with organizer split
app.post('/api/events/:id/tickets', async (req, res) => {
  var { ticketType, email, quantity } = req.body;
  var event = await db.events.findById(req.params.id);
  var organizer = await db.organizers.findById(event.organizer_id);

  var ticketPrice = event.ticket_prices[ticketType]; // e.g., 5000 NGN
  var totalAmount = ticketPrice * quantity;
  var platformFee = 500; // NGN 500 per order flat booking fee
  var organizerShare = totalAmount - platformFee;

  var reference = 'tkt_' + event.id + '_' + Date.now();

  var response = await fetch('https://api.paystack.co/transaction/initialize', {
    method: 'POST',
    headers: { Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY, 'Content-Type': 'application/json' },
    body: JSON.stringify({
      email,
      amount: totalAmount * 100,
      subaccount: organizer.subaccount_code,
      transaction_charge: platformFee * 100, // Platform booking fee in kobo
      bearer: 'account',
      reference,
      metadata: {
        event_id: event.id,
        ticket_type: ticketType,
        quantity,
      },
    }),
  });

  var data = await response.json();
  res.json({ authorization_url: data.data.authorization_url });
});

// Webhook: generate and send tickets on payment
if (event.event === 'charge.success') {
  var meta = event.data.metadata;
  if (meta?.event_id) {
    var tickets = await generateTickets(meta.event_id, meta.ticket_type, meta.quantity);
    await sendTicketEmail(event.data.customer.email, tickets);
    await db.sales.create({
      reference: event.data.reference,
      event_id: meta.event_id,
      email: event.data.customer.email,
      ticket_type: meta.ticket_type,
      quantity: meta.quantity,
      status: 'paid',
    });
  }
}

Learn More

Key Takeaways

  • Create an organizer subaccount per event host. Reuse the same subaccount for all events by that organizer.
  • Set the organizer's percentage_charge per transaction (e.g., 85%) — your platform keeps 15% as a booking fee.
  • Generate tickets (PDF or QR code) only after charge.success webhook confirms payment.
  • Hold organizer settlement until after the event date to protect against last-minute cancellations.
  • For multi-tier tickets (VIP, Regular, Early Bird), use the same subaccount but different transaction amounts per ticket type.
  • Issue refunds via the Paystack refund API. Partial refund the ticket price if a service fee is non-refundable.

Frequently Asked Questions

When should I release ticket revenue to the organizer?
Best practice: release after the event date passes without a cancellation. This protects buyers if the event is cancelled. Communicate this to organizers upfront. Set a manual settlement window and trigger payout 24-48 hours after the event end date.
How do I handle event cancellation refunds?
If the event is cancelled before the event date and organizer settlement has not been initiated, issue full refunds via the Paystack refund API. If organizer funds have already been released, you must recover from the organizer directly. This is why holding funds until post-event is important.
Can I support multiple ticket tiers (VIP, Regular, Early Bird) with splits?
Yes. The split configuration (subaccount + platform fee) is the same regardless of ticket tier. The difference is only the transaction amount per ticket type. Store ticket prices in your events table and calculate the split based on the chosen tier's price.
How do I issue QR code tickets after payment?
In your charge.success webhook handler, generate a unique QR code per ticket (encode ticket_id + event_id + buyer_email in the QR payload). Store it in your database and send via email. At event check-in, scan the QR code and verify against your database.

Ready to build real-world apps?

Join the McTaba Labs full-stack marathon (4 months full-time · 6 months part-time). Learn M-Pesa, USSD, and WhatsApp engineering while shipping 8 production apps.

Apply to the McTaba Marathon