Skip to main content

Create Payment Method

Creates a new payment method.

HTTP Request

POST/api/payment/methods

Authorization

Authorization

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

Request Body

FieldTypeRequiredDescription
backendStringYesBackend identifier for the payment method (choices: zarinpal, zibal, pay-on-delivery)
activeBooleanNoWhether the payment method is active (default: true)
orderIntegerNoDisplay row-order of the payment method in the list (default: 0)
nameStringYesName of the payment method (unique)
imageIntegerNoID of the payment method's logo image
descriptionStringNoDescription of the payment method
settingsJsonNoAdditional settings for the payment method (merchant_id, api_key, etc.)

Example Requests

1import requests
2
3# Create a new payment method
4response = requests.post('http://www.example.com/api/payment/methods', 
5  json={
6      'backend': 'zarinpal',
7      'active': True,
8      'order': 1,
9      'name': 'Credit Card',
10      'image': 123,
11      'description': 'Pay with your credit card.',
12      'settings': {
13          'merchant_id': 'your_merchant_id',
14          'api_key': 'your_api_key'
15      }
16  },
17  headers={'Authorization': 'Token <your_api_key>'}
18)
19print(response.json())
20
21# Create minimal payment method
22response = requests.post('http://www.example.com/api/payment/methods', 
23  json={
24      'backend': 'pay-on-delivery',
25      'name': 'Cash on Delivery'
26  },
27  headers={'Authorization': 'Token <your_api_key>'}
28)
29print(response.json())

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

Exmple Response

{
"id": 3,
"active": true,
"backend": "zibal",
"order": 10,
"name": "Zarinpal2",
"image_data": {
"id": 4,
"type": "image",
"name": "rams",
"size": 118805,
"human_readable_size": "116.02 KB",
"f": "http://127.0.0.1:8000/media/core_media/2025/11/29/RAMFeatured.jpg",
"width": 1280,
"height": 720,
"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
}
]
},
"description": "minima",
"settings": {
"a": 1,
"b": 2
},
"auto_approve_payments": false,
"created_at": "2025-12-21T09:47:46.504213Z",
"updated_at": "2025-12-21T09:47:46.504223Z"
}

Notes

  • The settings field must be a valid json