رويــــــالوحة المطور

RUYA / توثيق المطورين

أجهزة المحافظ

دليل التكامل

Generated endpoint reference
[
  {
    "method": "GET",
    "path": "/api/v1/agent-devices",
    "authentication": "OWNER or ADMIN session",
    "status": 200
  },
  {
    "method": "POST",
    "path": "/api/v1/agent-devices",
    "authentication": "OWNER or ADMIN session",
    "status": 201
  },
  {
    "method": "DELETE",
    "path": "/api/v1/agent-devices/:id",
    "authentication": "OWNER or ADMIN session",
    "status": 200
  },
  {
    "method": "GET",
    "path": "/api/v1/agent-devices/observations",
    "authentication": "OWNER or ADMIN session",
    "status": 200
  },
  {
    "method": "POST",
    "path": "/api/agent/v1/pair",
    "authentication": "One-time pairing token",
    "status": 201
  },
  {
    "method": "POST",
    "path": "/api/agent/v1/disconnect",
    "authentication": "Device Bearer credential",
    "status": 201
  },
  {
    "method": "POST",
    "path": "/api/agent/v1/heartbeat",
    "authentication": "Device Bearer credential",
    "status": 201
  },
  {
    "method": "POST",
    "path": "/api/agent/v1/credentials/rotate",
    "authentication": "Device Bearer credential",
    "status": 201
  },
  {
    "method": "POST",
    "path": "/api/agent/v1/observations",
    "authentication": "Device Bearer credential",
    "status": 201
  },
  {
    "method": "POST",
    "path": "/api/admin/agent-devices/:id/revoke",
    "authentication": "ADMIN session",
    "status": 201
  },
  {
    "method": "POST",
    "path": "/api/agent/v1/configuration",
    "authentication": "Device Bearer credential",
    "status": 201
  },
  {
    "method": "POST",
    "path": "/api/agent/v1/sms",
    "authentication": "Device Bearer credential",
    "status": 201
  },
  {
    "method": "GET",
    "path": "/api/v1/sms",
    "authentication": "OWNER or ADMIN session",
    "status": 200
  },
  {
    "method": "POST",
    "path": "/api/v1/sms/:id/reprocess",
    "authentication": "OWNER or ADMIN session",
    "status": 201
  },
  {
    "method": "GET",
    "path": "/api/admin/sms/policies",
    "authentication": "ADMIN session",
    "status": 200
  },
  {
    "method": "POST",
    "path": "/api/admin/sms/policies",
    "authentication": "ADMIN session",
    "status": 201
  },
  {
    "method": "POST",
    "path": "/api/admin/sms/policies/:id/enabled",
    "authentication": "ADMIN session",
    "status": 201
  },
  {
    "method": "POST",
    "path": "/api/admin/sms/templates",
    "authentication": "ADMIN session",
    "status": 201
  },
  {
    "method": "POST",
    "path": "/api/admin/sms/templates/:id/enabled",
    "authentication": "ADMIN session",
    "status": 201
  },
  {
    "method": "GET",
    "path": "/api/admin/sms/messages",
    "authentication": "ADMIN session",
    "status": 200
  },
  {
    "method": "POST",
    "path": "/api/admin/sms/messages/:id/reprocess",
    "authentication": "ADMIN session",
    "status": 201
  }
]

سجل هاتف المحفظة من عمليات التاجر ← أجهزة المحافظ. يلزم حساب ومحفظة معتمدان واشتراك سارٍ. رمز الربط ينتهي بعد عشر دقائق ويظهر مرة واحدة. بيانات الأجهزة وأحداثها معزولة لكل تاجر.

يستقبل Android الرسائل المناسبة بعد منح الإذن والموافقة وضبط المرسل وعلامة الاستلام من الإدارة. لا تأتي صيغ مزود مفعّلة مسبقاً. تحفظ الصيغ المجهولة مشفرة للمراجعة. تستخرج القوالب المبلغ والرقم والمرجع دون تخمين. تبقى SMS في PENDING أثناء الانتظار ثم UNDER_REVIEW؛ ولا تؤكد PAID دون مراجعة مالية مستقلة.

