/* Plugin: Crypto QR Pay (Complete rewrite per user request) Structure (single-file bundle for easy install): - crypto-qr-pay.php (this file) contains all code sections separated by comments Instructions: save this file as wp-content/plugins/crypto-qr-pay/crypto-qr-pay.php and create folders: - wp-content/plugins/crypto-qr-pay/assets/js/checkout.js (content provided below) - wp-content/plugins/crypto-qr-pay/assets/css/style.css (content provided below) Activate plugin in WP admin. Then go to WooCommerce -> Crypto QR Pay to configure ETH wallet (backend wallet), USDT contract, Etherscan API key, store logo/title/description/support url. ------ MAIN PLUGIN (this file defines constants and includes) ------ ------ assets/js/checkout.js (place in assets/js/checkout.js) ------ // content for assets/js/checkout.js jQuery(function($){ // Only run on order-pay page which includes #cryptoqr_checkout if (!$('#cryptoqr_checkout').length) return; // get order id from URL const m = location.href.match(/order-pay\/(\d+)/); if (!m || !m[1]) return; const orderId = m[1]; const payUrl = location.href; // show logo/title/desc from cryptoqr_vars if (cryptoqr_vars.logo) { const img = ''; $('#cryptoqr_checkout .cryptoqr-header').remove(); $('#cryptoqr_checkout').prepend('
'+img+'

'+cryptoqr_vars.title+'

'+cryptoqr_vars.description+'

'); } // generate QR function generateQR(){ $('#cryptoqr_status').text('生成二维码...'); $.post(cryptoqr_vars.ajax_url, { action:'cryptoqr_get_qr', order_id:orderId }, function(resp){ if(!resp || !resp.success){ $('#cryptoqr_status').text('生成失败'); return; } $('#cryptoqr_qr_area').html(''); $('#cryptoqr_unique_amount').text('请支付: '+resp.data.unique+' USDT'); $('#cryptoqr_paid_btn').show(); $('#cryptoqr_status').text('扫码支付后点击我已支付开始验证(最多 3 分钟)'); }); } generateQR(); $('#cryptoqr_paid_btn').on('click', function(){ let attempts = 0; const max = 36; $('#cryptoqr_status').text('开始监听支付状态...'); const iv = setInterval(function(){ attempts++; $('#cryptoqr_status').text('检查支付状态... ('+attempts+'/'+max+')'); $.post(cryptoqr_vars.ajax_url, { action:'cryptoqr_check_status', order_id:orderId }, function(res){ if(res && res.success && res.data.paid){ clearInterval(iv); $('#cryptoqr_status').html('支付成功,跳转中...'); setTimeout(function(){ // derive thankyou URL by replacing order-pay with order-received const thank = payUrl.replace('/order-pay/','/order-received/'); window.location.href = thank; },1200); } }); if(attempts>=max){ clearInterval(iv); // show manual input $('#cryptoqr_status').html('
3 分钟未检测到交易,请输入交易哈希:
'); $('#cryptoqr_support').on('click', function(){ window.open(cryptoqr_vars.support_link || '#','_blank'); }); $('#cryptoqr_manual_submit').on('click', function(){ const tx = $('#cryptoqr_manual_tx').val().trim(); if(!tx){ alert('请输入 tx'); return; } $.post(cryptoqr_vars.ajax_url, { action:'cryptoqr_verify_hash', order_id:orderId, tx_hash:tx }, function(r){ if(!r || !r.success){ alert('提交失败'); return; } alert('已提交,稍后系统会继续检查'); }); }); } },5000); }); }); ------ assets/css/style.css (place in assets/css/style.css) ------ .cryptoqr-logo{ max-height:34px; vertical-align:middle; margin-right:8px; } .cryptoqr-header{ display:flex; align-items:center; gap:12px; margin-bottom:12px; } .cryptoqr-big-logo{ max-height:64px; margin-right:12px; } /* minimal layout */ #cryptoqr_qr_area img{ border:1px solid #ddd; padding:6px; background:#fff; } End of bundle. Follow the installation instructions at top to place files and activate.
Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/sbeuxy.top/wp-content/plugins/crypto-qr-pay/crypto-qr-pay.php:253) in /www/wwwroot/sbeuxy.top/wp-includes/pluggable.php on line 1531

Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/sbeuxy.top/wp-content/plugins/crypto-qr-pay/crypto-qr-pay.php:253) in /www/wwwroot/sbeuxy.top/wp-includes/pluggable.php on line 1534