Create Order Payment
Create a new order payment.
HTTP Request
POST/api/orders/:order_id/payments
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| order_id | Integer | Yes | Unique ID of the order to create a payment for |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| payment_method | Integer | Yes | ID of the payment method |
| amount | Integer | Yes | Payment amount (in smallest currency unit) |
| approved | Boolean | No | Whether the payment is approved (default: false) |
| transaction_id | String | No | External transaction identifier |
| notes | String | No | Additional notes about the payment |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# Create a new order payment
4response = requests.post('http://www.example.com/api/orders/123/payments',
5 json={
6 'payment_method': 5,
7 'amount': 5000,
8 'approved': True,
9 'transaction_id': 'TXN_ABC123',
10 'notes': 'Credit card payment processed successfully'
11 },
12 headers={'Authorization': 'Token <your_api_key>'}
13)
14print(response.json())
15
16# Create minimal payment
17response = requests.post('http://www.example.com/api/orders/123/payments',
18 json={
19 'payment_method': 2,
20 'amount': 2500
21 },
22 headers={'Authorization': 'Token <your_api_key>'}
23)
24print(response.json())1# Create a new order payment
2curl -X POST "http://www.example.com/api/orders/123/payments" -H "Authorization: Token <your_api_key>" -H "Content-Type: application/json" -d '{
3 "payment_method": 5,
4 "amount": 5000,
5 "approved": true,
6 "transaction_id": "TXN_ABC123",
7 "notes": "Credit card payment processed successfully"
8}'
9
10# Create minimal payment
11curl -X POST "http://www.example.com/api/orders/123/payments" -H "Authorization: Token <your_api_key>" -H "Content-Type: application/json" -d '{
12 "payment_method": 2,
13 "amount": 2500
14}'Status Codes
| Code | Description |
|---|---|
| 201 | Order payment created successfully |
| 400 | Bad request — invalid input |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the order payment |
| payment_method | Integer | ID of the payment method (write-only) |
| payment_method_data | Object | Payment method details (read-only) |
| approved | Boolean | Whether the payment is approved |
| amount | Integer | Payment amount (in smallest currency unit) |
| transaction_id | String | External transaction identifier |
| notes | String | Additional notes about the payment |
| created_at | String (ISO 8601) | Timestamp when payment was created |
| updated_at | String (ISO 8601) | Timestamp when payment was last updated |
Payment Method Data Fields:
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the payment method |
| name | String | Name of the payment method |
| image | Object | Image details for the payment method |
Image Data Fields:
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the image |
| width | Integer | Width of the image in pixels |
| height | Integer | Height of the image in pixels |
| mode | String | Color mode of the image (e.g., RGB, RGBA) |