Skip to content

Instantly share code, notes, and snippets.

@yeasin2002
Created November 23, 2025 09:28
Show Gist options
  • Select an option

  • Save yeasin2002/a181a131a1e6ac91d110bb100ef46d38 to your computer and use it in GitHub Desktop.

Select an option

Save yeasin2002/a181a131a1e6ac91d110bb100ef46d38 to your computer and use it in GitHub Desktop.
JobSphere Money Flow

JobSphere Money Flow - Simple Explanation

Last Updated: November 23, 2025
Status: Current Implementation


๐ŸŽฏ Quick Answer to Your Questions

1. How Does Money Work in JobSphere?

YES - Users Recharge Their Wallet First (Prepaid System)

Think of it like a mobile phone plan:

  • Users add money to their wallet ONCE
  • They can use that balance for MULTIPLE transactions
  • No need to pay separately for each job

2. Where Does the Money Go?

Money moves through 3 stages:

  1. Customer's Wallet โ†’ Money added by customer
  2. Escrow (Holding Area) โ†’ Money locked when offer sent
  3. Final Destination โ†’ Split between Admin and Contractor when job completes

๐Ÿ’ฐ The Complete Money Journey

Stage 1: Customer Adds Money to Wallet

What Happens:

  • Customer deposits money (minimum $10)
  • Money goes into their "Available Balance"
  • They can use this for any job

Example:

Customer deposits: $500
Wallet Balance: $500 (available to use)
Escrow Balance: $0 (nothing locked yet)

Important Notes:

  • Currently: Money is added directly (TODO: Stripe integration)
  • Future: Will use Stripe for actual credit card payments
  • Minimum deposit: $10
  • No maximum limit

Stage 2: Customer Sends Job Offer

What Happens:

  • Customer selects a contractor
  • Sends offer with job amount (e.g., $100)
  • System calculates total cost: $105 (job + 5% platform fee)
  • Money moves from "Available" to "Escrow" (locked)

Money Movement: 00 - $105) โ””โ”€ Escrow Balance: $105 (locked until decision)


**Why Escrow?**
- Protects both parties
- Money is safe but not yet transferred
- Can be refunded if contractor rejects
- Prevents customer from spending same money twice

**Cost Breakdown for $100 Job:**

Job Amount: $100 Platform Fee (5%): $5 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Total Charged: $105


---

### Stage 3A: Contractor Accepts Offer โœ…

**What Happens:**
- Contractor reviews and accepts
- Platform fee ($5) goes to Admin immediately
- Remaining money ($100) stays in escrow
- Job status changes to "assigned"

**Money Movement:**

Customer Escrow: $105 โ”œโ”€ Platform Fee: $5 โ†’ Admin Wallet (immediately) โ””โ”€ Remaining: $100 โ†’ Stays in Escrow (until job done)

Admin Wallet: +$5 Customer Escrow: $100 (still locked)


**Why Split Payment?**
- Platform fee = Payment for using JobSphere
- Remaining money = Held until work is completed
- Protects customer from bad work
- Ensures contractor gets paid after completion

---

### Stage 3B: Contractor Rejects Offer โŒ

**What Happens:**
- Contractor declines the offer
- Full amount ($105) refunded to customer
- Money returns to "Available Balance"
- Customer can send new offer

**Money Movement:**

Customer Escrow: $105 โ†’ $0 Customer Available: $395 โ†’ $500 (full refund)

Result: Customer gets all money back


---

### Stage 4: Job Completion ๐ŸŽ‰

**What Happens:**
- Contractor completes work
- Customer marks job as complete
- Service fee (20%) goes to Admin
- Contractor gets their payout (80%)

**Final Money Split for $100 Job:**

Escrow Balance: $100

Split: โ”œโ”€ Service Fee (20%): $20 โ†’ Admin Wallet โ””โ”€ Contractor Payout (80%): $80 โ†’ Contractor Wallet

Final Results: โ”œโ”€ Admin Total: $25 ($5 platform + $20 service) โ”œโ”€ Contractor Gets: $80 โ””โ”€ Customer Paid: $105 total


---

### Stage 5: Contractor Withdraws Money ๐Ÿ’ธ

**What Happens:**
- Contractor has money in wallet
- Requests withdrawal (minimum $10, maximum $10,000)
- Money transferred to their bank account
- Takes 2-3 business days

**Example:**

Contractor Wallet: $80 Requests Withdrawal: $50

After Withdrawal: โ”œโ”€ Wallet Balance: $30 โ””โ”€ Bank Transfer: $50 (pending 2-3 days)


**Important:**
- Only contractors can withdraw
- Customers cannot withdraw (they use balance for jobs)
- Minimum: $10
- Maximum: $10,000 per transaction

