Skip to main content

Update Order Payment

Update an existing order payment.

HTTP Request

PATCH/api/orders/:id/payments/:payment_id

Authorization

Authorization

  • Required: Yes
  • Permission: Staff with OrderPaymentPermission or Admin
  • Permission Code: 2243
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Path Parameters

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the order to update
order_payment_idIntegerYesUnique ID of the order payment to update

Request Body

FieldTypeRequiredDescription
payment_methodIntegerNoID of the payment method
amountIntegerNoPayment amount (in smallest currency unit)
approvedBooleanNoWhether the payment is approved
transaction_idStringNoExternal transaction identifier
notesStringNoAdditional notes about the payment

Example Requests

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())

Response Fields

FieldTypeDescription
idIntegerUnique ID of the order
keyStringUnique key of the order (read-only)
statusStringCurrent status of the order
customer_dataObjectCustomer information (read-only)
payment_method_dataObjectPayment method information (read-only)
shipping_method_dataObjectShipping method information (read-only)
shipping_costNumberCost of shipping
notesStringOrder notes
extraObjectAdditional order data
created_atString (ISO 8601)Timestamp when order was created
updated_atString (ISO 8601)Timestamp when order was last updated
billing_country_dataObjectBilling country information (read-only)
billing_state_dataObjectBilling state information (read-only)
billing_city_dataObjectBilling city information (read-only)
billing_addressStringBilling address
billing_postal_codeStringBilling postal code
billing_national_codeStringBilling national code
billing_mobile_numberStringBilling mobile number
billing_first_nameStringBilling first name
billing_last_nameStringBilling last name
countIntegerNumber of items in order (computed field)
quantityIntegerTotal quantity of items (computed field)
items_subtotalNumberSubtotal of all items (computed field)
items_discountNumberTotal discount on items (computed field)
subtotalNumberOrder subtotal (computed field)
total_discountNumberTotal discount amount (computed field)
totalNumberOrder total amount (computed field)
amount_paidNumberAmount already paid (computed field)
amount_outstandingNumberOutstanding amount (computed field)
is_paidBooleanWhether order is fully paid (computed field)
itemsArrayList of order items (read-only)
paymentsArrayList of order payments (read-only)

Customer Structure

The customer object contains:

FieldTypeDescription
idIntegerCustomer ID
usernameStringCustomer username
mobile_numberStringCustomer mobile number
first_nameStringCustomer first name
last_nameStringCustomer last name
full_nameStringCustomer full name (computed)

Payment Method Structure

The payment_method object contains:

FieldTypeDescription
idIntegerPayment method ID
nameStringPayment method name
imageObjectPayment method image data

Shipping Method Structure

The shipping_method object contains:

FieldTypeDescription
idIntegerShipping method ID
nameStringShipping method name
imageObjectShipping method image data

Image Data Structure

FieldTypeDescription
idIntegerUnique ID of the image
typeStringFile type (e.g., image/jpeg)
nameStringOriginal file name
sizeIntegerFile size in bytes
human_readable_sizeStringHuman readable file size (e.g., 2.5 MB)
fStringURL to access the image file
widthIntegerImage width in pixels
heightIntegerImage height in pixels
modeStringColor mode (e.g., RGB, CMYK)
thumbnailsList of thumbnail objectsImgae thumbnails

Thumbnail Data Structure

FieldTypeDescription
idIntegerUnique ID of the thumbnail (unique)
fStringURL to access the thumbnail file
sizeIntegerFile size in bytes (nullable)

Geographic Data Structures

Country, state, and city objects contain:

Country/State:

FieldTypeDescription
idIntegerLocation ID
nameStringLocation name
codeStringLocation code

City:

FieldTypeDescription
idIntegerCity ID
nameStringCity name

Order Items Structure

Each item in the items array contains:

FieldTypeDescription
idIntegerUnique ID of the order item
productIntegerUnique ID of the product
product_nameStringCurrent Product Name
product_dataJsonFieldSnapshot of product data at time of order
unit_priceIntegerPrice per unit (in smallest currency unit)
unit_discountIntegerDiscount per unit (in smallest currency unit)
quantityIntegerQuantity ordered
notesStringItem-specific notes
subtotalIntegerCalculated subtotal (computed field)
discountIntegerTotal discount for this item (computed field)
totalIntegerFinal total for this item (computed field)
created_atString (ISO 8601)Item creation timestamp
updated_atString (ISO 8601)Item last update timestamp

