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
| Field | Type | Required | Description |
|---|---|---|---|
| backend | String | Yes | Backend identifier for the payment method (choices: zarinpal, zibal, pay-on-delivery) |
| active | Boolean | No | Whether the payment method is active (default: true) |
| order | Integer | No | Display row-order of the payment method in the list (default: 0) |
| name | String | Yes | Name of the payment method (unique) |
| image | Integer | No | ID of the payment method's logo image |
| description | String | No | Description of the payment method |
| settings | Json | No | Additional settings for the payment method (merchant_id, api_key, etc.) |
Example Requests
- 🐍 Python
- 🌐 Curl
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())1# Create a new payment method
2curl -X POST "http://www.example.com/api/payment/methods" \
3-H "Authorization: Token <your_api_key>" \
4-H "Content-Type: application/json" \
5-d '{
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
18# Create minimal payment method
19curl -X POST "http://www.example.com/api/payment/methods" \
20-H "Authorization: Token <your_api_key>" \
21-H "Content-Type: application/json" \
22-d '{
23 "backend": "pay-on-delivery",
24 "name": "Cash on Delivery"
25}'Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the payment method |
| backend | String | Backend identifier for the payment method |
| active | Boolean | Whether the payment method is active |
| order | Integer | Order of the payment method in the list |
| name | String | Name of the payment method |
| image_data | Object | Image details (read-only) |
| description | String | Description of the payment method |
| settings | Object | Additional settings for the payment method |
| created_at | String (ISO 8601) | Timestamp when the payment method was created |
| updated_at | String (ISO 8601) | Timestamp when the payment method was last updated |
Image Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the image |
| type | String | File type (e.g., image/jpeg) |
| name | String | Original file name |
| size | Integer | File size in bytes |
| human_readable_size | String | Human readable file size (e.g., 2.5 MB) |
| f | String | URL to access the image file |
| width | Integer | Image width in pixels |
| height | Integer | Image height in pixels |
| mode | String | Color mode (e.g., RGB, CMYK) |
| thumbnails | List of thumbnail objects | Imgae thumbnails |
Thumbnail Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the thumbnail (unique) |
| f | String | URL to access the thumbnail file |
| size | Integer | File 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
settingsfield must be a valid json