//! Payment page HTML renderer for the L402 402-challenge response.
//!
//! Separated from `lib.rs` to keep the core module focused on Nginx plumbing.
//! This module owns all HTML, CSS, and JavaScript that is sent to the browser
//! when a protected resource requires payment.
/// Render the full 402 payment page as an HTML string.
///
/// # Arguments
/// * `invoice` - BOLT-11 invoice string (used for QR + copy)
/// * `amount_msat` - Amount in millisatoshis (displayed as sats)
/// * `macaroon_b64` - Base64-encoded macaroon token
/// * `auto_detect` - Whether to poll for automatic payment detection
/// * `cashu_enabled` - Whether to show the Cashu/eCash tab
/// * `cashu_payment_request` - Optional P2PK Cashu payment request string
pub fn render_payment_page(
invoice: &str,
amount_msat: i64,
macaroon_b64: &str,
auto_detect: bool,
cashu_enabled: bool,
cashu_payment_request: Option<&str>,
) -> String {
// ── QR Code ─────────────────────────────────────────────────────────────
// Generate at 280 px and inject centering styles into the SVG root so the
// image always fills its white card wrapper without cropping.
let raw_qr = qrcode_generator::to_svg_to_string(
invoice.to_uppercase(),
qrcode_generator::QrCodeEcc::Medium,
280,
None::<&str>,
)
.unwrap_or_else(|_| {
""
.to_string()
});
let qr_svg = raw_qr.replacen(
"