SofizPay Logo

SofizPay

SofizPay Logo
SofizPay
التوثيق التقني
واجهة برمجة تطبيقات عناصر التاجر

إدارة العناصر

أنشئ عناصر تاجر مستقلة أو أضف عناصر موجودة إلى فاتورة. قم بإدارة كتالوج منتجاتك بسهولة.

نقاط نهاية API

POSThttps://sofizpay.com/merchant/items/

إنشاء عناصر مستقلة أو إضافة عناصر موجودة إلى فاتورة

PATCHhttps://sofizpay.com/merchant/items/

تحديث تفاصيل العنصر، التسعير، أو التوفر

GEThttps://sofizpay.com/merchant/items/

جلب عناصر التاجر مع إمكانية التصفية والترقيم

اختيار الطريقة

جميع النقاط تتطلب مصادقة Sofizpay باستخدام معامل encrypted_sk

معاملات الطلب (POST)

المعاملالنوعمطلوبالوصف
encrypted_skstringنعمBase64 encrypted Sofizpay secret key
itemsarrayنعمArray of items to create
invoice_idstringلاInvoice ID to add items to (optional)

مثال للطلب

cURL

bash
1curl -X POST "https://sofizpay.com/merchant/items/" \
2  -H "Content-Type: application/json" \
3  -d '{
4    "encrypted_sk": "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0K...",
5    "items": [
6      {
7        "name": "Samsung Galaxy S24",
8        "description": "Latest Samsung smartphone with 128GB storage",
9        "unit_price": 850.00,
10        "category": "Electronics",
11        "sku": "SAM-S24-128"
12      },
13      {
14        "name": "Wireless Earbuds",
15        "description": "Premium noise-cancelling wireless earbuds",
16        "unit_price": 120.00,
17        "category": "Accessories",
18        "sku": "WE-PREM-001"
19      }
20    ]
21  }'

Python

python
1import requests
2import json
3
4url = "https://sofizpay.com/merchant/items/"
5headers = {
6    "Content-Type": "application/json"
7}
8
9data = {
10    "encrypted_sk": "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0K...",
11    "items": [
12        {
13            "name": "Samsung Galaxy S24",
14            "description": "Latest Samsung smartphone with 128GB storage",
15            "unit_price": 850.00,
16            "category": "Electronics",
17            "sku": "SAM-S24-128"
18        },
19        {
20            "name": "Wireless Earbuds",
21            "description": "Premium noise-cancelling wireless earbuds",
22            "unit_price": 120.00,
23            "category": "Accessories",
24            "sku": "WE-PREM-001"
25        }
26    ]
27}
28
29response = requests.post(url, headers=headers, json=data)
30result = response.json()
31print(result)

JavaScript

javascript
1const url = "https://sofizpay.com/merchant/items/";
2const data = {
3  encrypted_sk: "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0K...",
4  items: [
5    {
6      name: "Samsung Galaxy S24",
7      description: "Latest Samsung smartphone with 128GB storage",
8      unit_price: 850.00,
9      category: "Electronics",
10      sku: "SAM-S24-128"
11    },
12    {
13      name: "Wireless Earbuds",
14      description: "Premium noise-cancelling wireless earbuds",
15      unit_price: 120.00,
16      category: "Accessories",
17      sku: "WE-PREM-001"
18    }
19  ]
20};
21
22fetch(url, {
23  method: 'POST',
24  headers: {
25    'Content-Type': 'application/json'
26  },
27  body: JSON.stringify(data)
28})
29.then(response => response.json())
30.then(result => console.log(result));

استجابة ناجحة (200)

تم إنشاء العناصر بنجاح مع كل التفاصيل

json
1{
2  "success": true,
3  "message": "Items created successfully",
4  "items": [
5    {
6      "id": "item_001",
7      "name": "Samsung Galaxy S24",
8      "description": "Latest Samsung smartphone with 128GB storage",
9      "unit_price": 850.00,
10      "category": "Electronics",
11      "sku": "SAM-S24-128",
12      "active": true,
13      "created_at": "2025-08-03T10:00:00Z",
14      "updated_at": "2025-08-03T10:00:00Z"
15    },
16    {
17      "id": "item_002",
18      "name": "Wireless Earbuds",
19      "description": "Premium noise-cancelling wireless earbuds",
20      "unit_price": 120.00,
21      "category": "Accessories",
22      "sku": "WE-PREM-001",
23      "active": true,
24      "created_at": "2025-08-03T10:00:00Z",
25      "updated_at": "2025-08-03T10:00:00Z"
26    }
27  ]
28}

استجابة خطأ (400/404)

أخطاء شائعة للمصادقة أو فشل التحقق

json
{
  "error": "Invalid secret key"
}

// Or for validation errors:
{
  "error": "Item with this SKU already exists for this merchant"
}

// Or for missing fields:
{
  "error": "Missing encrypted_sk"
}

مثال تحديث عنصر (PATCH)

قم بتحديث عنصر موجود بتغيير تفاصيله أو تسعيره أو حالة توفره

json
1{
2  "encrypted_sk": "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0K...",
3  "item_id": "item_001",
4  "name": "Samsung Galaxy S24 Ultra",
5  "description": "Latest Samsung smartphone with 256GB storage and S-Pen",
6  "unit_price": 950.00,
7  "category": "Electronics",
8  "active": true
9}
10
11// Response:
12{
13  "success": true,
14  "message": "Item updated successfully",
15  "item": {
16    "id": "item_001",
17    "name": "Samsung Galaxy S24 Ultra",
18    "description": "Latest Samsung smartphone with 256GB storage and S-Pen",
19    "unit_price": 950.00,
20    "category": "Electronics",
21    "sku": "SAM-S24-128",
22    "active": true,
23    "created_at": "2025-08-03T10:00:00Z",
24    "updated_at": "2025-08-03T11:15:00Z"
25  }
26}

ملاحظة أمان

حافظ دائمًا على مفتاحك السري المشفر آمنًا. استخدم HTTPS لجميع استدعاءات الـ API وتحقق من جميع الاستجابات على الخادم الخاص بك.