Skip to main content

Vault Workflow

📋 Overview​

Complete workflow for managing user vault accounts and vault transactions. The vault system allows users to create savings accounts, transfer money to/from vault, lock funds for specific periods, and manage vault maturity dates. This workflow covers all vault-related operations including account creation, balance display, money transfers, and fund locking.

🔄 Workflow Steps​

Step 1: Create Vault Account (Save User Wallet)​

  • Purpose: Create a new vault account for the user by associating them with a saving wallet
  • Prerequisites: User must be authenticated and have a valid user ID
  • Process:
    1. Call the Get All Wallets API with wallet_type = 3 to get the main vault wallet ID
    2. Extract the wallet_id from the response (saving wallet type)
    3. Call the Save User Wallet API to create the vault account
    4. Pass the vault wallet_id, user_id, currency_id, and set is_default = false
  • Result: User now has a vault account associated with their profile

Step 2: Display Vault Balance​

  • Purpose: Show the current balance in the user's vault account
  • Process:
    1. Call the Get All Wallets API with wallet_type = 3 to get vault wallet details
    2. Call the Get All User Wallets API with user_id and wallet_id to get user's vault balance
    3. Extract the balance information from the response
    4. Display the vault balance to the user
  • Result: User can see their current vault balance

Step 3: Add Money to Vault (Deposit)​

  • Purpose: Transfer money from main wallet to vault account
  • Process:
    1. Load Currency and Wallet Details: Follow the Common Transaction Flow
    2. Check Product and Calculate Charges:
    3. Execute Wallet Transfer:
      • Call the Wallet Transfer Money API
      • Set txn_code: "SWW" (Sub Wallet Withdraw)
      • Configure transfer from main wallet to vault wallet
      • Set meta_data.source_wallet_name: "Gafa Wallet" and meta_data.destination_wallet_name: "Vault+"

Add Money to Vault Request Example​

{
"charges_info": null,
"txn_amount": 10,
"payment_mode": 3,
"note": null,
"txn_code": "SWW",
"company_admin_user_info": {
"currency_id": "1f1519903ed240578f071aa45cb479f2",
"credit_type": 1,
"credit_type_id": "4010122e9d604e798b9a6e961df3e5b4",
"credit_account_type": 1,
"credit_account_type_id": "640b793d04e2428dbf19ab10399f4edb",
"username": "Mouhamad Amine"
},
"credit_user_info": {
"currency_id": "1f1519903ed240578f071aa45cb479f2",
"credit_type": 3,
"credit_type_id": "3a3d4e585aeb49e8bf3f3996fca0f82f",
"credit_account_type": 2,
"credit_account_type_id": "fb8f09210e0f46b7b4262d77f5b6c273",
"username": "Suresh Raina"
},
"debit_user_info": {
"currency_id": "1f1519903ed240578f071aa45cb479f2",
"debit_type": 1,
"debit_type_id": "4010122e9d604e798b9a6e961df3e5b4",
"debit_account_type": 2,
"debit_account_type_id": "fb8f09210e0f46b7b4262d77f5b6c273",
"username": "Suresh Raina"
},
"txn_device_info": {
"device_name": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36",
"os_name": "MacIntel",
"location": {},
"host_name": "localhost",
"url": "http://localhost:8000"
},
"meta_data": {
"source_wallet_name": "Gafa Wallet",
"destination_wallet_name": "Vault+"
}
}

Step 4: Withdraw Money from Vault​

  • Purpose: Transfer money from vault account back to main wallet
  • Process:
    1. Load Currency and Wallet Details: Follow the Common Transaction Flow
    2. Check Product and Calculate Charges:
    3. Execute Wallet Transfer:
      • Call the Wallet Transfer Money API
      • Set txn_code: "SWW"
      • Configure transfer from vault wallet to main wallet
      • Set meta_data.source_wallet_name: "Vault+" and meta_data.destination_wallet_name: "Gafa Wallet"

Withdraw Money from Vault Request Example​