Merchant session routes
POST /api/v1/agent-devices  {"label":"Wallet phone","methodId":"UUID"}
GET /api/v1/agent-devices
DELETE /api/v1/agent-devices/:id
GET /api/v1/agent-devices/observations?page=1
Authentication: OWNER or ADMIN cookie session.
Amounts: integer EGP minor units.
Creation: 201 metadata + pairingToken + expiresInSeconds:600.
Error: 400 invalid input; 401 unauthenticated; 403 role/plan/limit; 404 wallet/device unavailable.
Device API
POST /api/agent/v1/pair
Body: {"pairingToken":"ruya_pair_EXAMPLE_ONLY"}
Response: {"deviceId":"UUID","merchantId":"UUID","environment":"LIVE","credential":"ONE_TIME_SECRET","verification":"OBSERVATION_ONLY"}

POST /api/agent/v1/heartbeat
POST /api/agent/v1/observations
POST /api/agent/v1/disconnect
Authentication: Bearer ruya_device_EXAMPLE_ONLY

Observation body:
{"sourceEventId":"stable-event-001","amount":50000,"currency":"EGP","transactionReference":"EXAMPLE-001","observedAt":"2026-12-05T12:00:00.000Z"}

Response: {"id":"UUID","status":"UNDER_REVIEW","duplicate":false,"verification":"UNVERIFIED_DEVICE_OBSERVATION"}
Errors: {"error":{"status":409,"message":"Event payload mismatch"},"requestId":"REQUEST_ID"}
cURL / Node.js
curl https://ruya.site/api/agent/v1/heartbeat -H "Authorization: Bearer $RUYA_DEVICE_CREDENTIAL" -H "Content-Type: application/json" -d '{}'

const response = await fetch("https://ruya.site/api/agent/v1/heartbeat", {
  method:"POST", redirect:"error",
  headers:{Authorization:`Bearer ${process.env.RUYA_DEVICE_CREDENTIAL}`,"Content-Type":"application/json"},
  body:"{}"
});
if(!response.ok) throw new Error(`RUYA returned ${response.status}`);
const acknowledgement = await response.json();

أعد محاولات أخطاء الشبكة و429 و5xx بتأخير تدريجي ونفس sourceEventId والمحتوى. تغيير المحتوى يعيد 409. يسجل الحدث أو مرجع المحفظة مرة واحدة؛ استلام حدث مكرر لا يعني PAID. لا تعرض بيانات الجهاز في المتصفح. إلغاء الجهاز يبطل بيانات الاتصال ورمز الربط غير المستخدم.

إدارة أجهزة المحافظ
SMS configuration and ingestion
POST /api/agent/v1/configuration
Authentication: device Bearer credential; body {}
201 {deviceId,environment:"LIVE",walletType,senders:[{id,sender,receivingMarker}],configurationExpiresInSeconds:1800}

POST /api/agent/v1/sms
Authentication: device Bearer credential
Body: {sourceEventId,sender,body,receivedAt} (ISO UTC)
201 {id,status:"PENDING",duplicate:false}

GET /api/v1/sms?page=1 (OWNER session)
200 {data:[{id,sender,body,receivedAt,status,reason,amount,payer,transactionReference,observationId}],total,page}
POST /api/v1/sms/:id/reprocess body {} (unmatched UNDER_REVIEW only)
201 {queued:true}

400 invalid input/OTP/timestamp; 401 invalid device; 403 unauthorized sender; 409 reused event with changed body.
No merchantId/environment/status is accepted in the upload body.

افتح الأدمن ← رسائل المحافظ والصيغ لإضافة قواعد المرسل وقوالب النص. أنواع الإعداد المدعومة: فودافون كاش وأورنج كاش واتصالات كاش وWE Pay وإنستا باي. استخدم {{amount}} و{{reference}} واختيارياً {{payer}} مع تحديد فاصل الكسور. الاستخراج لصيغة مطابقة مختبرة فقط؛ تعدد التطابقات يتطلب المراجعة. لا يسمح بكود أو تعبير برمجي حر، واسم المرسل ليس إثباتاً مالياً.

SMS cURL / backend example
curl https://ruya.site/api/agent/v1/sms -H "Authorization: Bearer $RUYA_DEVICE_CREDENTIAL" -H "Content-Type: application/json" --data-binary @eligible-message.json

const response = await fetch("https://ruya.site/api/agent/v1/sms", {method:"POST", redirect:"error", headers:{Authorization:`Bearer ${process.env.RUYA_DEVICE_CREDENTIAL}`,"Content-Type":"application/json"},body:JSON.stringify(eligibleMessage)});
if(!response.ok) throw new Error(`SMS rejected (${response.status})`);
const acknowledgement=await response.json(); // storage acknowledgement, not payment proof
مراجعة رسائل المحافظ

آخر تحديث: ٥ ديسمبر ٢٠٢٦. مرجع المسارات مولّد من المتحكمات ومخططات التحقق الحالية.