orderConfirmOtp
نظرة عامة
استخدم هذا الـ mutation لتأكيد OTP مرتبط بطلب (على سبيل المثال، التحقق من الدفع عند الاستلام). قدم مفتاح التشفير، الهاتف، والدولة كما يتوقعها الـ backend الخاص بك. عند النجاح، تتلقى token يُستخدم لعمليات الطلب اللاحقة.
- النوع: GraphQL Mutation
- Endpoint: https://subdomain.com
- المصادقة: عامة (تأكيد OTP)
Mutation
mutation OrderConfirmOtp($input: OrderOtpConfirmInput!) {
orderConfirmOtp(input: $input) {
success
message
token
}
}
المتغيرات
{
"input": {
"encryptionKey": "<ENCRYPTION_KEY>",
"phone": "+966500000000",
"country": "SA"
}
}
أمثلة
- cURL
- JavaScript (fetch)
curl -X POST \
https://subdomain.com \
-H "Content-Type": "application/json" \
--data-binary @- << 'EOF'
{
"query": "mutation OrderConfirmOtp($input: OrderOtpConfirmInput!) { orderConfirmOtp(input: $input) { success message token } }",
"variables": {
"input": {
"encryptionKey": "<ENCRYPTION_KEY>",
"phone": "+966500000000",
"country": "SA"
}
}
}
EOF
const res = await fetch('https://subdomain.com', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: `
mutation OrderConfirmOtp($input: OrderOtpConfirmInput!) {
orderConfirmOtp(input: $input) {
success
message
token
}
}
`,
variables: {
input: {
encryptionKey: '<ENCRYPTION_KEY>',
phone: '+966500000000',
country: 'SA',
},
},
}),
});
const json = await res.json();
ملاحظات
encryptionKeyعادة يأتي منcreateCheckoutTokenأوbuyNow؛ تأكد من تمرير أحدث قيمة.- تعامل مع
tokenالمُعاد مثل رموز المصادقة الأخرى - خزّنه بشكل آمن للجلسة النشطة. - تعامل مع رسائل الخطأ لأكواد OTP غير الصالحة/منتهية الصلاحية واطلب من المستخدمين إعادة الإرسال إذا لزم الأمر.