Fee Calculation — Test Cases
Feature version: v1.0
Reference doc: Finance System — Deposit Fee
Result notation: ✅ Pass | ❌ Fail | ⏭ Skip | 🐛 Fail + bug report
Changelog
| Date | Version | Change | Author |
|---|---|---|---|
| 2026-06-25 | v1.1 | Added withdrawal payment-gate minimum fee (paymentGateFeeMinUsd) test cases | — |
| 2026-05-10 | v1.0 | Initial creation | — |
TC-FEE-001 — Deposit Fee Logic 🆕 NEW
Precondition: Fee configured in
payment_provider_fee_configs. A shop-linked player is needed to verify the shop USD wallet impact.
| # | Description | Steps | Expected Result | Actual Result |
|---|---|---|---|---|
| 1 | Player receives full credits — fee is not deducted from credits | Deposit $10 with feeRate=10% → Check player wallet | Player receives 10 credits (not 9) | |
| 2 | Fee is deducted from the shop's USD share | Shop receives USD after player deposits $10 with feeRate=10% | Shop USD wallet: +$9 (shop receives $10 − $1 fee) | |
| 3 | Shop profit calculated correctly | shopRate=0.80; player deposits $10; fee=10% | Shop profit = $9 − (10 × $0.80) = $9 − $8 = $1 | |
| 4 | Fee lookup — exact match takes highest priority | Fee config exists for both (provider, 'deposit', methodId) and (provider, 'deposit', 'all') | The methodId exact-match fee rate is used | |
| 5 | Fee lookup — fallback to 'all' when no exact match | No fee for specific methodId; fee exists for (provider, 'deposit', 'all') | The 'all' fallback fee rate is used | |
| 6 | Fee lookup — default = 0 when nothing matches | No fee config exists for the provider | platformFeeRate = 0, platformFeeAmount = 0 | |
| 7 | Fee rate is an immutable snapshot | Create a transaction → Change the fee config → Check the old transaction | The fee on the old transaction does not change | |
| 8 | Fee resolution failure is non-blocking | Simulate an error in resolveProviderFeeRate() | Transaction proceeds with feeRate = 0 |
TC-FEE-002 — Withdrawal Payment Gate Minimum Fee 🆕 NEW
Precondition: Withdrawal fee config with
paymentGateFeeRateandpaymentGateFeeMinUsdset for a provider/method. NET receive model active.
| # | Description | Steps | Expected Result | Actual Result |
|---|---|---|---|---|
| 1 | Minimum fee applies when percent is lower | Configure gate 1%, min $2.60 → Player withdraws $10 NET | gatewayFeeAmount = $2.60, gatewayPayoutUsd = $12.60 | |
| 2 | Percent fee applies when higher than minimum | Same config → Player withdraws $500 NET | gatewayFeeAmount = $5.00 (1%), gatewayPayoutUsd = $505.00 | |
| 3 | Zero minimum behaves as percent-only | paymentGateFeeMinUsd = 0, gate 1% → withdraw $10 NET | gatewayFeeAmount = $0.10, gatewayPayoutUsd = $10.10 | |
| 4 | Min fee does not change player NET receive | Any withdrawal with min fee configured | Player still receives exactly the requested netPayoutUsd; extra cost is on funding tier + gateway payout | |
| 5 | Min fee snapshot is immutable | Complete withdrawal → change min in admin config → check old transaction | Old transaction keeps original gatewayFeeAmount / gatewayPayoutUsd | |
| 6 | Admin can configure min per provider/method | Admin Portal → Provider Fees → withdrawal row → set "Payment gate min fee (USD)" | Value saved in payment_provider_fee_configs.payment_gate_fee_min_usd | |
| 7 | Deposit fees ignore gate minimum | Deposit with same provider config that has min on withdrawal | Deposit fee uses percent on gross only; min not applied |