Skip to main content

Update Payment Method

Updates an existing payment method. Only provided fields will be updated.

HTTP Request

PATCH/api/payment/methods/:id

Authorization

Authorization

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

Path Parameters

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the payment method to update

Request Body

FieldTypeRequiredDescription
backendStringNoBackend identifier for the payment method (zarinpal, pay-on-delivery)
activeBooleanNoWhether the payment method is active
orderIntegerNoOrder of the payment method in the list
nameStringNoName of the payment method
imageIntegerNoID of the payment method's logo image
descriptionStringNoDescription of the payment method
settingsObjectNoAdditional settings for the payment method (merchant_id, api_key, etc.)

Example Requests

1import requests
2
3# Update payment method status and order
4response = requests.patch('http://www.example.com/api/payment/methods/123', 
5  json={
6      'active': False,
7      'order': 5,
8      'description': 'Temporarily disabled for maintenance'
9  },
10  headers={'Authorization': 'Token <your_api_key>'}
11)
12print(response.json())
13
14# Update payment method settings
15response = requests.patch('http://www.example.com/api/payment/methods/123', 
16  json={
17      'settings': {
18          'merchant_id': 'new_merchant_id',
19          'api_key': 'new_api_key',
20          'sandbox': False
21      }
22  },
23  headers={'Authorization': 'Token <your_api_key>'}
24)
25print(response.json())

Status Codes

CodeDescription
200Payment method updated successfully
400Bad request — invalid input
401Unauthorized — authentication required
403Forbidden — insufficient permissions
404Not found — payment method does not exist
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the payment method
backendStringBackend identifier for the payment method
activeBooleanWhether the payment method is active
orderIntegerOrder of the payment method in the list
nameStringName of the payment method
image_dataObjectImage details (read-only)
descriptionStringDescription of the payment method
settingsObjectAdditional settings for the payment method
created_atString (ISO 8601)Timestamp when the payment method was created
updated_atString (ISO 8601)Timestamp when the payment method was last updated

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)

Settings Structure

this response field depends on the payment method backend type and may include fields such as:

FieldTypeDescription
merchant_idStringMerchant ID for payment gateway (e.g., Zarinpal)
api_keyStringAPI key for authenticating requests to the payment gateway