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

# إنشاء رابط دفع

> أنشئ رابط دفع جديداً للاستخدام مرة واحدة لنظام الدفع OneClick (Navio)

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

  أنشئ رابط دفع آمن للاستخدام مرة واحدة مع إعدادات قابلة للتخصيص. مثالي لطلبات التجارة الإلكترونية ومدفوعات الخدمات وتجديدات الاشتراكات.

  <Warning>
    **التحقق من صحة التاجر مطلوب**: أكمل التحقق من صحة التاجر على [ https://app.oneclickdz.com/profile](https://app.oneclickdz.com/profile) قبل استخدام هذا الـ endpoint.
  </Warning>

  ## جسم الطلب

  <ParamField body="productInfo" type="object" required>
    تفاصيل المنتج أو الخدمة المدفوع مقابلها

    <Expandable title="خصائص productInfo">
      <ParamField body="title" type="string" required>
        اسم المنتج/الخدمة (1 إلى 200 حرف)
      </ParamField>

      <ParamField body="description" type="string">
        وصف تفصيلي (بحد أقصى 1000 حرف). يدعم markdown.
      </ParamField>

      <ParamField body="amount" type="number" required>
        مبلغ الدفع بالدينار الجزائري (500 - 500,000) **أمثلة:** `5000`، `15000`، `50000`
      </ParamField>
    </Expandable>
  </ParamField>

  <ParamField body="feeMode" type="string" default="NO_FEE">
    يحدد من يدفع رسوم السحب - `NO_FEE` - التاجر يدفع جميع الرسوم (الافتراضي) - `SPLIT_FEE` - الرسوم مقسَّمة 50/50 - `CUSTOMER_FEE` - العميل يدفع جميع الرسوم
  </ParamField>

  <ParamField body="successMessage" type="string">
    رسالة نجاح مخصصة (بحد أقصى 500 حرف) تُعرض بعد الدفع
  </ParamField>

  <ParamField body="redirectUrl" type="string">
    URL إعادة التوجيه بعد الدفع الناجح (يجب أن يكون HTTP/HTTPS صالحاً)
  </ParamField>

  ## الاستجابة

  <ResponseField name="success" type="boolean">
    يشير إلى نجاح العملية
  </ResponseField>

  <ResponseField name="data" type="object">
    تفاصيل رابط الدفع

    <Expandable title="خصائص data">
      <ResponseField name="paymentLink" type="object">
        معلومات رابط الدفع الكاملة

        <Expandable title="خصائص paymentLink">
          <ResponseField name="uid" type="string">
            المعرف الفريد للتاجر
          </ResponseField>

          <ResponseField name="ref" type="string">
            كود مرجع الدفع (التنسيق: `OCPL-XXXXXX-YYYY`)
          </ResponseField>

          <ResponseField name="isSandbox" type="boolean">
            ما إذا كان هذا رابط دفع تجريبي
          </ResponseField>

          <ResponseField name="productInfo" type="object">
            معلومات المنتج كما أُرسلت
          </ResponseField>

          <ResponseField name="feeMode" type="string">
            وضع تكوين الرسوم
          </ResponseField>

          <ResponseField name="successMessage" type="string">
            رسالة النجاح المخصصة
          </ResponseField>

          <ResponseField name="redirectUrl" type="string">
            URL إعادة التوجيه بعد الدفع
          </ResponseField>

          <ResponseField name="time" type="string">
            طابع زمني لإنشاء الرابط (ISO 8601)
          </ResponseField>
        </Expandable>
      </ResponseField>

      <ResponseField name="paymentUrl" type="string">
        **URL الكامل لمشاركته مع العملاء** للدفع
      </ResponseField>

      <ResponseField name="paymentRef" type="string">
        كود مرجع الدفع - **احفظه** لتتبع المدفوعات
      </ResponseField>
    </Expandable>
  </ResponseField>

  <ResponseField name="meta" type="object">
    بيانات وصفية للاستجابة

    <Expandable title="خصائص meta">
      <ResponseField name="timestamp" type="string">
        طابع زمني للاستجابة (ISO 8601)
      </ResponseField>

      <ResponseField name="requestId" type="string">
        معرف طلب فريد للدعم
      </ResponseField>
    </Expandable>
  </ResponseField>

  ## الميزات الرئيسية

  <CardGroup cols={2}>
    <Card title="مرونة الرسوم" icon="money-bill">
      اختر من يدفع رسوم المعاملة - التاجر أو العميل أو مشتركَين
    </Card>

    <Card title="علامة تجارية مخصصة" icon="palette">
      رسائل نجاح مخصصة وURL إعادة توجيه
    </Card>

    <Card title="اختبار sandbox" icon="flask">
      اختبر تكاملك بأمان قبل الإطلاق
    </Card>

    <Card title="أمان الاستخدام الفردي" icon="shield-check">
      كل رابط للاستخدام مرة واحدة لأمان معزَّز
    </Card>
  </CardGroup>

  ## ملاحظات مهمة

  <Note>
    **حدود المبلغ:** - الحد الأدنى: 500 دج - الحد الأقصى: 500,000 دج - يجب أن يكون عدداً صحيحاً (بدون كسور عشرية)
  </Note>

  <Note>
    **بنية الرسوم:** - 0% عند استخدام رصيد OneClick - 1% رسوم سحب فقط (قابلة للتكوين لكل معاملة)
  </Note>

  <Note>
    **انتهاء صلاحية الرابط:** تنتهي صلاحية روابط الدفع بعد 20 دقيقة من الإنشاء إذا لم يُبدأ الدفع
  </Note>

  <RequestExample>
    ```bash cURL theme={null}
    curl --request POST \
      --url https://api.oneclickdz.com/v3/ocpay/createLink \
      --header 'Content-Type: application/json' \
      --header 'X-Access-Token: YOUR_API_KEY' \
      --data '{
      "productInfo": {
        "title": "Premium Subscription",
        "description": "Monthly access to premium features",
        "amount": 5000
      },
      "feeMode": "NO_FEE",
      "successMessage": "Thank you for your purchase!",
      "redirectUrl": "https://yourstore.com/success?orderId=12345"
    }'
    ```

    ```javascript JavaScript theme={null}
    const response = await fetch("https://api.oneclickdz.com/v3/ocpay/createLink", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-Access-Token": "YOUR_API_KEY",
      },
      body: JSON.stringify({
        productInfo: {
          title: "Premium Subscription",
          description: "Monthly access to premium features",
          amount: 5000,
        },
        feeMode: "NO_FEE",
        successMessage: "Thank you for your purchase!",
        redirectUrl: "https://yourstore.com/success?orderId=12345",
      }),
    });

    const data = await response.json();
    console.log("Payment URL:", data.data.paymentUrl);
    console.log("Payment Ref:", data.data.paymentRef);
    ```

    ```python Python theme={null}
    import requests

    url = "https://api.oneclickdz.com/v3/ocpay/createLink"
    headers = {
        "Content-Type": "application/json",
        "X-Access-Token": "YOUR_API_KEY"
    }
    payload = {
        "productInfo": {
            "title": "Premium Subscription",
            "description": "Monthly access to premium features",
            "amount": 5000
        },
        "feeMode": "NO_FEE",
        "successMessage": "Thank you for your purchase!",
        "redirectUrl": "https://yourstore.com/success?orderId=12345"
    }

    response = requests.post(url, json=payload, headers=headers)
    data = response.json()

    print(f"Payment URL: {data['data']['paymentUrl']}")
    print(f"Payment Ref: {data['data']['paymentRef']}")
    ```

    ```php PHP theme={null}
    <?php
    $url = 'https://api.oneclickdz.com/v3/ocpay/createLink';
    $headers = [
        'Content-Type: application/json',
        'X-Access-Token: YOUR_API_KEY'
    ];
    $payload = [
        'productInfo' => [
            'title' => 'Premium Subscription',
            'description' => 'Monthly access to premium features',
            'amount' => 5000
        ],
        'feeMode' => 'NO_FEE',
        'successMessage' => 'Thank you for your purchase!',
        'redirectUrl' => 'https://yourstore.com/success?orderId=12345'
    ];

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));

    $response = curl_exec($ch);
    $data = json_decode($response, true);

    echo "Payment URL: " . $data['data']['paymentUrl'] . "\n";
    echo "Payment Ref: " . $data['data']['paymentRef'] . "\n";
    ?>
    ```
  </RequestExample>

  <ResponseExample>
    ```json استجابة ناجحة (200) theme={null}
    {
      "success": true,
      "data": {
        "paymentLink": {
          "uid": "user_123456789",
          "ref": "OCPL-A1B2C3-D4E5",
          "isSandbox": false,
          "productInfo": {
            "title": "Premium Subscription",
            "description": "Monthly access to premium features",
            "amount": 5000
          },
          "feeMode": "NO_FEE",
          "successMessage": "Thank you for your purchase!",
          "redirectUrl": "https://yourstore.com/success?orderId=12345",
          "time": "2025-01-15T10:30:00Z"
        },
        "paymentUrl": "https://pay.ocdz.link/pay/OCPL-A1B2C3-D4E5",
        "paymentRef": "OCPL-A1B2C3-D4E5"
      },
      "meta": {
        "timestamp": "2025-01-15T10:30:00Z",
        "requestId": "req_abc123xyz"
      }
    }
    ```

    ```json خطأ في التحقق (400) theme={null}
    {
      "success": false,
      "error": {
        "code": "VALIDATION_ERROR",
        "message": "Invalid request data",
        "details": [
          {
            "field": "productInfo.amount",
            "message": "Amount must be between 500 and 500,000 DZD"
          }
        ]
      },
      "meta": {
        "timestamp": "2025-01-15T10:30:00Z",
        "requestId": "req_abc123xyz"
      }
    }
    ```
  </ResponseExample>

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

  <CardGroup cols={2}>
    <Card title="التحقق من حالة الدفع" icon="magnifying-glass" href="/ar/api-reference/ocpay/check-payment">
      تعلم كيفية التحقق من حالة الدفع
    </Card>

    <Card title="دليل التكامل" icon="book" href="/ar/ocpay-guides/overview">
      دليل تكامل Navio الكامل
    </Card>
  </CardGroup>
</div>
