API Documentation

This document provides an overview of the APIs available in the api.php file. These APIs allow interaction with the system for account management, payouts, transactions, promo codes, and reporting.

API Endpoints

1. GET /account

Fetches the balance of the current user's account.

Example Response:
{
    "user": 100.50
}
        

2. GET /account/{accountId}/ledger

Returns the ledger for a specific account.

3. POST /payout/request

Submits a payout request for the current user.

Request Body:
{
    "account_type": "user",
    "amount": 50.00
}

Example Response:
{
    "status": "pending",
    "message": "Payout request submitted."
}
        

4. GET /payout/history

Fetches the payout history for the current user.

5. POST /refund/request

Submits a refund request for a specific ticket.

Request Body:
{
    "ticket_id": "12345",
    "reason": "Event canceled"
}

Example Response:
{
    "status": "requested",
    "message": "Refund submitted."
}
        

6. GET /promo-codes

Lists all promo codes created by the current user.

7. GET /promo-code-usage

Fetches usage records for a specific promo code.

Query Parameter:
?code=CODE123
        

8. GET /transactions

Fetches all transactions for the current user.

9. POST /transaction

Creates a new transaction for a ticket sale.

Request Body:
{
    "ticket_id": "12345",
    "event_id": "67890",
    "amount": 100.00,
    "promo_code": "PROMO123",
    "ref_1_id": 1,
    "ref_1_desc": "Reference 1 Description",
    "ref_2_id": 2,
    "ref_2_desc": "Reference 2 Description"
}

Example Response:
{
    "transaction_id": "98765",
    "message": "Transaction created successfully."
}
        

10. POST /payout/{requestId}/approve

Approves a payout request.

Request Body:
{
    "external_reference": "BANK123"
}
        

11. POST /payout/{requestId}/reject

Rejects a payout request with a reason.

Request Body:
{
    "reason": "Insufficient funds"
}
        

12. POST /payout/{requestId}/paid

Marks a payout request as paid.

Request Body:
{
    "payment_reference": "PAY123"
}
        

Process

The API uses RESTful principles. Each endpoint corresponds to a specific functionality, and the HTTP method determines the action:

All requests require authentication via a token. Ensure the token is included in the request headers.

Error Handling

If an error occurs, the API returns a JSON response with an error message and a corresponding HTTP status code.

Example Error Response:
{
    "error": "Unauthorized"
}