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(observers): bound the consolidated sweep and drop a dead code path

rishabhb5c812566953
diff --git a/apps/gmail-observer/src/browser-automator.js b/apps/gmail-observer/src/browser-automator.js
index b34f05f..db5b696 100644
--- a/apps/gmail-observer/src/browser-automator.js
+++ b/apps/gmail-observer/src/browser-automator.js
@@ -40,9 +40,6 @@ export class GmailBrowserAutomator {
async fetchActivePaymentAmounts() {
try {
- if (this.gmailPoller && this.gmailPoller.observerClient && typeof this.gmailPoller.observerClient.getActiveWindow === 'function') {
- return await this.gmailPoller.observerClient.getActiveWindow();
- }
const res = await fetch(`${this.apiBaseUrl}/api/v1/pollers/active-window`, {
headers: { 'Authorization': `Bearer ${getObserverToken()}` },
signal: AbortSignal.timeout(1500)
diff --git a/apps/payment-api/src/services/observer-poller.service.js b/apps/payment-api/src/services/observer-poller.service.js
index e8da52b..0146dac 100644
--- a/apps/payment-api/src/services/observer-poller.service.js
+++ b/apps/payment-api/src/services/observer-poller.service.js
@@ -204,12 +204,15 @@ export class ObserverPollerService {
getActiveSessions() {
try {
const sixtySecsAgo = new Date(Date.now() - 60000).toISOString();
+ // A session that already reached the Triple Verification Standard (level 3) is fully
+ // confirmed: sweeping it again can never change its outcome, so it is excluded. This
+ // preserves the upper bound the previous per-session sweep timers enforced.
return this.db.query(`
SELECT id, receiving_account_id, amount_paise, status, verification_level
FROM payment_sessions
WHERE method = 'UPI' AND (
- status IN ('ACTIVE', 'PROCESSING')
- OR (status = 'SUCCESS' AND verification_level < 2 AND completed_at >= ?)
+ (status IN ('ACTIVE', 'PROCESSING') AND COALESCE(verification_level, 0) < 3)
+ OR (status = 'SUCCESS' AND COALESCE(verification_level, 0) < 2 AND completed_at >= ?)
)
`, [sixtySecsAgo]);
} catch {
diff --git a/apps/sms-observer/src/browser-automator.js b/apps/sms-observer/src/browser-automator.js
index 5b7e7c4..f3a494b 100644
--- a/apps/sms-observer/src/browser-automator.js
+++ b/apps/sms-observer/src/browser-automator.js
@@ -40,9 +40,6 @@ export class GoogleMessagesAutomator {
async fetchActivePaymentAmounts() {
try {
- if (this.smsService && this.smsService.observerClient && typeof this.smsService.observerClient.getActiveWindow === 'function') {
- return await this.smsService.observerClient.getActiveWindow();
- }
const res = await fetch(`${this.apiBaseUrl}/api/v1/pollers/active-window`, {
headers: { 'Authorization': `Bearer ${getObserverToken()}` },
signal: AbortSignal.timeout(1500)