Skip to content

User - Invoices

Base URL: https://your-domain.com

Admin endpoints for managing invoices. All endpoints require admin/staff authentication.


Fetch All Invoices

Retrieve a paginated list of all invoices with optional filters. Returns invoice data with package, reseller sales details, and salesperson information.

PropertyValue
EndpointFetch All Invoices
MethodGET
URL/api/v1/invoices
AuthenticationBearer Token

Request Headers:

HeaderValueRequired
Acceptapplication/jsonYes
AuthorizationBearer your-auth-tokenYes

Query Parameters:

Required Parameters

ParameterTypeRequiredDescription
isp_idintegerYesISP ID
branch_idintegerYesBranch ID

Pagination Parameters

ParameterTypeRequiredDescription
offsetintegerNoPagination offset (default: 0)
limitintegerNoResults per page (default: 100)

Filter Parameters

ParameterTypeRequiredDescription
package_idintegerNoFilter by package ID
salesperson_idintegerNoFilter by salesperson ID
invoice_statusintegerNoFilter by status (1=Paid, 2=Unpaid, 3=Cancelled, 4=Refunded, 5=Partial, 6=Due)

Request Body: None

Success Response (200 OK):

json
{
    "success": true,
    "data": {
        "invoices": [
            {
                "id": 123,
                "invoice_number": "INV-2024-0123",
                "subscriber_id": 1,
                "subscriber_name": "John Doe",
                "amount": 1000,
                "status": "paid",
                "payment_date": "2024-01-15 10:30:00",
                "created_at": "2024-01-01 00:00:00"
            }
        ],
        "total": 150
    }
}

Error Response (401 Unauthorized):

json
{
    "success": false,
    "message": "Unauthenticated"
}

cURL Example:

bash
curl -X GET "https://your-domain.com/api/v1/invoices?isp_id=1&branch_id=1&offset=0&limit=100" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer your-auth-token"

View Invoice

View a single invoice with full details including package, subscriber, salesperson, action by data, and associated payment information.

PropertyValue
EndpointView Invoice
MethodGET
URL/api/v1/invoices/view
AuthenticationBearer Token

Path Parameters:

ParameterTypeRequiredDescription
idintegerYesInvoice ID

Query Parameters:

ParameterTypeRequiredDescription
isp_idintegerYesISP ID
branch_idintegerYesBranch ID
user_idintegerYesUser ID

Success Response (200 OK):

json
{
    "success": true,
    "data": {
        "id": 123,
        "invoice_number": "INV-2024-0123",
        "subscriber_id": 1,
        "subscriber_name": "John Doe",
        "package_name": "10MB Package",
        "amount": 1000,
        "discount": 0,
        "tax": 0,
        "total": 1000,
        "status": "paid",
        "payment_method": "Cash",
        "payment_date": "2024-01-15 10:30:00",
        "notes": "",
        "created_at": "2024-01-01 00:00:00"
    }
}

Error Response (404 Not Found):

json
{
    "success": false,
    "message": "Invoice not found"
}

cURL Example:

bash
curl -X GET "https://your-domain.com/api/v1/invoices/view?id=1&isp_id=1&branch_id=1" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer your-auth-token"

Update Invoice

Update invoice status or billing note. Cannot modify invoices that have been activated.

PropertyValue
EndpointUpdate Invoice
MethodPUT
URL/api/v1/invoices/update
AuthenticationBearer Token

Path Parameters:

ParameterTypeRequiredDescription
idintegerYesInvoice ID

Request Headers:

HeaderValueRequired
Content-Typeapplication/jsonYes
Acceptapplication/jsonYes
AuthorizationBearer your-auth-tokenYes

Request Body:

json
{
    "status": "paid",
    "notes": "Paid via cash"
}
ParameterTypeRequiredDescription
statusstringNoInvoice status (paid, unpaid, pending)
notesstringNoAdditional notes

Success Response (200 OK):

json
{
    "success": true,
    "message": "Invoice updated successfully"
}

Error Response (404 Not Found):

json
{
    "success": false,
    "message": "Invoice not found"
}

cURL Example:

bash
curl -X PUT "https://your-domain.com/api/v1/invoices/update" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer your-auth-token" \
  -d '{
    "id": 1,
    "isp_id": 1,
    "branch_id": 1,
    "invoice_status": 1,
    "billing_note": "Payment received via cash"
  }'

Delete Invoice

Delete/Cancel an invoice. Cannot delete invoices that have been activated - mark as cancelled instead.

PropertyValue
EndpointDelete Invoice
MethodDELETE
URL/api/v1/invoices/delete
AuthenticationBearer Token

Query Parameters:

ParameterTypeRequiredDescription
isp_idintegerYesISP ID
branch_idintegerYesBranch ID
user_idintegerYesUser ID

Success Response (200 OK):

json
{
    "success": true,
    "message": "Invoice deleted successfully"
}

Error Response (404 Not Found):

json
{
    "success": false,
    "message": "Invoice not found"
}

Error Response (400 Bad Request):

json
{
    "success": false,
    "message": "Cannot delete paid invoice"
}

cURL Example:

bash
curl -X DELETE "https://your-domain.com/api/v1/invoices/delete?id=1&isp_id=1&branch_id=1" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer your-auth-token"

www.onezeroart.com