الانتقال إلى المحتوى الرئيسي

Documentation Index

Fetch the complete documentation index at: https://docs.oneclickdz.com/llms.txt

Use this file to discover all available pages before exploring further.

نظرة عامة

بعد التحقق من توفر المنتج، قدّم طلب بطاقة الهدية عبر endpoint الطلب. يستدعي الطلب الناجح إرجاع معرّف الطلب الذي ستستخدمه لتتبع الحالة.
تحقق دائماً من المخزون والرصيد قبل تقديم الطلب لتجنب الأخطاء.

مرجع API

POST /v3/gift-cards/placeOrder

التوثيق الكامل للـ endpoint

تقديم طلب أساسي

async function placeOrder(orderData) {
  const response = await fetch(
    "https://api.oneclickdz.com/v3/gift-cards/placeOrder",
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-Access-Token": process.env.API_KEY,
      },
      body: JSON.stringify({
        productId: orderData.productId,
        typeId: orderData.typeId,
        ref: orderData.ref,
      }),
    }
  );

  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.error?.message || `HTTP ${response.status}`);
  }

  const result = await response.json();
  return result.data;
}

// Usage
const order = await placeOrder({
  productId: "507f1f77bcf86cd799439011",
  typeId: "type_10",
  ref: `order-${Date.now()}`
});

console.log('Order placed:', order.orderId);

مثال على الاستجابة

{
  "success": true,
  "data": {
    "orderId": "6901616fe9e88196b4eb64b2",
    "orderRef": "order-123456"
  },
  "meta": {
    "timestamp": "2025-11-01T12:00:00.000Z"
  }
}

معالجة الأخطاء

try:
    order_id = place_order(product_id, type_id, quantity)
    print(f"Success: {order_id}")
except Exception as error:
    if 'stock' in str(error):
        print("Out of stock")
    elif 'balance' in str(error):
        print("Insufficient balance")
    else:
        print(f"Order failed: {error}")

أفضل الممارسات

التحقق أولاً

تحقق دائماً من المخزون والرصيد قبل تقديم أي طلب

مرجعيات فريدة

أنشئ ref فريداً لكل طلب لتجنب التكرار

تخزين orderId

احفظ orderId فوراً في قاعدة البيانات بعد نجاح الطلب

بدء الاستعلام

ابدأ استعلام الحالة فور تقديم الطلب بنجاح

الخطوات التالية

تتبع الحالة

استعلام حالة الطلب حتى اكتماله

التسليم الآمن

تسليم البطاقات بأمان للعملاء

مرجع API

التوثيق الكامل للـ endpoint