Skip to content

Why Payments?

Integrating a payment processor directly inside ProcessWire templates looks simple until a real business needs partial captures, partial refunds, idempotency under double-clicks, multi-currency gateway routing, recurring subscriptions, asynchronous webhook retries, encrypted API keys, and GDPR-safe customer anonymization.

Concern Ad-Hoc Gateway SDK Code ProcessWire Payments
Double-charge protection Manual unique keys per endpoint Built-in idempotency fingerprinting + SELECT ... FOR UPDATE database locks
Multi-gateway routing Hardcoded if/else per currency or region GatewayRepository priority and currency routing across any number of configured gateway instances
Credential storage Plaintext API keys in database or scattered .env reads SecretBox supporting $env:VAR, $config:key, and authenticated sodium_crypto_secretbox (enc:v1:)
Hosted invoice collection Build custom token routes and expiry checks One call to createPaymentLink() generates a SHA-256 hashed /pay/{token} checkout URL
Recurring billing & usage Duplicate webhook handlers and status sync scripts Managed payments_subscriptions + append-only payments_subscription_events tables, metered usage, and ReconcileSubscriptionsTask
Webhook reliability Synchronous endpoint prone to timeouts and duplicate delivery Verified /_payments/webhook/{gatewayHandle} ingestion with ProcessWebhookQueue (payments-webhooks) and replayable audit log
Compliance & privacy Deleting a user breaks financial ledgers or leaks PII contactsParticipant and entriesUserDeleteListener anonymize PII (anonymizeForContact, anonymizeForUser) while keeping ledger totals intact

Because Payments exposes a single gateway-agnostic API and pull-discovered hooks (paymentsWebhookListener, paymentsHooks), upper-layer modules such as Packages, Commerce, Charter, and Account share the same configured gateways, billing plans, invoices, and customer portal links with zero duplicated driver code.

Next steps