{
"charges_info": null,
"txn_amount": 10,
"payment_mode": 3,
"note": null,
"txn_code": "SWW",
"company_admin_user_info": {
"currency_id": "1f1519903ed240578f071aa45cb479f2",
"credit_type": 1,
"credit_type_id": "4010122e9d604e798b9a6e961df3e5b4",
"credit_account_type": 1,
"credit_account_type_id": "640b793d04e2428dbf19ab10399f4edb",
"username": "Mouhamad Amine"
},
"credit_user_info": {
"currency_id": "1f1519903ed240578f071aa45cb479f2",
"credit_type": 1,
"credit_type_id": "4010122e9d604e798b9a6e961df3e5b4",
"credit_account_type": 2,
"credit_account_type_id": "fb8f09210e0f46b7b4262d77f5b6c273",
"username": "Suresh Raina"
},
"debit_user_info": {
"currency_id": "1f1519903ed240578f071aa45cb479f2",
"debit_type": 3,
"debit_type_id": "3a3d4e585aeb49e8bf3f3996fca0f82f",
"debit_account_type": 2,
"debit_account_type_id": "fb8f09210e0f46b7b4262d77f5b6c273",
"username": "Suresh Raina"
},
"txn_device_info": {
"device_name": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36",
"os_name": "MacIntel",
"location": {},
"host_name": "localhost",
"url": "http://localhost:8000"
},
"meta_data": {
"source_wallet_name": "Vault+",
"destination_wallet_name": "Gafa Wallet"
}
}

Step 5: Lock Vault Amount​

  • Purpose: Lock funds in the vault for a specific period to prevent withdrawals
  • Process:
    1. Validate Lock Parameters:
      • Ensure vault account exists for the user
      • Validate lock amount is available in vault
      • Set appropriate lock and maturity dates
    2. Create Wallet Lock:
      • Call the Save User Wallet Lock API
      • Pass wallet_id (vault wallet), user_wallet_id, currency_id, locked_amount, locked_date, and maturity_date
    3. Handle Response:
      • If successful, show confirmation message
      • If duplicate lock exists, show appropriate error message

Step 6: Modify Vault Maturity Date​

  • Purpose: Update the maturity date of an existing vault lock
  • Process:
    1. Get Existing Lock Details:
    2. Update Lock:
    3. Handle Response:
      • If successful, show confirmation message
      • If lock not found, show appropriate error message

📡 API References​

Core Vault APIs​

Common Transaction APIs​

🔄 Flow Logic​

Vault Account Creation Flow​

User Request → Get Vault Wallet → Save User Wallet → Vault Account Created

Vault Balance Display Flow​

User Request → Get Vault Wallet → Get User Wallet → Display Balance

Vault Deposit Flow​

User Request → Load Currency/Wallet → Check SWTR Product → Calculate Charges → Transfer Money (Main → Vault) → Success

Vault Withdrawal Flow​

User Request → Load Currency/Wallet → Check SWW Product → Calculate Charges → Transfer Money (Vault → Main) → Success

Vault Lock Flow​

User Request → Validate Parameters → Save Wallet Lock → Lock Created

Vault Lock Update Flow​

User Request → Get Existing Lock → Update Lock → Lock Modified

💡 Key Implementation Notes​

Transaction Codes​

  • SWTR: Sub Wallet Transfer (for adding money to vault)
  • SWW: Sub Wallet Withdraw (for withdrawing money from vault)

Wallet Types​

  • Type 3: Saving Wallet (Vault wallet type)

Account Types​

  • Credit Type 1: Company Admin Account
  • Credit Type 3: Vault Wallet Account
  • Debit Type 1: Company Admin Account
  • Debit Type 3: Vault Wallet Account

Meta Data Configuration​

  • Deposit: source_wallet_name: "Gafa Wallet", destination_wallet_name: "Vault+"
  • Withdrawal: source_wallet_name: "Vault+", destination_wallet_name: "Gafa Wallet"

Error Handling​

  • Duplicate Vault Account: Handle case where user already has a vault account
  • Insufficient Balance: Check vault balance before withdrawal
  • Lock Conflicts: Prevent duplicate locks for same user/wallet combination
  • Invalid Dates: Validate lock and maturity dates

🎯 Use Cases​

Personal Savings​

  • Users can create vault accounts for personal savings goals
  • Lock funds for specific periods to prevent impulsive spending
  • Track savings progress with balance display

Financial Planning​

  • Set up structured savings plans with maturity dates
  • Create multiple vault accounts for different savings goals
  • Manage long-term financial objectives

Investment Preparation​

  • Lock funds for investment opportunities
  • Create time-bound savings for specific investments
  • Manage investment capital allocation

Emergency Funds​

  • Create locked emergency funds with specific maturity dates
  • Ensure funds are available when needed
  • Maintain financial discipline through fund locking