The following changes were made by the replace_file_content tool to: /root/aadharbot/index.js. If relevant, proactively run terminal commands to execute this code for the USER. Don't ask for permission. [diff_block_start] @@ -4158,24 +4158,74 @@ // Step 1: Submit Payment Request console.log(`[PAYMENT] Submitting payment order for ₹${amount} to cashier API...`); - const submitRes = await fetch('https://cashier.oeur39rmwe.com/session/payment/submit', { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - 'Authorization': 'IND', - 'Token': token, - 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0' - }, - body: `bankCardId=0&localAmount=${amount}&paymentId=822` - }); - - if (!submitRes.ok) throw new Error(`Payment Submit API returned HTTP ${submitRes.status}`); - const submitJson = await submitRes.json(); - console.log(`[PAYMENT] Submit API response:`, JSON.stringify(submitJson)); - - if (submitJson.code !== 0 || !submitJson.data || !submitJson.data.result || !submitJson.data.result.requestUrl) { - const errorMsg = submitJson.message || submitJson.msg || "Invalid order response from server"; - throw new Error(errorMsg); + + // Discover active payment channels from deposit index + let candidatePaymentIds = [820, 822]; + try { + const depIndexRes = await fetch('https://cashier.oeur39rmwe.com/session/deposit/index/', { + headers: { + 'Authorization': 'IND', + 'Token': token, + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0' + } + }); + if (depIndexRes.ok) { + const depIndexJson = await depIndexRes.json(); + if (depIndexJson.code === 0 && depIndexJson.data && Array.isArray(depIndexJson.data.payments)) { + const onlineIds = depIndexJson.data.payments.map(p => p.paymentId).filter(Boolean); + if (onlineIds.length > 0) { + candidatePaymentIds = [...new Set([...onlineIds, 820, 822])]; + } + } + } + } catch (depErr) { + console.warn(`[PAYMENT WARNING] Failed to query deposit index:`, depErr.message); + } + + let submitJson = null; + let lastSubmitError = null; + + for (let i = 0; i < candidatePaymentIds.length; i++) { + const pid = candidatePaymentIds[i]; + try { + console.log(`[PAYMENT] Attempting paymentId ${pid} for ₹${amount} (${i + 1}/${candidatePaymentIds.length})...`); + const submitRes = await fetch('https://cashier.oeur39rmwe.com/session/payment/submit', { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Authorization': 'IND', + 'Token': token, + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0' + }, + body: `bankCardId=0&localAmount=${amount}&paymentId=${pid}` + }); + + if (!submitRes.ok) throw new Error(`Payment Submit API returned HTTP ${submitRes.status}`); + const resJson = await submitRes.json(); + console.log(`[PAYMENT] Submit API response (paymentId=${pid}):`, JSON.stringify(resJson)); + + if (resJson.code === 0 && resJson.data && resJson.data.result && resJson.data.result.requestUrl) { + submitJson = resJson; + break; + } + + const mappedErr = CASHIER_ERROR_MAP[resJson.code] || resJson.message || resJson.msg || `Payment gateway returned code ${resJson.code}`; + lastSubmitError = new Error(mappedErr); + + if (i < candidatePaymentIds.length - 1) { + await new Promise(r => setTimeout(r, 1500)); + } + } catch (err) { + lastSubmitError = err; + console.warn(`[PAYMENT WARNING] paymentId ${pid} failed:`, err.message); + if (i < candidatePaymentIds.length - 1) { + await new Promise(r => setTimeout(r, 1500)); + } + } + } + + if (!submitJson || !submitJson.data || !submitJson.data.result || !submitJson.data.result.requestUrl) { + throw lastSubmitError || new Error("Failed to generate payment order from server"); } requestUrl = submitJson.data.result.requestUrl; [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.