---

## ๐Ÿ“Š Complete Example: $100 Job from Start to Finish

### Step 1: Customer Deposits Money

Action: Customer deposits $200 Result: Wallet Balance = $200


### Step 2: Customer Posts Job

Action: Posts job with $100 budget Result: Job visible to contractors


### Step 3: Contractor Applies

Action: Contractor submits application Result: Customer sees application


### Step 4: Customer Sends Offer

Action: Sends $100 offer Calculation:

  • Job Amount: $100
  • Platform Fee (5%): $5
  • Total Charge: $105

Money Movement:

  • Available: $200 โ†’ $95
  • Escrow: $0 โ†’ $105

### Step 5: Contractor Accepts

Action: Accepts offer Money Movement:

  • Escrow: $105 โ†’ $100
  • Admin Wallet: +$5 (platform fee)

Job Status: "assigned"


### Step 6: Work Completed

Action: Customer marks complete Money Movement:

  • Escrow: $100 โ†’ $0
  • Admin Wallet: +$20 (service fee)
  • Contractor Wallet: +$80 (payout)

Final Balances:

  • Customer: $95 available
  • Admin: $25 earned
  • Contractor: $80 earned

### Step 7: Contractor Withdraws

Action: Withdraws $80 Result: $80 sent to bank (2-3 days)


---

## ๐Ÿ”„ Alternative Scenarios

### Scenario A: Offer Rejected

Steps 1-4: Same as above Customer Escrow: $105

Step 5: Contractor Rejects Money Movement:

  • Escrow: $105 โ†’ $0
  • Available: $95 โ†’ $200 (full refund)

Result: Customer gets all money back


### Scenario B: Job Cancelled

Steps 1-5: Same as main example Customer Escrow: $100 Admin Already Got: $5

Step 6: Customer Cancels Job Money Movement:

  • Escrow: $100 โ†’ $0
  • Available: $95 โ†’ $195 (refund $100)

Result:

  • Customer gets $100 back (not the $5 platform fee)
  • Admin keeps $5 platform fee

### Scenario C: Offer Expires (7 Days)

Steps 1-4: Same as above Customer Escrow: $105

After 7 Days: Offer expires automatically Money Movement:

  • Escrow: $105 โ†’ $0
  • Available: $95 โ†’ $200 (full refund)

Result: Customer gets all money back


---

## ๐Ÿ’ก Key Concepts Explained

### What is "Escrow"?

**Simple Explanation:**
- Escrow = A safe holding area for money
- Money is locked but not transferred yet
- Protects both customer and contractor
- Released only when conditions are met

**Think of it like:**
- Putting money in a locked box
- Both parties can see it
- Only opens when job is done (or cancelled)

### What is "Available Balance"?

**Simple Explanation:**
- Money you can use right now
- Not locked in any transaction
- Can send offers with this money
- Can be withdrawn (contractors only)

### What is "Escrow Balance"?

**Simple Explanation:**
- Money locked in pending offers
- Cannot be used for other jobs
- Will be released when offer is decided
- Either goes to contractor or refunded

### Why Two Types of Fees?

**Platform Fee (5%)**
- Charged when offer is sent
- Goes to Admin when offer accepted
- Pays for using JobSphere platform
- Non-refundable after acceptance

**Service Fee (20%)**
- Charged when job completes
- Deducted from contractor's payout
- Pays for transaction processing
- Ensures quality and support

---

## ๐ŸŽจ Visual Money Flow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ CUSTOMER DEPOSITS $200 โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Customer Wallet โ”‚ โ”‚ Balance: $200 โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ Sends $100 Offer โ”‚ (Charged $105) โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Customer Wallet โ”‚ โ”‚ Available: $95 โ”‚ โ”‚ Escrow: $105 โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ โ–ผ โ–ผ ACCEPT REJECT โ”‚ โ”‚ โ–ผ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Platform Fee โ”‚ โ”‚ Full Refund โ”‚ โ”‚ $5 โ†’ Admin โ”‚ โ”‚ $105 โ†’ Back โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ Escrow: $100 โ”‚ โ”‚ Available: โ”‚ โ”‚ (Still Locked)โ”‚ โ”‚ $200 โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ Job Completed โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Final Split โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ Service Fee: $20 โ”‚ โ”‚ โ†’ Admin Wallet โ”‚ โ”‚ โ”‚ โ”‚ Contractor: $80 โ”‚ โ”‚ โ†’ Contractor Wallet โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Contractor Withdraws โ”‚ โ”‚ $80 โ†’ Bank Account โ”‚ โ”‚ (2-3 business days) โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


---

## ๐Ÿ“‹ Transaction Types in Database

The system tracks every money movement:

