Update Order Payment
Update an existing order payment.
HTTP Request
PATCH/api/orders/:id/payments/:payment_id
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | Integer | Yes | Unique ID of the order to update |
| order_payment_id | Integer | Yes | Unique ID of the order payment to update |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| payment_method | Integer | No | ID of the payment method |
| amount | Integer | No | Payment amount (in smallest currency unit) |
| approved | Boolean | No | Whether the payment is approved |
| transaction_id | String | No | External transaction identifier |
| notes | String | No | Additional notes about the payment |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# Partial update (PATCH)
4response = requests.patch('http://www.example.com/api/orders/123/payments/456',
5 json={
6 'approved': True,
7 'transaction_id': 'TXN_UPDATED_789',
8 'notes': 'Payment approved after verification'
9 },
10 headers={'Authorization': 'Token <your_api_key>'}
11)
12print(response.json())
13
14# Update payment status only
15response = requests.patch('http://www.example.com/api/orders/123/payments/456',
16 json={
17 'approved': False
18 },
19 headers={'Authorization': 'Token <your_api_key>'}
20)
21print(response.json())
22
23# Update amount and payment method
24response = requests.patch('http://www.example.com/api/orders/123/payments/456',
25 json={
26 'amount': 7500,
27 'payment_method': 3
28 },
29 headers={'Authorization': 'Token <your_api_key>'}
30)
31print(response.json())1# Partial update (PATCH)
2curl -X PATCH "http://www.example.com/api/orders/123/payments/456" -H "Authorization: Token <your_api_key>" -H "Content-Type: application/json" -d '{
3 "approved": true,
4 "transaction_id": "TXN_UPDATED_789",
5 "notes": "Payment approved after verification"
6}'
7
8# Update payment status onlyPayment
9curl -X PATCH "http://www.example.com/api/orders/123/payments/456" -H "Authorization: Token <your_api_key>" -H "Content-Type: application/json" -d '{
10 "approved": false
11}'Status Codes
| Code | Description |
|---|---|
| 200 | Order payment updated successfully |
| 400 | Bad request — invalid input |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | Not found — order payment does not exist |
| 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) |