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(core): preserve active timer when processing transition fails

generaltony007d53ca256993a
diff --git a/packages/core/src/timing-engine.js b/packages/core/src/timing-engine.js
index ddf6363..95d8772 100644
--- a/packages/core/src/timing-engine.js
+++ b/packages/core/src/timing-engine.js
@@ -110,16 +110,16 @@ export class TimingEngine {
* @returns {any} Updated session in PROCESSING state
*/
handlePaymentDone(sessionId) {
- // 1. Cancel Timer 1
+ // Commit the database transition before cancelling the active timer. A failed
+ // transition leaves the session ACTIVE, so its original expiry must stay armed.
+ const session = this.sessionRepo.transitionToProcessing(sessionId, this.processingDurationMs);
+
const activeTimer = this.activeTimers.get(sessionId);
if (activeTimer) {
clearTimeout(activeTimer);
this.activeTimers.delete(sessionId);
}
- // 2. Transition session to PROCESSING in DB
- const session = this.sessionRepo.transitionToProcessing(sessionId, this.processingDurationMs);
-
if (this.auditRepo) {
this.auditRepo.log({
merchantId: session.merchantId,