/api/payments/hostedيتطلب Idempotency-Keyإنشاء دفعة
يُعيد 201 مع الدفعة الجديدة. وتؤدي إعادة إرسال الطلب نفسه بقيمة Idempotency-Key نفسها إلى إعادة 200 مع الدفعة نفسها.
متن الطلب
| الحقل | النوع | إلزامي | الوصف | مثال |
|---|---|---|---|---|
merchant_order_id | string | إلزامي | مرجع طلب الشراء لديك: من 1 إلى 64 حرفًا من A-Z a-z 0-9 . _ -. ولا يُستخدم كل مرجع إلا لدفعة واحدة في كل بيئة، حتى إذا فشلت تلك الدفعة أو انتهت صلاحيتها. ولا يُفرَّق بين الأحرف الكبيرة والصغيرة عند التحقق من التفرد: إذ يُعامَل ORDER-1 وorder-1 بوصفهما المرجع نفسه. | ORDER-2026-001 |
amount | string | إلزامي | مبلغ موجب بمنزلتين عشريتين ودون أصفار بادئة، على سبيل المثال "100.00". ويجب أن يكون ضمن حدود حسابك. | "100.00" |
currency | string | اختياري | في حال حذفه، تُطبَّق العملة الرئيسية للنظام.USDEURAEDTRY | USD |
webhook_url | string · uri | إلزامي | نقطة النهاية التي تستقبل webhooks هذه الدفعة. HTTPS عام على المنفذ 443، بحد أقصى 500 حرف، بدون معلومات مستخدم أو جزء (fragment). لا تُقبل العناوين الخاصة والمحلية، حتى في sandbox؛ ويجب أن يُحلّ اسم المضيف إلى عنوان IP عام وقت الطلب، وإلا 422 9000008. | https://merchant.example/webhooks/payments |
success_url | string · uri | إلزامي | وجهة إعادة توجيه المتصفح بعد نجاح الدفعة. HTTPS، بحد أقصى 2048 حرفًا، ودون معلومات المستخدم (user info) أو المقطع (fragment). وتقبل البيئة التجريبية أيضًا http://localhost و127.0.0.1 و[::1]. | https://merchant.example/payment/success |
fail_url | string · uri | إلزامي | وجهة إعادة توجيه المتصفح عند فشل الدفعة أو انتهاء صلاحيتها أو إلغائها. وتسري عليها القواعد نفسها المطبقة على success_url. | https://merchant.example/payment/failure |
customer | object | إلزامي | بيانات الاتصال الخاصة بالدافع؛ تُستخدم لنتيجة الدفع والإيصال وخطوات التحقق لدى البنك. يُقبل email وphone فقط؛ وأي حقل آخر داخل customer يُرفض بـ 422 1000001. | { … } |
customer.email | string | إلزامي | عنوان البريد الإلكتروني الحقيقي للدافع: RFC 5322، بحد أقصى 254 حرفًا، مع نطاق يحتوي على نقطة. يُحفظ بأحرف صغيرة. | [email protected] |
customer.phone | string | إلزامي | رقم الهاتف الحقيقي للدافع بالصيغة الدولية (+ رمز الدولة، E.164)، مثل +37061234567. قاعدة خاصة بتركيا: +90 متبوعًا بالرقم الوطني المكوّن من 10 أرقام (5xx جوال، 2xx و3xx و4xx ثابت، 8xx خاص). الرقم المرسل بدون رمز الدولة يُعامل كرقم تركي (+90). | +37061234567 |
تنطبق هذه الروابط الثلاثة على هذه الدفعة فقط، ولا تؤخذ من إعدادات لوحة التحكم.
لا تطلب صفحة الدفع من الدافع عنوان البريد الإلكتروني ورقم الهاتف مرة أخرى. حفاظًا على الخصوصية، لا يُعاد customer في كائن الدفع ولا في الـ webhooks.
| الحقل | السبب | الرسالة في errors |
|---|---|---|
customer.email | صيغة غير صالحة أو أطول من 254 حرفًا. | customer.email must be a valid e-mail address (max 254 characters). |
customer.email | عنوان نائب أو نموذجي أو مؤقت. | customer.email must be the payer's real address; placeholder, example or disposable addresses (example.com, test@…, mailinator…) are not accepted. |
customer.phone | ليس رقمًا صالحًا بالصيغة الدولية. | customer.phone must be a valid phone number in international format (e.g. +37061234567). |
customer.phone | نمط أرقام مكررة أو متسلسلة. | customer.phone must be the payer's real number; repeated or sequential digit patterns (5555555555, 1234567890) are not accepted. |
customer.phone | رقم تركي ليس بصيغة +90 متبوعًا بعشرة أرقام تبدأ بـ 2 أو 3 أو 4 أو 5 أو 8. | customer.phone for Türkiye must be +90 followed by a 10-digit number starting with 2, 3, 4, 5 or 8 (e.g. +905321234567). |
HTTP 422 · 1000001
{
"type": "https://payniko.com/problems/1000001",
"title": "Validation failed",
"status": 422,
"detail": "The submitted fields are not valid.",
"code": "1000001",
"correlation_id": "4c7a1e9d-2b3f-4d85-9a6e-0f1b2c3d4e5f",
"errors": {
"customer.email": [
"customer.email must be the payer's real address; placeholder, example or disposable addresses (example.com, test@…, mailinator…) are not accepted."
],
"customer.phone": [
"customer.phone must be the payer's real number; repeated or sequential digit patterns (5555555555, 1234567890) are not accepted."
]
}
}إذا رُفض الطلب بسبب customer، فاعرض السبب للدافع بوضوح (مثلًا: أدخل عنوان بريدك الإلكتروني أو رقم هاتفك الخاص) واسمح له بتصحيح الحقل قبل إنشاء الدفع مرة أخرى. الرسائل في errors باللغة الإنجليزية ومخصصة لسجلاتك ولفريق الدعم.
تطبّق صفحات روابط الدفع في Payniko القواعد نفسها على عنوان البريد الإلكتروني ورقم الهاتف اللذين يدخلهما الدافع هناك، وتعرض له سبب الرفض.
متن الطلب · مثال
{
"merchant_order_id": "ORDER-2026-001",
"amount": "100.00",
"currency": "USD",
"webhook_url": "https://merchant.example/webhooks/payments",
"success_url": "https://merchant.example/payment/success",
"fail_url": "https://merchant.example/payment/failure",
"customer": {
"email": "[email protected]",
"phone": "+37061234567"
}
}KEY="$(openssl rand -hex 16)" # store with the order before sending; reuse it after network errors
./payniko.sh POST '/api/payments/hosted' '{
"merchant_order_id": "ORDER-2026-001",
"amount": "100.00",
"currency": "USD",
"webhook_url": "https://merchant.example/webhooks/payments",
"success_url": "https://merchant.example/payment/success",
"fail_url": "https://merchant.example/payment/failure",
"customer": {
"email": "[email protected]",
"phone": "+37061234567"
}
}' "$KEY"import {api, randomUUID} from './payniko.mjs';
const key = randomUUID(); // Store this key with the order before sending; reuse it after network errors.
const payment = await api('POST', '/api/payments/hosted', {
"merchant_order_id": "ORDER-2026-001",
"amount": "100.00",
"currency": "USD",
"webhook_url": "https://merchant.example/webhooks/payments",
"success_url": "https://merchant.example/payment/success",
"fail_url": "https://merchant.example/payment/failure",
"customer": {
"email": "[email protected]",
"phone": "+37061234567"
}
}, key);
console.log(payment);<?php
require __DIR__ . '/payniko.php';
$key = bin2hex(random_bytes(16)); // store with the order; reuse it after network errors
$payment = payniko_api('POST', '/api/payments/hosted', [
"merchant_order_id" => 'ORDER-2026-001',
"amount" => '100.00',
"currency" => 'USD',
"webhook_url" => 'https://merchant.example/webhooks/payments',
"success_url" => 'https://merchant.example/payment/success',
"fail_url" => 'https://merchant.example/payment/failure',
"customer" => [
"email" => '[email protected]',
"phone" => '+37061234567',
],
], $key);
print_r($payment);from payniko import api
import uuid
key = str(uuid.uuid4()) # store with the order; reuse it after network errors
payment = api("POST", "/api/payments/hosted", {
"merchant_order_id": "ORDER-2026-001",
"amount": "100.00",
"currency": "USD",
"webhook_url": "https://merchant.example/webhooks/payments",
"success_url": "https://merchant.example/payment/success",
"fail_url": "https://merchant.example/payment/failure",
"customer": {
"email": "[email protected]",
"phone": "+37061234567"
}
}, key)
print(payment)الاستجابة · 201
يُعيد { "data": Payment } مع status: requires_action وnext_action.url.
الاستجابة · مثال
{
"data": {
"payment_id": "LUVEI-PAYN-123456",
"merchant_order_id": "ORDER-2026-001",
"flow": "hosted",
"status": "requires_action",
"amount": "100.00",
"currency": "USD",
"environment": "sandbox",
"next_action": {
"type": "redirect",
"url": "https://payniko.com/l/example-checkout",
"expires_at": "2026-11-02T12:00:00.000Z"
},
"card": null,
"failure": null,
"created_at": "2026-11-01T12:00:00.000Z",
"expires_at": "2026-11-02T12:00:00.000Z",
"completed_at": null
}
}استجابات أخرى
200: أُعيد إرسال المفتاح والمتن نفسيهما. وتُعاد الدفعة الأصلية دون إنشاء دفعة جديدة.4099000010: سبق استخدام هذا المفتاح مع متن مختلف.4099000039: الطلب الأول بهذا المفتاح لا يزال قيد المعالجة. أعد إرسال الطلب نفسه بعد انتظار قصير.4099000007: توجد دفعة مسبقًا لقيمةmerchant_order_idهذه.4229000005: المبلغ خارج حدود حسابك؛ ويتضمنlimitsالنطاق المسموح به.4221000001معcustomerأوcustomer.emailأوcustomer.phoneفيerrors: بيانات الاتصال مفقودة أو غير صالحة.4221000001،1000020،1000021،9000008،9000038: أحد الحقول غير صالح؛ وتجد التفاصيل فيerrorsوintegration.violations.
HTTP 422 · 9000005
{
"type": "https://payniko.com/problems/9000005",
"title": "Invalid amount",
"status": 422,
"detail": "The amount is outside the account limits.",
"code": "9000005",
"correlation_id": "6d1f0c2e-8a4b-4c7d-9e21-3f5a7b9c1d20",
"limits": {
"currency_code": "USD",
"min_amount": "25.00",
"max_amount": null
}
}تُقيَّم الحدود بالعملة الرئيسية للنظام (limits.currency_code) بعد تحويل مبلغك. وتعني max_amount: null عدم وجود حد أعلى. وقيم الحدود الواردة في هذا المثال توضيحية.