Hoppa till huvudinnehåll
Petanque Life

Payment Processing

F08.02 11 features Plattform+

I korthet

Payment Processing is the gateway-agnostic settlement layer that records, reconciles, refunds and audits every inbound payment against the Invoice it clears, integrating Stripe Checkout for cards and bank-debit, Swish QR for Swedish payers, Bankgirot transfer matching, multi-currency capture with ECB rate freeze, refund flows, club bulk-payment fan-out and Azure Key Vault-backed gateway credentials behind one uniform Payment lifecycle.

Så fungerar det

Each payment is anchored to an Invoice and progresses through a tracked status lifecycle written to /payments/. Online card and bank-debit settlement runs through Stripe Checkout: clients call POST /checkout/ with gateway=stripe, the user is redirected to Stripe Checkout, and the platform listens on POST /webhooks/stripe for checkout.session.completed (creates Payment, updates Invoice, generates receipt, distributes revenue), checkout.session.expired (marks the session expired) and payment_intent.payment_failed (flags failure). Swedish payers can pay by Swish; POST /checkout/ with gateway=swish returns a base64 QR payload, the Swish app posts back to /webhooks/swish, and the same Payment-creation pipeline executes.

Bank transfers settle through the Bank Reconciliation subsystem, which writes Payment rows when an inbound BGI line matches an Invoice OCR reference. Receipt PDFs are emitted on demand via /receipts/{id}/pdf. Refunds run through /payments/{id}/gateway-refund, which reverses the original Stripe charge or Swish settlement and writes a corresponding negative Payment.

Multi-currency support stores both transaction currency and tenant base currency on every Payment, with the ECB reference rate frozen at invoice-issue time to keep historical conversions reproducible. Club bulk payment lets a club treasurer settle every member licence in one Stripe session that fans out into per-member Payment rows. Per-tenant payment gateways are configured via /payment-gateways/, with credentials stored as Azure Key Vault references rather than plaintext secrets.

Every Payment writes a structured audit row queryable through /payment-history/{debtor_id}, and the entire pipeline is idempotent on Stripe event id and Swish callback id to survive webhook replays.

Centrala funktioner

  • Stripe Checkout integration with webhook-driven Payment creation, receipt generation and revenue distribution
  • Swish QR-code flow for Swedish payers with same downstream pipeline as Stripe
  • Refund processing via /payments/{id}/gateway-refund that reverses the original gateway charge
  • Club bulk payment that fans one Stripe session out to per-member Payment rows
  • Multi-currency support with ECB reference rate frozen on the originating Invoice
  • Per-tenant gateway configuration with credentials stored as Azure Key Vault references
  • Idempotent webhook processing and full audit trail through /payment-history/{debtor_id}

I praktiken

A French club treasurer opens the licence renewal cart for 47 members and chooses Pay all by card. The platform creates one Stripe Checkout session totalling 2 350 EUR; he completes the card payment in Stripe. Within seconds the platform receives checkout.session.completed, creates 47 Payment rows linked to 47 invoices, generates 47 receipts, runs revenue distribution to ligue, comite and insurance pools and emails the treasurer a master receipt with a per-member breakdown.

Two weeks later one member requests a refund; the treasurer hits Refund on that member's invoice, /payments/{id}/gateway-refund reverses the line through Stripe, and a negative Payment row is appended to /payment-history/.

Features i detta subsystem

11
ID Status Funktioner
F08.02.01 Levererad ✅ Payment recording and status tracking
F08.02.02 Planerad ✅ Online payment gateway integration (Stripe, PayPal, local providers)
F08.02.03 Planerad ✅ Bank transfer payment matching
F08.02.04 Levererad ✅ Payment receipt generation
F08.02.05 Planerad ✅ Installment payment plans (split license fee over months)
F08.02.06 Levererad ✅ Payment reconciliation
F08.02.07 Planerad ✅ Refund processing
F08.02.08 Planerad ✅ Club bulk payment (club pays all member licenses)
F08.02.09 Planerad ✅ Multi-currency support (international competitions)
F08.02.10 Levererad ✅ Payment audit trail
F08.02.11 Levererad ✅ Affiliate hybrid signup med Stripe Payment Link — gated av sys_support-godkännande, 14 d expiry, valuta klassificeras per land (SE→SEK, NO→NOK, DK→DKK, GB→GBP, CH→CHF, övriga→EUR), webhook driver provisionering via PL-T003 ✅ PL-T302