Payments & billing
renox-billing
Subscriptions for Renox apps (plans, trials, upgrades, cancellations) with Stripe and Xendit.
From crates.io
Version 1.3.1
Updated Oct 25, 2026
105 downloads
Install
Run this in your project folder. cargo add renox-billing
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 renox::prelude::*;
use renox_billing::{Billing, Interval, Plan};
App::new()
.module(Auth::new().account()) // the account page shows the subscription
.module(
Billing::new()
.plan(Plan::new("basic", "Basic").price(900, "USD", Interval::Month))
.plan(Plan::new("pro", "Pro").price(1_900, "USD", Interval::Month).trial_days(14))
.stripe() // STRIPE_SECRET, STRIPE_WEBHOOK_SECRET, STRIPE_PRICE_<PLAN>
.xendit(), // XENDIT_SECRET_KEY, XENDIT_CALLBACK_TOKEN (plans `.via("xendit")`)
)
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.