Receive total stats of payments and transactions in the given date range and filters.
| Permission | Description |
|---|---|
payments.view_all | View data of all payments in the system |
payments.view_own | View only own payment data |
| Name | Type | Required | Description | Example |
|---|---|---|---|---|
| type | string | No | See available types. Comma-separated | "wallet,subscription" |
| payable_type | string | No | Filter by payable type(s), comma-separated | "gym,plan" |
| payable_id | int | No | Filter by payable ID(s), comma-separated | "1,2,3" |
| user_id | int | No | Filter by user ID(s), comma-separated | "10,20" |
| is_done | bool | No | Filter by completion status | true |
| is_rejected | bool | No | Filter withdrawals by rejection state | true |
| start_date | string | No | Start of date range (YYYY-MM-DD) | "2024-01-01" |
| end_date | string | No | End of date range (YYYY-MM-DD) | "2024-01-31" |
| min_amount | number | No | Minimum amount | 100 |
| max_amount | number | No | Maximum amount | 1000 |
| description | string | No | Search in description | "membership" |
| sort | string | No | Sort order: desc or asc; anything else is a 422 | "desc" |
Every filter is optional and checked for shape only. A comma-separated ID filter must be digits and commas (1,2,3, spaces around the commas allowed), at most 1000 characters; a date must be a parseable date, and a blank one (start_date=) means today. A filter sent as an array (?user_id[]=1) or a malformed date or ID list (1,abc) returns 422. Values that match nothing (an unknown type, a short payable_type such as gym) return an empty result, not an error.
GET /api/v1/payments/data/stats?type=income&user_id=10
Authorization: Bearer {token}
Returns stats for each type of payment record.
{
"total_income": 123,
"total_commission": 123,
"total_deposit": 123,
"total_withdrawal": 123,
"total_purchase": 123,
"total_store_purchase": 123
}
Normal users can use this as a overall payment report for their own account, and admins can use it as the whole system cash flow stats. For example the total amount of commissions, would be the total income of the application.
total_store_purchase is Premium sold through an app store's in-app billing. It is reported apart
from total_purchase because the two are different rails: a store collected that money and settles
out of band, so it never passed through a wallet. Add them for total Premium revenue; never treat
one as a subset of the other. See Store billing.
| Status | Description | Reference |
|---|---|---|
| 401 | Unauthorized | Authentication error |
| 422 | A malformed filter (see Query Parameters) | Validation error |