renox-billing
Subscriptions for Renox apps (Laravel's Cashier): plans declared in code, free trials, upgrades and downgrades, cancellations with a grace period, with Stripe and Xendit, plus one-off payments and payment links (Stripe, Xendit, N-Genius).
use *;
use ;
new
.module // the account page shows the subscription
.module
What it adds:
- a plans page (
/billing) that sends the user to the gateway's payment page (Stripe Checkout, Xendit's recurring plan page), and a "Subscription" card on/accountwith "Change plan", "Cancel" and "Resume"; Billing::of(&state, &user):subscribed(),subscribed_to(plan),on_trial(),on_grace_period(),checkout(plan),start_trial(plan),swap(plan),cancel(),cancel_now(),resume(); anyBillableowner (a team) works too;require_subscription()andrequire_plan(&[…])guards for routes;- the gateways' webhooks through
renox::webhook(/billing/webhooks/{gateway}): verified, processed once per event, out-of-order safe, into thesubscriptionsandbilling_customerstables; - the events
SubscriptionCreated,SubscriptionUpdated,SubscriptionCanceled,PaymentSucceededandPaymentFailed, recorded in the activity log when the app has theAuditmodule; - one-off payments:
Billing::of(&state, &user).charge(Charge::new(money).reference("job", 42))andBilling::payment_link(&state, PaymentLink::new(money))store abilling_paymentsrow with your reference;Billing::refund(pending until the gateway confirms, partial refunds add up),Billing::payment_status, disputes, and a scheduledbilling:expire-linkssweep for links that ran out; a success that arrives after a failure is still applied; - keys looked up per installation (
Stripe::resolved(..)) and several accounts per gateway (.account("acme-llc"), webhook/billing/webhooks/{gateway}/{account}); - events
PaymentRefunded,RefundSucceeded,RefundFailed,DisputeOpened,DisputeWon,DisputeLostandPaymentLinkExpired; - Stripe, Xendit and N-Genius (
.ngenius()); another provider is one impl of theGatewaytrait.
The guide is docs/billing.md;
examples/bikeshop uses it for its service plans (Stripe, Xendit and a demo gateway) and to let staff send a work order's payment link
(examples/bikeshop/src/app/workshop/order.rs, pay_link). Versioned with renox: use the same version for both.