IIAPI Webhooks
IIAPI receives webhook notifications from T-VAN providers about invoice status changes.
Overview
Webhook Endpoint
POST /api/iiapi/webhookEvent Types
| Event | Description |
|---|---|
INVOICE_SIGNED | T-VAN signed the invoice |
INVOICE_SENT | Invoice sent to CQT |
INVOICE_ACCEPTED | CQT accepted invoice |
INVOICE_REJECTED | CQT rejected invoice |
Webhook Payload
typescript
interface IIAPIWebhookPayload {
event: 'INVOICE_SIGNED' | 'INVOICE_SENT' | 'INVOICE_ACCEPTED' | 'INVOICE_REJECTED';
invoiceId: string;
invoiceNumber: string;
status: string;
provider: string;
timestamp: string;
data: {
// Event-specific data
};
}Handle Webhook
typescript
// Configure webhook handler
iiApiOptions: {
enableControllers: true,
onWebhook: async (event, data) => {
switch (event) {
case 'INVOICE_ACCEPTED':
await saleOrderService.updateInvoiceStatus(data.invoiceId, 'COMPLETED');
await notificationService.send({
type: 'INVOICE_READY',
invoiceNumber: data.invoiceNumber,
});
break;
case 'INVOICE_REJECTED':
await alertService.notifyAdmin({
type: 'INVOICE_REJECTION',
invoiceId: data.invoiceId,
reason: data.reason,
});
break;
}
},
}Rejection Handling
When CQT rejects an invoice:
typescript
if (event === 'INVOICE_REJECTED') {
const { reason, errorCode, suggestions } = data;
// Log rejection
await auditService.logRejection({
invoiceId: data.invoiceId,
reason,
errorCode,
});
// Attempt auto-correction if possible
if (errorCode === 'INVALID_TAX_CODE') {
// Lookup correct tax code
const correctedTaxCode = await tvanService.lookupTaxCode(originalTaxCode);
// Update and resubmit
}
}