| Type | When | From | To | Description |
|------|------|------|-----|-------------|
| `deposit` | Customer adds money | Customer | Customer | Wallet top-up |
| `escrow_hold` | Offer sent | Available | Escrow | Lock money for offer |
| `platform_fee` | Offer accepted | Escrow | Admin | 5% platform fee |
| `service_fee` | Job completed | Escrow | Admin | 20% service fee |
| `contractor_payout` | Job completed | Escrow | Contractor | 80% payment |
| `refund` | Offer rejected/cancelled | Escrow | Available | Money returned |
| `withdrawal` | Contractor withdraws | Wallet | Bank | Cash out |

---

## โš ๏ธ Important Rules

### For Customers:
1. โœ… Must have money in wallet before sending offers
2. โœ… Money is locked in escrow when offer sent
3. โœ… Get full refund if contractor rejects
4. โœ… Platform fee ($5) non-refundable after acceptance
5. โŒ Cannot withdraw money (use it for jobs only)

### For Contractors:
1. โœ… Can accept or reject offers
2. โœ… Get 80% of job amount when complete
3. โœ… Can withdraw anytime (min $10, max $10,000)
4. โœ… Money arrives in 2-3 business days
5. โŒ Cannot send offers (only customers can)

### For Admin:
1. โœ… Gets 5% when offer accepted
2. โœ… Gets 20% when job completed
3. โœ… Total commission: 25% per job
4. โœ… Money auto-transferred (no manual work)

---

## ๐Ÿ”ฎ Future Enhancements (TODO)

### Currently Missing:
- โŒ Stripe integration for deposits (currently manual)
- โŒ Stripe Connect for withdrawals (currently manual)
- โŒ Webhook handling for payment confirmations
- โŒ Dispute resolution system
- โŒ Partial refunds

### Coming Soon:
- โœ… Real credit card payments via Stripe
- โœ… Automatic bank transfers for withdrawals
- โœ… Payment failure handling
- โœ… Chargeback protection
- โœ… Multi-currency support

---

## ๐Ÿ†š Comparison: Current vs Future

### Current System (Wallet-Based)

Customer โ†’ Deposits to Wallet โ†’ Uses Balance โ†’ Sends Offers โ†“ (Manual/Direct)


**Pros:**
- Simple to understand
- Fast transactions
- No payment gateway fees per transaction
- Users can budget better

**Cons:**
- Requires upfront deposit
- Money locked in platform
- No instant credit card payments

### Future System (Hybrid)

Customer โ†’ Option 1: Deposit to Wallet (prepaid) โ†’ Option 2: Pay per job (Stripe)


**Benefits:**
- Flexibility for users
- Both prepaid and pay-per-use
- Better for one-time users
- Stripe handles security

---

## ๐Ÿ“ž Common Questions

### Q: Why do I need to deposit money first?
**A:** It's a prepaid system like a mobile phone. You add credit once and use it for multiple jobs. This makes transactions faster and cheaper.

### Q: What if I don't have enough balance?
**A:** You'll see an error: "Insufficient balance. Required: $105, Available: $50". Just deposit more money first.

### Q: Can I get my money back?
**A:**
- โœ… YES if contractor rejects offer (full refund)
- โœ… YES if you cancel before acceptance (full refund)
- โŒ NO platform fee ($5) after contractor accepts
- โœ… YES remaining money if you cancel after acceptance

### Q: How long does withdrawal take?
**A:** 2-3 business days for money to reach your bank account.

### Q: Is my money safe in escrow?
**A:** YES! Escrow money is locked and cannot be used by anyone until the job is completed or cancelled. It's like a safe deposit box.

### Q: What happens if contractor doesn't complete work?
**A:** You can cancel the job and get a refund of the escrow amount (minus the platform fee already paid).

---

## ๐ŸŽฏ Summary

**JobSphere uses a PREPAID WALLET SYSTEM:**

1. **Customers deposit money once** โ†’ Use for multiple jobs
2. **Money moves to escrow** โ†’ When offer sent (locked safely)
3. **Platform fee taken** โ†’ When contractor accepts (5%)
4. **Service fee taken** โ†’ When job completes (20%)
5. **Contractor gets paid** โ†’ 80% of job amount
6. **Contractor withdraws** โ†’ Money to bank account

**Key Benefit:** Fast, secure, and transparent money flow with complete audit trail.

---

**Document Status**: โœ… Reflects Current Implementation
**Last Verified**: November 23, 2025
**Code Location**: `src/api/wallet/`, `src/api/offer/`

Before Offer: โ”œโ”€ Available Balance: $500 โ””โ”€ Escrow Balance: $0

After Sending $100 Offer: โ”œโ”€ Available Balance: $395 ($5


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment