Commerce: Checkout and Order Processing – Terms & Cancellation Policy Messaging

This section manages how terms of service acceptance and cancellation policy messages are built and surfaced during the Stripe checkout flow. It adapts dynamically based on the event type (tournament vs. showcase) and the presence of Event Insurance.

Components Overview

  • buildTermsAndConditions: Constructs the dynamic message.
  • Stripe session configuration: Injects the message into Stripe’s terms_of_service_acceptance step.
  • Blade view (**cancelation-policy.blade.php**): Renders the policy on the public site.

StripeTrait::buildTermsAndConditions() ✍️

A private method in App\Traits\StripeTrait that generates the full TOS & cancellation policy text. It runs during checkout session initialization.

/**
 * Build the terms and conditions message 
 * based on event type and insurance status
 */
private function buildTermsAndConditions(
    Event $event,
    string $websiteName,
    string $invoiceDeadline,
    string $dayAfter
): string { ... }

Parameters

Name Type Description
$event Event The event being purchased
$websiteName string Website display name (e.g. “Prep Network”)
$invoiceDeadline string Formatted invoice cutoff date (e.g. “April 1, 2025”)
$dayAfter string The day after the invoice deadline

Message Construction Logic

  1. Base Terms
  2. Always includes links to the site’s TOS & Privacy Policy.
  3. No Registrations Yet
  4. Returns only the base terms when no existing cart registrations exist.
  5. Tournament Policy
  6. Before deadline: full rollover payment to future same-season event (if not sold out).
  7. After deadline: payments are irrevocable, non-refundable, non-transferable.
  8. Showcase Policy
  9. With Event Insurance: full refund (minus insurance fee) up to 48 hours before event; thereafter, credit only.
  10. Without Event Insurance: credit only with advanced notification; no refunds.

Stripe Session Configuration 📦

During stripeCheckout(), the service merges custom text into the session data:

$defaultSessionData = [
    // ...
    'custom_text' => [
        'terms_of_service_acceptance' => [
            'message' => $terms,
        ],
    ],
    'consent_collection' => ['terms_of_service' => 'required'],
    // ...
];
Session::create($stripeSessionData);
  • custom_text.terms_of_service_acceptance.message: Supplies our dynamic policy copy to Stripe’s modal.
  • consent_collection: Ensures users must accept TOS to proceed.

Front-End Display: cancelation-policy.blade.php 🖥️

A Blade partial renders the policy on the public event page before checkout:

@php
  $invoiceDeadline = $event->invoice_deadline?->format('F jS, Y') ?? '';
  $dayAfter = $event->invoice_deadline?->addDay()->format('F jS, Y') ?? '';
@endphp

<div class="text-xs">
  <p>
    By clicking the button above, you agree to the {{ $event->website->name }}
    terms and conditions, and the following cancellation policy.
    @if ($event->isTournament())
      …tournament policy…
    @elseif($event->isShowcase())
      @if (Session::has('cart') && collect(Session::get('cart'))
           ->where('name','Event Insurance')->count())
        …insurance policy…
      @else
        …no-insurance policy…
      @endif
    @endif
  </p>
</div>

This snippet matches the server-side logic, ensuring consistency between the site UI and Stripe modal.


Policy Flowchart

flowchart TD
  A[User Clicks Checkout] --> B{buildTermsAndConditions}
  B -->|Tournament| C[Tournament Policy]
  B -->|Showcase + Insurance| D[Insurance Policy]
  B -->|Showcase – Insurance| E[No-Insurance Policy]
  C --> F[Inject into Stripe Session]
  D --> F
  E --> F
  F --> G[Stripe Checkout Modal]

Dependencies & Relations

  • Event Model
  • isTournament(), isShowcase(), and invoice_deadline methods/attributes.
  • Stripe SDK
  • Stripe::setApiKey(), Session::create(), consent_collection.
  • Configuration
  • services.stripe.payment_method_configuration in config/services.php.
  • Cart & Order Services
  • SaveOrderService processes items and metadata before checkout.

Key Takeaways 📋

  • Single Source of Truth: Logic lives in one method, reused by both Stripe and Blade.
  • Dynamic Copy: Adapts to event type and insurance selection at runtime.
  • Mandatory Consent: Enforced via Stripe’s consent_collection.
  • Consistency: Ensures messaging is identical on-site and in the Stripe modal.

By centralizing policy message generation and aligning front-end and Stripe flows, the platform delivers a clear, compliant, and user-friendly checkout experience.