# MIB Financing API ## Overview Financing data is fetched from the MIB **WebView** host (`faisamobilex-wv.mib.com.mv`), which is separate from the API host (`faisanet.mib.com.mv`). The response is an HTML page; financing deal data is embedded in `data-*` attributes on card elements. --- ## Endpoint ``` GET https://faisamobilex-wv.mib.com.mv/financing?dashurl=1 ``` ### Authentication Session cookies from the login flow must be sent with the request: | Cookie | Value | |----------------|---------------------------------------------| | `mbmodel` | `IOS-1.0` (literal string) | | `xxid` | Session ID from login (`MibSession.xxid`) | | `IBSID` | Same as `xxid` | | `mbnonce` | `nonceGenerator` string from login response | | `time-tracker` | `597` (literal string) | ### Request Headers | Header | Value | |--------------------|------------------------------------| | `User-Agent` | Standard Android WebView UA string | | `X-Requested-With` | `mv.com.mib.faisamobilex` | --- ## Response **Content-Type:** `text/html; charset=UTF-8` The response is a full HTML page. Each financing deal is represented as a `
` with the class `finance-card-holder` and all deal fields embedded as `data-*` attributes: ```html
``` ### Data Fields | Field | Type | Description | |-----------------------|---------|------------------------------------------------------| | `productDesc` | String | Product name (e.g. "Ujalaa CG Finance") | | `dealStatus` | String | Status code: `P` = Active/Pending | | `statusDesc` | String | Human-readable status (e.g. "Approved") | | `dealAmount` | Decimal | Total financing amount | | `dealNo` | Integer | Unique deal/contract number | | `paidAmount` | Decimal | Amount paid to date | | `outstandingAmount` | Decimal | Remaining unpaid balance | | `dealDate` | String | Contract start date (`yyyy-MM-dd HH:mm:ss`) | | `overdueAmount` | Decimal | Amount currently overdue (0 if none) | | `installmentAmount` | Decimal | Monthly installment amount | | `noOfInstallments` | Integer | Total number of installments | | `lastPaidDate` | String | Date of most recent payment (`yyyy-MM-dd HH:mm:ss`) | | `lastPayAmount` | Decimal | Amount of most recent payment | | `financeCurrency` | Integer | Currency code (462 = MVR) | | `curCodeDesc` | String | Currency abbreviation (e.g. "MVR") | ### Parsing Strategy Use a regex to find all elements with class `finance-card-holder`, then extract all `data-*` attribute key/value pairs from each match: ```kotlin val cardPattern = Regex("""finance-card-holder[^>]+>""") val attrPattern = Regex("""data-(\w+)\s*=\s*"([^"]*)"""") ``` --- ## Completion Date Estimation Remaining installments can be estimated from outstanding and installment amounts: ``` remainingInstallments = ceil(outstandingAmount / installmentAmount) completionDate = today + remainingInstallments months ``` --- ## Notes - The WebView endpoint uses a different subdomain (`faisamobilex-wv`) from the encrypted API (`faisanet`). - No encryption is used; the session is maintained purely via cookies. - The HTML is served gzip/brotli compressed; OkHttp handles decompression automatically. - The `time-tracker` cookie value appears to be static at `597` — its purpose is unclear, but omitting it may affect behavior. - Known product names include consumer goods finance and cash financing variants.