Stripe recurring payments

sequenceDiagram participant b as web browser participant p as portal participant k as worker participant w as scheduler participant e as emailer participant s as Stripe b->>p: let's make a plan p->>b: payment plan form loop calculate plans b->>b: plan options end b->>p: create payment plan p->>b: financials form b-->>s: credit card info s-->>p: payment Source p-->>s: client info, Source s-->>p: Customer.id p-->>p: Save Plan, Line Items, Customer.id loop Daily: process today's line items w-->>k: Start the transaction scan job Loop Scan for due transactions k-->>k: Find each due item, add to charge job queue end Loop continually running charge queue k-->>k: Confirm item is still uncharged alt transaction succeeds k-->>s: Charge line item s-->>k: success k-->>k: update line item, remove from queue k-->>e: success email notification to client end alt transaction decline k-->>s: Charge line item s-->>k: declined k-->>e: declined email notification to staff b-->>p: review declined payment plan p->>b: financials form p-->>p: Update payment method b-->>s: credit card info s-->>p: updated payment Source p-->>p: update plan, new payment source p-->>k: add line item to charge queue end end end