A user wallet in Bubble uses a Wallet Data Type linked to each user with a balance field and a Transaction Data Type recording all credits and debits. This tutorial covers designing the wallet data model with proper balance tracking, building the wallet dashboard UI with balance display and transaction history, implementing send and receive money flows between users, and creating a top-up interface connected to Stripe for adding funds.
Overview: User Wallet in Bubble
This tutorial shows you how to build a digital wallet feature where users can view their balance, see transaction history, send money to other users, and add funds through payment processing.
Prerequisites
- A Bubble app with user authentication
- A Stripe account for payment processing (optional)
- Basic understanding of Data Types and Workflows
- Familiarity with number fields and calculations in Bubble
Step-by-step guide
Design the wallet data model
Design the wallet data model
Create a 'Wallet' Data Type with: user (User — one wallet per user), balance (number — current balance in cents to avoid floating point issues), currency (text — e.g. 'USD'). Create a 'WalletTransaction' Data Type with: wallet (Wallet), type (text — credit/debit), amount (number — in cents), description (text), counterparty (User — who the transfer is with), reference_id (text — external payment ref), balance_after (number — balance snapshot after transaction), Created Date. Create the wallet record automatically when a user signs up.
Expected result: Wallet and WalletTransaction Data Types support balance tracking and full transaction history.
Build the wallet dashboard
Build the wallet dashboard
Create a wallet page showing: a large balance display formatted as currency (divide cents by 100), a row of action buttons (Top Up, Send, Receive), and a Repeating Group of WalletTransactions sorted by Created Date descending. Each transaction row shows: icon (green arrow up for credit, red arrow down for debit), description, amount (formatted as +$XX.XX or -$XX.XX), balance after transaction, and date. Add filters above the list: date range picker and type filter (all/credits/debits). Add a summary section showing total credits and debits this month.
Expected result: Users see their current balance, transaction history, and action buttons on the wallet dashboard.
Implement the top-up flow
Implement the top-up flow
When the Top Up button is clicked, show a popup with pre-set amount buttons ($10, $25, $50, $100) and a custom amount input. On confirmation, initiate a Stripe Checkout session for the selected amount. On successful payment (via Stripe webhook), create a WalletTransaction with type = 'credit', the amount, description = 'Top up via card', reference_id = Stripe charge ID, and update the Wallet balance by adding the amount. Set balance_after to the new balance.
Expected result: Users can add funds to their wallet via credit card payment.
Implement user-to-user transfers
Implement user-to-user transfers
When the Send button is clicked, show a popup with: a user search input (to find the recipient), an amount input, and an optional note. Validate that the sender has sufficient balance. In the workflow: create a debit WalletTransaction for the sender (amount subtracted from balance), create a credit WalletTransaction for the recipient (amount added to balance), update both Wallets. Use a backend workflow for this to ensure atomicity — if any step fails, the whole transfer should not partially complete.
Pro tip: Always use backend workflows for transfers to maintain data consistency. Check the sender's balance inside the backend workflow to prevent race conditions where two transfers drain the account simultaneously.
Expected result: Users can send money to other users with proper balance validation and atomic transfer processing.
Add security and audit features
Add security and audit features
Add transaction verification by requiring a PIN or password confirmation before transfers above a threshold amount. Log all wallet operations in a separate AuditLog Data Type for compliance. Add a daily balance reconciliation backend workflow that compares each Wallet's balance against the sum of all its transactions to detect discrepancies. Display a transaction receipt after each operation with a unique reference number. Add low-balance alerts that notify users when their balance drops below a configured threshold.
Expected result: The wallet system includes security verification, audit logging, balance reconciliation, and user alerts.
Complete working example
1USER WALLET SYSTEM SUMMARY2=====================================34DATA MODEL:5 Wallet: user, balance (cents), currency6 WalletTransaction: wallet, type (credit/debit),7 amount (cents), description, counterparty,8 reference_id, balance_after, Created Date910WALLET DASHBOARD:11 Balance: Wallet's balance / 100 as currency12 Actions: Top Up, Send, Receive buttons13 History: RG of transactions (desc by date)14 Credit: green +$XX.XX15 Debit: red -$XX.XX16 Filters: date range, type17 Summary: monthly credits/debits1819TOP UP FLOW:20 Amount selection → Stripe Checkout21 Webhook: payment success22 → Create credit WalletTransaction23 → Update Wallet balance += amount24 → Set balance_after2526TRANSFER FLOW (BACKEND WORKFLOW):27 1. Validate sender balance >= amount28 2. Create debit transaction (sender)29 3. Update sender Wallet balance -= amount30 4. Create credit transaction (recipient)31 5. Update recipient Wallet balance += amount32 6. Notify both parties3334SECURITY:35 PIN/password for large transfers36 Audit log for all operations37 Daily balance reconciliation38 Low-balance alertsCommon mistakes when designing a User Wallet Feature in Bubble
Why it's a problem: Using floating point numbers for balance instead of integers (cents)
How to avoid: Store all monetary values in cents (integers). Divide by 100 only for display formatting.
Why it's a problem: Processing transfers in frontend workflows
How to avoid: Use backend workflows for all balance-changing operations to ensure atomicity and prevent partial transfers
Why it's a problem: Not recording balance_after on each transaction
How to avoid: Calculate and store balance_after on every WalletTransaction for audit and display purposes
Best practices
- Store monetary values in cents (integers) to avoid floating point errors
- Use backend workflows for all balance-changing operations
- Record balance_after on every transaction for audit trails
- Validate sufficient balance before processing debits
- Run daily balance reconciliation to detect discrepancies
- Require additional verification for large transfers
- Log all operations in an audit trail for compliance
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I want to build a digital wallet feature in my Bubble.io app where users can top up with Stripe, send money to each other, and see transaction history. How should I design the data model?
Help me build a user wallet with balance display, transaction history list, top-up via Stripe, and user-to-user transfer capability with proper security validation.
Frequently asked questions
Should I store money values as dollars or cents?
Always store in cents (integers). $10.50 becomes 1050. This avoids floating point arithmetic errors that occur with decimal numbers.
How do I handle negative balances?
Validate balance >= transfer amount before processing any debit. If your business allows negative balances (credit), add a credit_limit field to the Wallet.
Is a Bubble wallet suitable for real money?
For real money applications, consult with a financial compliance expert. Depending on your jurisdiction, you may need money transmitter licenses. Platform credits and virtual currencies have fewer regulatory requirements.
Can I add multiple currencies?
Yes. Add a currency field to Wallet and WalletTransaction. Implement exchange rates and conversion logic for cross-currency transfers.
How do I handle refunds?
Create a credit WalletTransaction referencing the original debit transaction. Update the Wallet balance by adding the refund amount.
Can RapidDev help build a wallet system?
Yes. RapidDev can build secure digital wallet systems in Bubble including payment integration, transfer logic, fraud prevention, and compliance features.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation