# Wallet APIs ## Fetch Balance Flow ```sequence Client->Server: UserID Server-->Twid: MobileNo Twid-->Server: Balance Note over Server: Record Balance in DB Server->Client: Balance Note over Client: Balance Page ``` ## Fetch Balance: *Inactive* **GET** /expresso/mandir/api/wallet/info.php?job=fetchBalance&userId=2 HTTP/1.1 Host: trell.co Request ``` job: fetchBalance userId: string or int ``` Response ```https://hackmd.io/new { "success": true, "message": "balance retrieved", "userSummary": { "userId": "2", "deviceId": "a3fa8681-62cc-447f-be50-87013d36bfa6", "mobile": "7506575335", "userAvatar": "https:\/\/cdn.trell.co\/images\/mandir\/profile\/2_pp.jpeg", "username": "Ambedkar", "referralLink": "https:\/\/srimandir.app.link\/refer\/E4263", "isProfileComplete": true, "coinSummary": { "currentStreakStartDate": "2020-07-20", "currentStreakDuration": "2", "currentStreakEndDate": "2020-07-21", "coinBalance": "78", "todayCoinEarn": null, "levelId": "4", "levelName": "\u091a\u0924\u0941\u0930\u094d\u0925 \u091a\u0915\u094d\u0930", "levelTarget": "51", "levelImageUrl": "https:\/\/cdn.trell.co\/images\/mandir\/coinLevels\/4.png" }, "walletSummary": { "realAmount": "150", "totalAmount": "170", "isMember": "0" }, "walletBalance": "170", "cards": [] } } ``` > Note: Use totalAmount in walletSummary to show user balance, not walletBalance --- ## Fetch Recharge Plans: *Inactive* **GET** /expresso/mandir/api/wallet/info.php?job=fetchRechargePlans&userId=2 HTTP/1.1 Host: trell.co Request ``` job: fetchRechargePlans userId: string or int ``` Response ```https://hackmd.io/new { "success": true, "message": "recharge plans fetched", "rechargePlans": [ { "rechargeId": "1", "realAmount": "100", "totalAmount": "100" }, { "rechargeId": "2", "realAmount": "200", "totalAmount": "220" }, { "rechargeId": "3", "realAmount": "500", "totalAmount": "600" }, { "rechargeId": "4", "realAmount": "1000", "totalAmount": "1200" } ] } ``` --- ## Fetch Resource Prices: *Inactive* **GET** /expresso/mandir/api/wallet/info.php?job=fetchResourcePrices&userId=2 HTTP/1.1 Host: trell.co Request ``` job: fetchResourcePrices userId: string or int ``` Response ```https://hackmd.io/new { "success": true, "message": "resources fetched", "resourcePrices": [ { "redeemId": "1", "price": "50", "resourceId": "1", "resourceName": "" } ] } ``` --- ## Recharge Flow ```sequence Note over Client: User chooses Plan Client->Server: Recharge Plan, UserID Server-->Twid: MobileNo Twid-->Server: PWA Hash Note over Server: Registers Txn in DB (real+ virtual) Server->Client: PWA Hash Client->Twid: PWA Hash Note over Twid: Payment Handshake Twid->Client: Txn status (real) Note over Client: Txn Complete UI (real) Twid-->Server: Txn status (real) Note over Server: Txn Marked Complete (real) Server-->Twid: amount (virtual) Twid-->Server: Balance Note over Server: Txn Marked Complete (virtual) Note over Server: Record Balance in DB Note over Client: Fetch Balance Flow Client->Server: UserId Server->Client: Balance Note over Client: Balance UI ``` ## Recharge Wallet: *Inactive* **GET** /expresso/mandir/api/wallet/add.php?userId=2&rechargeId=2 HTTP/1.1 Host: trell.co Request ``` userId: string or int rechargeId: string or int ``` Response ```https://hackmd.io/new { "data": { "brand_key": "WFcnB62BZfsVC5DZqv2aQDDV95ek4a2n", "customer_pwa_hash": "pwa_hash_738e75d1-5865-4805-acf8-fdce76df511a", "pg_source": "payu", "mobile": "7506575335", "hash_webhook_url": "https:\/\/trell.co\/expresso\/mandir\/api\/wallet\/hashWebhook.php", "merchant_transaction_id": 44, "bill_amount": 200, "callback_url": "", "transaction_webhook_url": "https:\/\/trell.co\/expresso\/mandir\/api\/wallet\/webhook.php" }, "success": true, "message": "token generated and transaction(s) initiated" } ``` --- ## Demo Transaction Webhook Call (For tests only): *Inactive* **GET** /expresso/mandir/api/wallet/demoCall.php HTTP/1.1 Host: trell.co Response ```https://hackmd.io/new { "error_code": "0", "status": true, "message": "Data added successfully", "data": null } ``` --- ## Redeem Flow ```sequence Note over Client: Fetch Balance Flow Note over Client: Choose Recharge Plan for Resource Note over Client: Recharge Flow (if required) Client->Server: Resource Id Server-->Twid: MobileNo, Redeem Amount Twid-->Server: Redeem Success, Balance Note over Server: Registers Balance in DB Server->Client: Resource Privilege Note over Client: Resource UI ``` --- ## Redeem Wallet Balance: *Inactive* **GET** /expresso/mandir/api/wallet/redeem.php?userId=2&resourceId=2 HTTP/1.1 Host: trell.co Request ``` userId: string or int resourceId: string or int ``` Response ```https://hackmd.io/new { "success": true, "message": "amount redeemed", "data": {} } ``` --- ## Fetch Commerce Resources: *Inactive* **GET** /expresso/mandir/api/wallet/info.php?job=fetchCommerceResources&userId=2 HTTP/1.1 Host: trell.co Request ``` job: fetchCommerceResources userId: string or int ``` Response ```https://hackmd.io/new { "success": true, "message": "resources fetched", "walletBalance": "5909", "resourcePrices": { "offering": [ { "resourceId": "1", "isVisible": true, "isLocked": false, "resourceName": "offering_flower_genda", "resourceNameLocal": "\u0917\u0947\u0902\u0926\u093e", "resourceImage": null, "mrp": "0", "afterDiscountPrice": 0 }, { "resourceId": "2", "isVisible": true, "isLocked": false, "resourceName": "offering_flower_mogra", "resourceNameLocal": "\u092e\u094b\u0917\u0930\u093e", "resourceImage": null, "mrp": "101", "afterDiscountPrice": 41 } ], "donation": [ { "resourceId": "8", "isVisible": true, "isLocked": true, "resourceName": "donation_hundi_11", "resourceNameLocal": "\u20b911", "resourceImage": null, "mrp": "11", "afterDiscountPrice": 11 }, { "resourceId": "10", "isVisible": false, "isLocked": false, "resourceName": "donation_hundi_51", "resourceNameLocal": "\u20b951", "resourceImage": null, "mrp": "51", "afterDiscountPrice": 51 } ] } } ``` ---