Payment Invoices API
Endpoints for managing payment invoices in the system.
Get Payment Invoices List
Get the complete list of payment invoices.
Request
GET /api/payment-invoices
Headers
Name | Type | Description |
---|---|---|
X-API-Key | string | Required. API key |
Query Parameters
Name | Type | Description |
---|---|---|
is_paid | boolean | Optional. Filter by payment status |
user_id | integer | Optional. Filter by user ID |
page | integer | Optional. Page number |
per_page | integer | Optional. Records per page |
Response
{
"payment_invoices": [
{
"id": 1,
"user_id": 123,
"gateway": "paypal",
"transaction_id": "1AB23456CD789012E",
"amount": 100.00,
"original_amount": 100.00,
"currency_id": 1,
"currency": "USD",
"is_paid": true,
"paid_at": "2023-01-01T01:00:00Z",
"created_at": "2023-01-01T00:00:00Z"
}
]
}
Response Fields
Field | Type | Description |
---|---|---|
payment_invoices | array | Array of payment invoices |
id | integer | Invoice ID |
user_id | integer | User ID |
gateway | string | Payment gateway key |
transaction_id | string | Transaction ID (can be null) |
amount | number | Payment amount |
original_amount | number | Original amount (before discounts) |
currency_id | integer | Currency ID |
currency | string | Currency code |
is_paid | boolean | Payment status |
paid_at | string | Payment date (can be null) |
created_at | string | Creation date |
Response Codes
Code | Description |
---|---|
200 | Successful request |
401 | Invalid or missing API key |
403 | Insufficient permissions to perform request |
Get Payment Invoice Data
Get detailed information about a specific payment invoice.
Request
GET /api/payment-invoices/{id}
Path Parameters
Name | Type | Description |
---|---|---|
id | integer | Payment invoice ID |
Headers
Name | Type | Description |
---|---|---|
X-API-Key | string | Required. API key |
Response
{
"payment_invoice": {
"id": 1,
"user_id": 123,
"user": {
"id": 123,
"name": "John Doe",
"email": "[email protected]"
},
"gateway": "paypal",
"transaction_id": "1AB23456CD789012E",
"amount": 100.00,
"original_amount": 100.00,
"currency_id": 1,
"currency": "USD",
"is_paid": true,
"paid_at": "2023-01-01T01:00:00Z",
"created_at": "2023-01-01T00:00:00Z"
}
}
Response Codes
Code | Description |
---|---|
200 | Successful request |
401 | Invalid or missing API key |
403 | Insufficient permissions to perform request |
404 | Payment invoice not found |
Create Payment Invoice
Create a new payment invoice in the system.
Request
POST /api/payment-invoices
Headers
Name | Type | Description |
---|---|---|
X-API-Key | string | Required. API key |
Content-Type | string | Required. application/json |
Request Body
{
"user_id": 123,
"gateway": "stripe",
"amount": 75.50,
"currency_id": 1,
"promo_code": "DISCOUNT10"
}
Request Body Parameters
Name | Type | Description |
---|---|---|
user_id | integer | Required. User ID |
gateway | string | Required. Payment gateway key |
amount | number | Required. Payment amount |
currency_id | integer | Required. Currency ID |
promo_code | string | Optional. Promo code for discount |
Response
{
"message": "Payment invoice created successfully",
"payment_invoice": {
"id": 3,
"user_id": 123,
"gateway": "stripe",
"transaction_id": null,
"amount": 67.95,
"original_amount": 75.50,
"currency_id": 1,
"currency": "USD",
"is_paid": false,
"paid_at": null,
"created_at": "2023-03-15T12:00:00Z"
}
}
Response Codes
Code | Description |
---|---|
201 | Payment invoice successfully created |
401 | Invalid or missing API key |
403 | Insufficient permissions to perform request |
404 | User, currency or promo code not found |
422 | Invalid request parameters |
Update Payment Invoice Status
Update the status of an existing payment invoice.
Request
PUT /api/payment-invoices/{id}/status
Path Parameters
Name | Type | Description |
---|---|---|
id | integer | Payment invoice ID |
Headers
Name | Type | Description |
---|---|---|
X-API-Key | string | Required. API key |
Content-Type | string | Required. application/json |
Request Body
{
"is_paid": true,
"transaction_id": "XYZ987654321"
}
Request Body Parameters
Name | Type | Description |
---|---|---|
is_paid | boolean | Required. Payment status |
transaction_id | string | Optional. Transaction ID |
Response
{
"message": "Payment invoice status updated successfully",
"payment_invoice": {
"id": 3,
"user_id": 123,
"gateway": "stripe",
"transaction_id": "XYZ987654321",
"amount": 67.95,
"is_paid": true,
"paid_at": "2023-03-15T12:30:00Z"
}
}
Response Codes
Code | Description |
---|---|
200 | Invoice status successfully updated |
401 | Invalid or missing API key |
403 | Insufficient permissions to perform request |
404 | Payment invoice not found |
422 | Invalid request parameters |
Delete Payment Invoice
Delete a payment invoice from the system (only for unpaid invoices).
Request
DELETE /api/payment-invoices/{id}
Path Parameters
Name | Type | Description |
---|---|---|
id | integer | Payment invoice ID |
Headers
Name | Type | Description |
---|---|---|
X-API-Key | string | Required. API key |
Response
{
"message": "Payment invoice deleted successfully"
}
Response Codes
Code | Description |
---|---|
200 | Payment invoice successfully deleted |
401 | Invalid or missing API key |
403 | Insufficient permissions to perform request |
404 | Payment invoice not found |
422 | Cannot delete paid invoice |