Skip to content

A self-hosted UPI & COD payment gateway with zero per-transaction platform fees, universal JavaScript checkout integration, dynamic QR payments, WhatsApp OTP authentication, and automated payment verification.

JavaScript

fix(db): mirror modern outcome outbox event identity

generaltony00755d408f0cc50
diff --git a/packages/db/src/schema.sql b/packages/db/src/schema.sql
index f872468..67878a8 100644
--- a/packages/db/src/schema.sql
+++ b/packages/db/src/schema.sql
@@ -198,15 +198,16 @@ CREATE INDEX IF NOT EXISTS idx_webhook_deliveries_retry ON webhook_deliveries (i
-- Durable terminal-event outbox: populated in the same SQLite transaction as the status update.
-- Only NEW terminal transitions are queued; migrations must never replay historic orders.
CREATE TABLE IF NOT EXISTS payment_webhook_outbox (
- payment_id TEXT PRIMARY KEY REFERENCES payment_sessions(id) ON DELETE CASCADE,
- event_type TEXT NOT NULL CHECK(event_type IN ('SUCCESS','FAILED','EXPIRED','CANCELLED')),
- created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))
+ payment_id TEXT NOT NULL REFERENCES payment_sessions(id) ON DELETE CASCADE,
+ event_type TEXT NOT NULL CHECK(event_type IN ('SUCCESS','FAILED','EXPIRED','CANCELLED','OBSERVED_SUCCESS','MANUAL_REVIEW','RECONCILED')),
+ created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')),
+ PRIMARY KEY (payment_id, event_type)
);
CREATE TRIGGER IF NOT EXISTS trg_terminal_payment_webhook_outbox
AFTER UPDATE OF status ON payment_sessions
-WHEN NEW.status IN ('SUCCESS','FAILED','EXPIRED','CANCELLED')
- AND OLD.status NOT IN ('SUCCESS','FAILED','EXPIRED','CANCELLED')
+WHEN NEW.status IN ('SUCCESS','FAILED','EXPIRED','CANCELLED','OBSERVED_SUCCESS','MANUAL_REVIEW','RECONCILED')
+ AND OLD.status != NEW.status
BEGIN
INSERT OR IGNORE INTO payment_webhook_outbox (payment_id, event_type)
VALUES (NEW.id, NEW.status);
@@ -303,4 +304,3 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_statement_lines_source
CREATE INDEX IF NOT EXISTS idx_statement_lines_utr
ON bank_statement_lines (receiving_account_id, utr);
-