Integrations
Wallet and Subscription Credits
How plan credits and permanent credits actually work in Bunship.
This is the core monetization layer for template buyers. Billing events and AI usage both settle into wallet balances.
What You Get
- Two-bucket wallet model:
planBalance: resets by subscription cyclepermanentBalance: top-up credits, non-expiring
- Automatic deduction priority: plan first, permanent second
- Full ledger trail in
t_wallet_transaction - User wallet APIs in
/v1/wallet/*
Code Map
- Wallet schema:
packages/db/src/drizzle/schema/wallet.ts - User wallet API:
apps/ship-api/src/module/wallet.ts - Wallet services:
apps/ship-api/src/services/wallet/index.ts - User UI:
apps/ship/src/app/[locale]/(app)/credits - Admin UI:
apps/ship/src/app/[locale]/(admin)/admin/wallets
Real Flow in Production
- Stripe checkout succeeds.
- Webhook writes order/subscription updates.
- Wallet service grants or refreshes credits.
- Consumption (for example AI generation) deducts balances.
- All mutations are queryable in wallet transaction history.
What Buyers Usually Customize
- Credits granted per plan.
- Top-up package definitions and price points.
- Ledger labels/meta shown in UI.
- Manual adjustment policy for admin operations.
Launch Checklist
- Subscription renewals grant the expected credits exactly once.
- Cancellations and refunds do not leave stale balance states.
- Wallet transaction history in UI matches DB ledger.
- Admin manual operations are audited.