The following changes were made by the replace_file_content tool to: /root/aadharbot/gateways.js. If relevant, proactively run terminal commands to execute this code for the USER. Don't ask for permission. [diff_block_start] @@ -434,9 +434,69 @@ const d = new Date(); expectedDate = formatDateIST(d); } + } else if (isPayflow) { + let orderIdVal = parsedUrl.searchParams.get('orderId') || parsedUrl.searchParams.get('order_id'); + if (!orderIdVal && parsedUrl.hash) { + const hashMatch = parsedUrl.hash.match(/[?&]orderId=([^&]+)/i) || parsedUrl.hash.match(/[?&]order_id=([^&]+)/i); + if (hashMatch) { + orderIdVal = hashMatch[1]; + } + } + orderId = orderIdVal; + console.log(`[GATEWAY] Payflow detected. Order ID: ${orderId}`); + + gatewayApiUrl = `https://${gatewayHost}`; + + const priv = crypto.createPrivateKey({ + key: Buffer.from(PAYFLOW_KEY_B64, 'base64'), + format: 'der', + type: 'pkcs8' + }); + const pub = crypto.createPublicKey(priv); + const encryptedOrderId = crypto.publicEncrypt({ + key: pub, + padding: crypto.constants.RSA_PKCS1_PADDING + }, Buffer.from(orderId)).toString('base64'); + + const buildRes = await fetch(`${gatewayApiUrl}/prod-checkout-api/build/v2/buildInfo?payOrderId=${encodeURIComponent(encryptedOrderId)}&os=Windows&osVersion=10&deviceType=PC&browser=Chrome&browserVersion=120.0.0.0`, { + method: 'GET', + headers: { + 'Origin': `https://${gatewayHost}`, + 'Referer': requestUrl, + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36' + } + }); + + if (!buildRes.ok) throw new Error(`Payflow API returned HTTP ${buildRes.status}`); + const payJson = await buildRes.json(); + + if (payJson.code !== 200 || !payJson.data || !payJson.data.deepLink) { + throw new Error(payJson.msg || "Failed to retrieve payment deepLink from Payflow"); + } + + const upiUrl = payJson.data.deepLink; + console.log(`[GATEWAY] Payflow extracted UPI URI: ${upiUrl}`); + + const QRCode = require('qrcode'); + qrBuffer = await QRCode.toBuffer(upiUrl, { type: 'png', width: 400 }); + + if (payJson.data.createTime) { + const d = new Date(Number(payJson.data.createTime)); + expectedDate = formatDateIST(d); + } else { + const d = new Date(); + expectedDate = formatDateIST(d); + } } else { // Standard flow (xspay, etc.) - orderId = parsedUrl.searchParams.get('orderId') || parsedUrl.searchParams.get('order_id'); + let orderIdVal = parsedUrl.searchParams.get('orderId') || parsedUrl.searchParams.get('order_id'); + if (!orderIdVal && parsedUrl.hash) { + const hashMatch = parsedUrl.hash.match(/[?&]orderId=([^&]+)/i) || parsedUrl.hash.match(/[?&]order_id=([^&]+)/i); + if (hashMatch) { + orderIdVal = hashMatch[1]; + } + } + orderId = orderIdVal; console.log(`[GATEWAY] Standard gateway detected. Order ID: ${orderId}`); if (gatewayHost.startsWith('pay.')) { @@ -482,6 +482,8 @@ isIndiaPay, isEwalletPay, isBluePay, + isUpiPayments, + isPayflow, tenantId, gatewayHost, gatewayApiUrl @@ -493,7 +493,7 @@ * @param {string} utr 12-digit UTR code. */ async function uploadUtr(session, utr) { - const { orderId, nonce, isGoldgo, isRynpp, isKivoPay, isIndiaPay, isEwalletPay, isBluePay, isUpiPayments, tenantId, gatewayHost, gatewayApiUrl } = session; + const { orderId, nonce, isGoldgo, isRynpp, isKivoPay, isIndiaPay, isEwalletPay, isBluePay, isUpiPayments, isPayflow, tenantId, gatewayHost, gatewayApiUrl } = session; if (isKivoPay) { console.log(`[GATEWAY] Uploading KivoPay UTR: ${utr} for order: ${orderId}`); [diff_block_end] Please note that the above snippet only shows the MODIFIED lines from the last change. It shows up to 3 lines of unchanged lines before and after the modified lines. The actual file contents may have many more lines not shown.