integration wordpress
This commit is contained in:
136
integration/wordpress/templates/payment-instructions.php
Normal file
136
integration/wordpress/templates/payment-instructions.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?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>
|
||||
|
||||
81
integration/wordpress/templates/settings.php
Normal file
81
integration/wordpress/templates/settings.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* 设置页面模板
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<h1><?php echo esc_html__('M2Pool ETH 支付设置', 'm2pool-eth-payment'); ?></h1>
|
||||
|
||||
<form method="post" action="">
|
||||
<?php wp_nonce_field('m2pool_eth_settings'); ?>
|
||||
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="api_url"><?php echo esc_html__('API 地址', 'm2pool-eth-payment'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="url" id="api_url" name="api_url" value="<?php echo esc_attr($api_url); ?>" class="regular-text" />
|
||||
<p class="description"><?php echo esc_html__('支付系统的 API 地址,例如: http://localhost:8080', 'm2pool-eth-payment'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="api_key"><?php echo esc_html__('API 密钥', 'm2pool-eth-payment'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" id="api_key" name="api_key" value="<?php echo esc_attr($api_key); ?>" class="regular-text" />
|
||||
<p class="description"><?php echo esc_html__('用于签名验证的 API 密钥', 'm2pool-eth-payment'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="from_address"><?php echo esc_html__('发送地址', 'm2pool-eth-payment'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" id="from_address" name="from_address" value="<?php echo esc_attr($from_address); ?>" class="regular-text" />
|
||||
<p class="description"><?php echo esc_html__('用于发送支付的以太坊地址(可选)', 'm2pool-eth-payment'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="to_address"><?php echo esc_html__('接收地址', 'm2pool-eth-payment'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" id="to_address" name="to_address" value="<?php echo esc_attr($to_address); ?>" class="regular-text" />
|
||||
<p class="description"><?php echo esc_html__('用于接收支付的以太坊地址', 'm2pool-eth-payment'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="listen_interval"><?php echo esc_html__('监听间隔(秒)', 'm2pool-eth-payment'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="number" id="listen_interval" name="listen_interval" value="<?php echo esc_attr($listen_interval); ?>" min="10" max="300" />
|
||||
<p class="description"><?php echo esc_html__('检查支付状态的间隔时间(秒),建议 30-60 秒', 'm2pool-eth-payment'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p class="submit">
|
||||
<input type="submit" name="m2pool_eth_save_settings" class="button button-primary" value="<?php echo esc_attr__('保存设置', 'm2pool-eth-payment'); ?>" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<hr />
|
||||
|
||||
<h2><?php echo esc_html__('Webhook 设置', 'm2pool-eth-payment'); ?></h2>
|
||||
<p><?php echo esc_html__('Webhook URL(用于接收支付状态通知):', 'm2pool-eth-payment'); ?></p>
|
||||
<code><?php echo esc_url(rest_url('m2pool-eth/v1/webhook')); ?></code>
|
||||
<p class="description"><?php echo esc_html__('将此 URL 配置到您的支付系统中,以便接收支付状态更新', 'm2pool-eth-payment'); ?></p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user