Subscriptions, Usage & Marketplace
Payments provides a full recurring billing engine backed by the payments-plans Entries collection plus the transactional payments_subscriptions and append-only payments_subscription_events managed SQL tables (entries_tbl_payments_*).
Subscription Lifecycle
Section titled “Subscription Lifecycle”<?php namespace ProcessWire;
$payments = Payments::requireInstance($wire);
// Create a subscription against a payments-plans handle$sub = $payments->subscribe([ 'plan_handle' => 'aegean-club-pro', 'gateway_handle' => 'stripe-eur', 'user_id' => (int) $user->id, 'quantity' => 1,]);
// Upgrade/downgrade plans or adjust seat quantities$payments->switchPlan($sub->id, 'aegean-club-fleet');$payments->updateSubscriptionQuantity($sub->id, 4);
// Pause, resume, or cancel (at period end or immediately)$payments->pauseSubscription($sub->id);$payments->resumeSubscription($sub->id);$payments->cancelSubscription($sub->id, immediately: false);
// Check active entitlement in templates or middleware$isMember = $payments->hasActiveSubscription((int) $user->id, 'aegean-club-fleet');Metered Usage Billing
Section titled “Metered Usage Billing”For drivers implementing MeteredSubscriptionGatewayInterface, record incremental or set usage quantities against an active subscription and inspect the current billing period summary:
<?php namespace ProcessWire;
$payments->recordUsage($sub->id, quantity: 3, metadata: ['metric' => 'marina_berth_nights']);$usage = $payments->getUsageSummary($sub->id);Customer Portal & Invoices
Section titled “Customer Portal & Invoices”Let signed-in members update payment methods, manage subscriptions, and download invoices without building custom billing forms:
<?php namespace ProcessWire;
// Provider-hosted billing portal URL (per subscription or per user)$portalUrl = $payments->customerPortalUrl($sub->id, returnUrl: 'https://aegeanvoyages.example/account/billing');$userPortalUrl = $payments->customerPortalUrlForUser((int) $user->id, returnUrl: 'https://aegeanvoyages.example/account/billing');
// List invoices and resolve a signed/authenticated PDF download URL$invoices = $payments->listInvoicesForUser((int) $user->id);$pdfUrl = $payments->resolveInvoicePdfUrl($invoices[0]['id'], (int) $user->id);Marketplace Splits & Sub-Merchants
Section titled “Marketplace Splits & Sub-Merchants”For platforms collecting funds on behalf of yacht owners, brokers, or vendors (gateways implementing MarketplaceGatewayInterface), Payments supports sub-merchant onboarding, platform fees (platformFeeMinor), multi-party splits, and explicit payouts:
<?php namespace ProcessWire;
use Totoglu\Payments\Domain\Money;use Totoglu\Payments\Domain\PaymentIntentRequest;
$subMerchant = $payments->createSubMerchantAccount('stripe-eur', [ 'business_name' => 'Blue Horizon Maritime Ltd.', 'country' => 'TR',]);
$splitIntent = new PaymentIntentRequest( amount: Money::fromMajor('14700.00', 'EUR'), payableType: 'charter_booking', payableId: 'CHR-2026-209', idempotencyKey: 'charter:CHR-2026-209:split', platformFeeMinor: 147000, // 10% platform commission splits: [ ['account_id' => $subMerchant['account_id'], 'amount_minor' => 1323000], ],);
$transfer = $payments->createMarketplaceTransfer('stripe-eur', [ 'destination' => $subMerchant['account_id'], 'amount' => Money::fromMajor('13230.00', 'EUR'), 'reference' => 'CHR-2026-209',]);Step-by-Step: Managing a Member Subscription in Admin UI
Section titled “Step-by-Step: Managing a Member Subscription in Admin UI”- Open Setup -> Payments -> Plans and confirm your recurring plan (
aegean-club-pro) is published and linked to your active gateway handle. - When a member checks out, monitor their status under Setup -> Payments -> Subscriptions (
trialing,active,past_due,paused, orcanceled). - Click any subscription row to inspect its append-only
payments_subscription_eventstimeline, trigger a pause/resume, or cancel at period end without issuing manual API calls.