Order Payment Structure

Each item in the payments array contains:

  • The shipping method structure here is the same as the above-mentioned ShippingMethod Structure.
FieldTypeDescription
idIntegerId of the order payment
payment_method_dataObjectPayment method data of the order payment
approvedBooleanWhether the order payment is approved
amountIntegerThe order payment amount
transaction_idStringThe transaction id of the order payment
notesStringThe extra notes about the order payment
created_atString (ISO 8601)The creation datetime of the order payment
updated_atString (ISO 8601)The last updated datetime of the order payment

Example Response

{
"id": 2,
"key": "0c86ab758d3e236cb5a4",
"status": "shipped",
"customer_data": {
"id": 1,
"username": "BehroozGhorbani",
"mobile_number": "09308744204",
"first_name": "بهروز",
"last_name": "قربانی",
"full_name": "بهروز قربانی"
},
"payment_method_data": {
"id": 1,
"name": "پرداخت در مخل",
"image": null
},
"shipping_method_data": {
"id": 1,
"name": "پیک موتور",
"image": {
"id": 8,
"type": "image",
"name": "پیک موتوری",
"size": 808754,
"human_readable_size": "789.80 KB",
"f": "http://127.0.0.1:8000/media/core_media/2025/12/20/Fantasticheskie_kartinki_dlja_monitora_68_63.jpg",
"width": 1920,
"height": 1080,
"mode": "RGB",
"thumbnails": [
{
"id": 213,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_64x64.jpg",
"size": 64
},
{
"id": 214,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_128x128.jpg",
"size": 128
},
{
"id": 215,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_512x512.jpg",
"size": 512
},
{
"id": 216,
"f": "http://127.0.0.1:8000/media/core_media/2026/02/02/thumbnails/test2_ecH0zVV_thumbnail_1080x1080.jpg",
"size": 1080
}
]
}
},
"shipping_cost": 75000,
"notes": "Facilis sequi alias optio. Alias ipsam deserunt. At veniam nam et. Et aut id id aut quae non animi. Sed tempora aut ut ipsa dicta vel eveniet et aspernatur.",
"extra": {
"some": "data"
},
"created_at": "2025-12-27T18:17:09.771123Z",
"updated_at": "2025-12-28T11:28:47.290350Z",
"billing_country_data": {
"id": 1,
"name": "ایران",
"code": "IR"
},
"billing_state_data": {
"id": 1,
"name": "آذربایجان شرقی",
"code": "EA"
},
"billing_city_data": {
"id": 1,
"name": "اسکو"
},
"billing_address": "5411 Stokes Grove",
"billing_postal_code": "1234567890",
"billing_national_code": null,
"billing_mobile_number": "09523296536",
"billing_first_name": "پدرام",
"billing_last_name": "زمانی",
"count": 0,
"quantity": 0,
"items_subtotal": 0,
"items_discount": 0,
"subtotal": 0,
"total_discount": 0,
"total": 75000,
"amount_paid": 500000,
"amount_outstanding": -425000,
"is_paid": true,
"is_payable": true,
"items": [],
"payments": [
{
"id": 1,
"payment_method_data": {
"id": 1,
"name": "پرداخت در مخل",
"image": null
},
"approved": true,
"amount": 500000,
"transaction_id": "1589800",
"notes": "",
"created_at": "2025-12-28T10:43:38.509103Z",
"updated_at": "2025-12-28T10:43:38.509107Z"
},
{
"id": 2,
"payment_method_data": {
"id": 2,
"name": "زرین پال",
"image": {
"id": 5,
"type": "image",
"name": "keyboard",
"size": 2131742,
"human_readable_size": "2.03 MB",
"f": "http://127.0.0.1:8000/media/core_media/2025/11/29/Fantasticheskie_kartinki_dlja_monitora_68_96.jpg",
"width": 2560,
"height": 1600,
"mode": "RGB"
}
},
"approved": false,
"amount": 9800,
"transaction_id": "12345678910111213",
"notes": "by zarinpal",
"created_at": "2025-12-28T13:20:31.445502Z",
"updated_at": "2025-12-28T13:27:08.022228Z"
}
]
}