> ## 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.

# التحقق من حالة الطلب

> احصل على حالة الطلب واسترجع البطاقات عند اكتماله

<div dir="rtl">
  ## نظرة عامة

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

  ## معاملات المسار

  <ParamField path="orderId" type="string" required>
    معرف الطلب من استجابة `/placeOrder`
  </ParamField>

  ## الاستجابة

  <ResponseField name="data" type="object">
    <Expandable title="الخصائص">
      <ResponseField name="status" type="string">
        * **HANDLING:** قيد المعالجة - **FULFILLED:** مكتمل، البطاقات متاحة ✅ -
          **PARTIALLY\_FILLED:** بعض البطاقات مُسلَّمة ⚠️ - **REFUNDED:** فشل واسترداد ❌
      </ResponseField>

      <ResponseField name="quantity" type="number">
        كمية الطلب الأصلية
      </ResponseField>

      <ResponseField name="fulfilled_quantity" type="number">
        عدد البطاقات المُسلَّمة
      </ResponseField>

      <ResponseField name="fulfilled_amount" type="number">
        إجمالي المبلغ المحتسَب
      </ResponseField>

      <ResponseField name="price_per_card" type="number">
        السعر لكل بطاقة
      </ResponseField>

      <ResponseField name="cards" type="array">
        مصفوفة كائنات البطاقات (عند FULFILLED أو PARTIALLY\_FILLED)

        <Expandable title="كائن البطاقة">
          <ResponseField name="value" type="string">
            كود/PIN البطاقة (البيانات الاعتمادية الرئيسية)
          </ResponseField>

          <ResponseField name="serial" type="string">
            الرقم التسلسلي للبطاقة (البيانات الاعتمادية الثانوية)
          </ResponseField>
        </Expandable>
      </ResponseField>
    </Expandable>
  </ResponseField>

  ## أمثلة

  <CodeGroup>
    ```bash cURL theme={null}
    curl https://api.oneclickdz.com/v3/gift-cards/checkOrder/6901616fe9e88196b4eb64b3 \
      -H "X-Access-Token: YOUR_API_KEY"
    ```

    ```javascript Node.js theme={null}
    const orderId = "6901616fe9e88196b4eb64b3";
    const response = await fetch(
      `https://api.oneclickdz.com/v3/gift-cards/checkOrder/${orderId}`,
      { headers: { "X-Access-Token": "YOUR_API_KEY" } }
    );
    const { data } = await response.json();

    if (data.status === "FULFILLED") {
      console.log("Cards:", data.cards);
    }
    ```

    ```python Python theme={null}
    response = requests.get(
        f'https://api.oneclickdz.com/v3/gift-cards/checkOrder/{order_id}',
        headers={'X-Access-Token': 'YOUR_API_KEY'}
    )
    data = response.json()['data']

    if data['status'] == 'FULFILLED':
        for card in data['cards']:
            print(f"Code: {card['value']}, Serial: {card['serial']}")
    ```

    ```php PHP theme={null}
    <?php
    $orderId = '6901616fe9e88196b4eb64b3';
    $ch = curl_init("https://api.oneclickdz.com/v3/gift-cards/checkOrder/{$orderId}");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-Access-Token: YOUR_API_KEY']);
    $response = curl_exec($ch);
    $result = json_decode($response, true);
    $data = $result['data'];

    if ($data['status'] === 'FULFILLED') {
        foreach ($data['cards'] as $card) {
            echo "Code: " . $card['value'] . ", Serial: " . $card['serial'] . "\n";
        }
    }
    ?>
    ```
  </CodeGroup>

  ### استجابة قيد المعالجة

  ```json theme={null}
  {
    "success": true,
    "data": {
      "_id": "6901616fe9e88196b4eb64b3",
      "status": "HANDLING",
      "quantity": 2,
      "product": "507f1f77bcf86cd799439011",
      "type": "type_001",
      "time": "2025-10-29T01:00:00.000Z"
    }
  }
  ```

  ### استجابة عند الاكتمال

  ```json theme={null}
  {
    "success": true,
    "data": {
      "_id": "6901616fe9e88196b4eb64b3",
      "status": "FULFILLED",
      "quantity": 2,
      "fulfilled_quantity": 2,
      "fulfilled_amount": 980,
      "price_per_card": 490,
      "cards": [
        {
          "value": "XXXX-XXXX-XXXX-XXXX",
          "serial": "123456789"
        },
        {
          "value": "YYYY-YYYY-YYYY-YYYY",
          "serial": "987654321"
        }
      ],
      "time": "2025-10-29T01:00:00.000Z"
    }
  }
  ```

  ## مثال الاستعلام الدوري

  ```javascript theme={null}
  async function pollOrder(orderId) {
    const maxAttempts = 60;

    for (let i = 0; i < maxAttempts; i++) {
      const response = await fetch(
        `https://api.oneclickdz.com/v3/gift-cards/checkOrder/${orderId}`,
        { headers: { "X-Access-Token": process.env.API_KEY } }
      );

      const { data } = await response.json();

      if (["FULFILLED", "PARTIALLY_FILLED", "REFUNDED"].includes(data.status)) {
        return data;
      }

      await new Promise((resolve) => setTimeout(resolve, 5000));
    }

    throw new Error("Timeout");
  }
  ```

  ## معالجة الحالات

  <AccordionGroup>
    <Accordion title="FULFILLED">
      جميع البطاقات مُسلَّمة بنجاح

      * `fulfilled_quantity === quantity`
      * جميع البطاقات متاحة في مصفوفة `cards`
      * سلِّمها للعميل
    </Accordion>

    <Accordion title="PARTIALLY_FILLED">
      بعض البطاقات مُسلَّمة، والباقي ملغى

      * `fulfilled_quantity < quantity`
      * صدر استرداد جزئي
      * سلِّم البطاقات المتاحة
      * أعِد الفرق للعميل
    </Accordion>
  </AccordionGroup>

  ## روابط ذات صلة

  <CardGroup cols={2}>
    <Card title="تقديم طلب" icon="cart-shopping" href="/ar/api-reference/gift-cards/place-order">
      إنشاء طلب جديد
    </Card>

    <Card title="قائمة الطلبات" icon="list" href="/ar/api-reference/gift-cards/list-orders">
      عرض جميع الطلبات
    </Card>
  </CardGroup>
</div>
