Table of Contents
#95 — "Prepaid" payment method has no connection to Customer Wallets (Resolved)
← Back to Manara Bugs · View issue #95 in MantisBT
Reported by: Khaled Tarabay on 2026-07-27T14:32:05+01:00
Assigned to: Claude
Resolved by: Claude on 2026-07-27T15:50:10+01:00
Severity: major
Priority: normal
Reproducibility: always
Category: General
Description: Selecting “Prepaid” as a Payment Method when recording a payment does not check, deduct from, or create any record in the separate Customer Wallets module. Recording a $45.00 payment with method=“Prepaid” against a customer with zero wallet history succeeded normally but no wallet entry was created, no balance was checked, and there was no block despite the customer having no prepaid funds available. Rechecked against a brand-new customer created fresh via the real Customers form (never in /wallet) — still true: payment accepted with zero field errors, customer still absent from Wallets afterward. The equivalent bug on the Wallets side (BUG-W04) is fixed, but this Payments-side counterpart is not. Recording a payment with method=“Prepaid” must draw down the customer's actual Customer Wallets balance, and if the customer has insufficient wallet balance the payment must be rejected with a clear error such as “Insufficient wallet balance customer has $X available.” On success, a corresponding debit transaction must appear in the customer's /wallet history, linked to the invoice/payment mirroring the two-way link BUG-W04's fix already implements from the Wallets side.
Steps to Reproduce: Pick a customer absent from /wallet. Create and Issue an invoice for that customer ($45.00 charge). Record a payment with Payment Method = “Prepaid” for the full amount. Confirm invoice shows PAID = $45.00 (currently happens) but customer still doesn't appear in /wallet (bug; should have been blocked or drawn down a real balance).
Resolution: FIXED — implemented for real this session (a prior pass had left this as “as-designed, no linkage intended,” matching the existing Mobile Wallet precedent; this ticket's detail — plus its sibling #99 — made clear the intended fix was to actually wire it up, so it now is).
Where: app/controllers/PaymentController.php (validate() + store()), app/classes/Billing/WalletTransaction.php (create() made reentrant + a bridge-skip flag), app/classes/Billing/PaymentMethod.php (new codeFor()).
What: recording a payment with Payment Method = “Prepaid” now draws down the customer's real Customer Wallets balance. validate() pre-checks the wallet balance (via CustomerWallet::balanceFor()) and rejects with “Insufficient wallet balance — customer has $X available.” if the amount exceeds it. On success, store() records the payments row as before, then calls WalletTransaction::create() (inside the SAME database transaction, so an insufficient-balance race rolls back the payment too) to record a real wallet DEBIT linked to the invoice/payment — it shows up in the customer's /wallet history immediately, exactly mirroring what BUG-W04/Mantis #52 already does from the Wallets side (a wallet entry that settles an invoice). A new optional $bridgeInvoicePayment=false flag on WalletTransaction::create() stops it from ALSO trying to insert a second payments row for the same invoice (that's the #52 bridge, the reverse direction) — the one that already exists here is the only one.
Verified live against the local database, reproducing the ticket's exact steps: customer with zero wallet history, credited $22 via a standalone Credit (see #99), then created a $45 invoice — attempting to pay the full $45 via Prepaid was correctly REJECTED (“Insufficient wallet balance — customer has $22.00 available.”); paying $15 via Prepaid instead succeeded, the wallet balance correctly dropped 22.00 → 7.00, exactly ONE payments row exists for the invoice (no duplicate from the bridge), and a real wallet_transactions row (direction=debit, source=invoice_payment, reference=“Payment #30”) is linked to both. Full test suite: 29/29 passing. Test data removed afterward.
Activity / Notes
- 2026-07-27T15:50:08+01:00 - Claude: FIXED — implemented for real this session (a prior pass had left this as “as-designed, no linkage intended,” matching the existing Mobile Wallet precedent; this ticket's detail — plus its sibling #99 — made clear the intended fix was to actually wire it up, so it now is).
Where: app/controllers/PaymentController.php (validate() + store()), app/classes/Billing/WalletTransaction.php (create() made reentrant + a bridge-skip flag), app/classes/Billing/PaymentMethod.php (new codeFor()).
What: recording a payment with Payment Method = “Prepaid” now draws down the customer's real Customer Wallets balance. validate() pre-checks the wallet balance (via CustomerWallet::balanceFor()) and rejects with “Insufficient wallet balance — customer has $X available.” if the amount exceeds it. On success, store() records the payments row as before, then calls WalletTransaction::create() (inside the SAME database transaction, so an insufficient-balance race rolls back the payment too) to record a real wallet DEBIT linked to the invoice/payment — it shows up in the customer's /wallet history immediately, exactly mirroring what BUG-W04/Mantis #52 already does from the Wallets side (a wallet entry that settles an invoice). A new optional $bridgeInvoicePayment=false flag on WalletTransaction::create() stops it from ALSO trying to insert a second payments row for the same invoice (that's the #52 bridge, the reverse direction) — the one that already exists here is the only one.
Verified live against the local database, reproducing the ticket's exact steps: customer with zero wallet history, credited $22 via a standalone Credit (see #99), then created a $45 invoice — attempting to pay the full $45 via Prepaid was correctly REJECTED (“Insufficient wallet balance — customer has $22.00 available.”); paying $15 via Prepaid instead succeeded, the wallet balance correctly dropped 22.00 → 7.00, exactly ONE payments row exists for the invoice (no duplicate from the bridge), and a real wallet_transactions row (direction=debit, source=invoice_payment, reference=“Payment #30”) is linked to both. Full test suite: 29/29 passing. Test data removed afterward.
Full History
| Date | User | Field | Change |
|---|---|---|---|
| 2026-07-27T14:32:05+01:00 | Khaled Tarabay | issue-new | New Issue |
| 2026-07-27T15:50:02+01:00 | Claude | Assigned To | ⇒ Claudine |
| 2026-07-27T15:50:06+01:00 | Claude | tag-added | Tag Attached: done-by-claude |
| 2026-07-27T15:50:08+01:00 | Claude | note-added | Note Added: 0000054 |
| 2026-07-27T15:50:10+01:00 | Claude | Status | new ⇒ resolved |
Synced automatically from MantisBT issue #95.
