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] @@ -44,8 +44,29 @@ * @returns {Promise<{ qrBuffer: Buffer, orderId: string, nonce: string|null, expectedDate: string|null, isGoldgo: boolean, isRynpp: boolean, isIndiaPay: boolean, isEwalletPay: boolean, tenantId: string|null, gatewayHost: string, gatewayApiUrl: string }>} */ async function generateQR(requestUrl, amount) { + if (requestUrl && requestUrl.includes('monepay.xyz')) { + try { + console.log(`[GATEWAY] Following monepay redirect for: ${requestUrl}`); + const redirRes = await fetch(requestUrl, { + method: 'GET', + redirect: 'manual', + headers: { + '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' + } + }); + const location = redirRes.headers.get('location'); + if (location && location.startsWith('http') && !location.includes('expired') && !location.includes('does not exist')) { + console.log(`[GATEWAY] monepay redirected to: ${location}`); + requestUrl = location; + } + } catch (e) { + console.warn(`[GATEWAY] monepay redirect follow failed:`, e.message); + } + } + const parsedUrl = new URL(requestUrl); const gatewayHost = parsedUrl.host; + const isDirectUpi = parsedUrl.searchParams.has('pa') || requestUrl.startsWith('upi://') || gatewayHost.includes('honeycombpro.io'); const isGoldgo = gatewayHost.includes('goldgo.cc') || gatewayHost.includes('goldgo68.com') || gatewayHost.includes('goldgo'); const isRynpp = gatewayHost.includes('rynpp.net'); const isKivoPay = gatewayHost.includes('kivopay.top') || gatewayHost.includes('kivopay.com'); @@ -62,7 +62,18 @@ let qrBuffer = null; let expectedDate = null; - if (isKivoPay) { + if (isDirectUpi) { + let upiUrl = requestUrl.startsWith('upi://') ? requestUrl : ('upi://pay' + parsedUrl.search); + if (!upiUrl.startsWith('upi://pay?')) { + upiUrl = upiUrl.replace(/^upi:\/\/[^?]*\?/, 'upi://pay?'); + } + orderId = parsedUrl.searchParams.get('tr') || parsedUrl.searchParams.get('tid') || parsedUrl.searchParams.get('orderId') || parsedUrl.searchParams.get('order_id') || ('UPI' + Date.now()); + console.log(`[GATEWAY] Direct UPI gateway detected (${gatewayHost}). Order ID: ${orderId}, UPI: ${upiUrl}`); + + const QRCode = require('qrcode'); + qrBuffer = await QRCode.toBuffer(upiUrl, { type: 'png', width: 400 }); + expectedDate = formatDateIST(new Date()); + } else if (isKivoPay) { orderId = parsedUrl.searchParams.get('order_id'); nonce = parsedUrl.searchParams.get('nonce'); const timestamp = parsedUrl.searchParams.get('timestamp'); [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.