Payment System

PayPal integration with 6-hop state machine and commission tracking

What It Does

Full payment lifecycle management. Tracks from billing through collection with automated reminders. PayPal webhooks handle online payments; manual entry covers clinic payments. The system auto-calculates the 10% commission owed on Oshun revenue.

External Service Details

External service: PayPal (sandbox + live modes)

Oshun deal: $500/mo base + 10% commission on all client revenue.

Required environment variables:

Journeys

The Payment System is the backbone of Journey 9:

Key Source Files

Payment State Machine

  1. awaiting — payment expected, no action yet
  2. grace — grace period active, soft reminder sent
  3. staff_prompted — staff notified to follow up
  4. patient_prompted — patient directly reminded
  5. at_risk — escalation begins, account flagged
  6. reconciliation — final resolution in progress
  7. complete — payment confirmed and recorded

Escalation timeline: Day 3 warning → Day 7 suspend → Day 14 final → Day 30 cancel

Database Tables

Known Issues

None currently.