Files
m2pool_payment/integration/wordpress/templates/payment-instructions.php
2025-11-18 17:26:07 +08:00

137 lines
4.5 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* 支付说明模板
*/
if (!defined('ABSPATH')) {
exit;
}
?>
<div class="m2pool-eth-payment-instructions">
<h3><?php echo esc_html__('ETH 支付说明', 'm2pool-eth-payment'); ?></h3>
<div class="payment-info">
<p><strong><?php echo esc_html__('请向以下地址支付:', 'm2pool-eth-payment'); ?></strong></p>
<div class="payment-address">
<code id="payment-address-code"><?php echo esc_html($payment_address); ?></code>
<button type="button" class="button copy-address" data-address="<?php echo esc_attr($payment_address); ?>">
<?php echo esc_html__('复制地址', 'm2pool-eth-payment'); ?>
</button>
</div>
<p><strong><?php echo esc_html__('支付金额:', 'm2pool-eth-payment'); ?></strong></p>
<p class="payment-amount"><?php echo esc_html($payment_amount); ?> <?php echo esc_html($payment_symbol); ?></p>
<div class="payment-status" id="payment-status">
<p><?php echo esc_html__('等待支付中...', 'm2pool-eth-payment'); ?></p>
</div>
</div>
<div class="payment-notes">
<p><strong><?php echo esc_html__('注意事项:', 'm2pool-eth-payment'); ?></strong></p>
<ul>
<li><?php echo esc_html__('请确保支付金额准确', 'm2pool-eth-payment'); ?></li>
<li><?php echo esc_html__('支付完成后,系统会自动确认(通常需要几分钟)', 'm2pool-eth-payment'); ?></li>
<li><?php echo esc_html__('请勿向此地址发送其他代币', 'm2pool-eth-payment'); ?></li>
</ul>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
// 复制地址功能
$('.copy-address').on('click', function() {
var address = $(this).data('address');
var $temp = $('<input>');
$('body').append($temp);
$temp.val(address).select();
document.execCommand('copy');
$temp.remove();
$(this).text('<?php echo esc_js(__('已复制', 'm2pool-eth-payment')); ?>');
setTimeout(function() {
$('.copy-address').text('<?php echo esc_js(__('复制地址', 'm2pool-eth-payment')); ?>');
}, 2000);
});
// 定期检查支付状态
var orderId = <?php echo esc_js($order_id); ?>;
var checkInterval = setInterval(function() {
$.ajax({
url: '<?php echo esc_url(admin_url('admin-ajax.php')); ?>',
type: 'POST',
data: {
action: 'm2pool_check_payment',
order_id: orderId,
nonce: '<?php echo esc_js(wp_create_nonce('m2pool_eth_check')); ?>'
},
success: function(response) {
if (response.success && response.data.status === 'completed') {
clearInterval(checkInterval);
$('#payment-status').html('<p style="color: green;"><?php echo esc_js(__('支付成功!页面将自动刷新...', 'm2pool-eth-payment')); ?></p>');
setTimeout(function() {
location.reload();
}, 2000);
} else if (response.success && response.data.status === 'processing') {
$('#payment-status').html('<p style="color: orange;"><?php echo esc_js(__('支付确认中...', 'm2pool-eth-payment')); ?></p>');
} else if (response.success && response.data.status === 'failed') {
clearInterval(checkInterval);
$('#payment-status').html('<p style="color: red;"><?php echo esc_js(__('支付失败', 'm2pool-eth-payment')); ?></p>');
}
}
});
}, 10000); // 每10秒检查一次
// 30秒后停止检查避免无限检查
setTimeout(function() {
clearInterval(checkInterval);
}, 300000); // 5分钟
});
</script>
<style>
.m2pool-eth-payment-instructions {
margin: 20px 0;
padding: 20px;
border: 1px solid #ddd;
border-radius: 4px;
background: #f9f9f9;
}
.payment-address {
margin: 10px 0;
display: flex;
align-items: center;
gap: 10px;
}
.payment-address code {
flex: 1;
padding: 10px;
background: #fff;
border: 1px solid #ddd;
border-radius: 4px;
word-break: break-all;
}
.payment-amount {
font-size: 1.2em;
font-weight: bold;
color: #0073aa;
margin: 10px 0;
}
.payment-status {
margin: 15px 0;
padding: 10px;
background: #fff;
border-radius: 4px;
}
.payment-notes ul {
margin-left: 20px;
}
</style>