ابنِ مع إنفوتاكس.
اربط أي نظام مالي بإحدى ثلاث طرق — دون استبدال الأنظمة. اختر ما يناسب كل منصّة، وامزجها عبر المجموعة.
مقتطف التضمين
Webhook
واجهة REST
مقتطف التضمين
<script src="https://cdn.invotax.qa/embed.js"
data-client="acme-trading"
data-key="pk_test_••••"
data-system="odoo"></script>واجهة REST
curl -X POST https://api-invotax.idealsolutions-apps.com/v1/documents \
-H "Authorization: Bearer sk_live_••••" \
-H "Content-Type: application/json" \
-d '{"type":"INVOICE","issuedAt":"2027-01-14T09:00:00+03:00","deviceId":"dev_••••",
"buyerName":{"en":"Acme","ar":"Acme"},
"lines":[{"description":"Steel","quantity":"3","unitPrice":"7800.00"}]}'نقاط النهاية الأساسية
| POST | /v1/documents | إنشاء فاتورة أو إشعار دائن/مدين أو مستند مبسّط |
| POST | /v1/integrations/ingest | سجل وارد من نظام متّصل |
| GET | /v1/tax/summary | ضريبة الهيئة المحتسبة لفترة |
| GET | /v1/reports/categories | إجماليات مصنّفة عبر الأنظمة |
المصادقة
التحقق من توقيعات الـ Webhook
Node.js
const crypto = require('crypto');
// rawBody must be the exact bytes received (e.g. a Buffer from your raw
// body middleware) -- never the re-serialized, parsed JSON.
function verifyInvoTaxSignature(rawBody, signatureHeader, secret) {
const signingKey = crypto.createHash('sha256').update(secret, 'utf8').digest();
const parts = Object.fromEntries(signatureHeader.split(',').map((p) => p.split('=')));
const { t, v1 } = parts;
const toleranceSeconds = 5 * 60;
if (Math.abs(Math.floor(Date.now() / 1000) - Number(t)) > toleranceSeconds) {
throw new Error('signature timestamp outside tolerance');
}
const signedContent = Buffer.concat([Buffer.from(`${t}.`, 'utf8'), rawBody]);
const expected = crypto.createHmac('sha256', signingKey).update(signedContent).digest('hex');
const expectedBuf = Buffer.from(expected, 'utf8');
const receivedBuf = Buffer.from(v1, 'utf8');
const valid =
expectedBuf.length === receivedBuf.length && crypto.timingSafeEqual(expectedBuf, receivedBuf);
if (!valid) throw new Error('signature mismatch');
}Python
import hashlib
import hmac
import time
# raw_body must be the exact bytes received on the wire -- never
# json.dumps(parsed_body).encode(), which can reorder or reformat.
def verify_invotax_signature(raw_body: bytes, signature_header: str, secret: str) -> None:
signing_key = hashlib.sha256(secret.encode("utf-8")).digest()
parts = dict(p.split("=", 1) for p in signature_header.split(","))
t, v1 = parts["t"], parts["v1"]
tolerance_seconds = 5 * 60
if abs(int(time.time()) - int(t)) > tolerance_seconds:
raise ValueError("signature timestamp outside tolerance")
signed_content = f"{t}.".encode("utf-8") + raw_body
expected = hmac.new(signing_key, signed_content, hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, v1):
raise ValueError("signature mismatch")
