WordPress子比主题接入EPUSDT插件支付收款功能[支持v7.7]

WordPress子比主题接入EPUSDT插件支付收款功能[支持v7.7]

WordPress子比主题接入EPUSDT插件支付收款功能[支持v7.7]
如需其他程序定制接入请联系站长
20
本站特惠
199
立即购买
您当前未登录!建议登陆后购买,可保存购买订单
订单问题请联系站长(08::00 -21::00)
付费资源
已售 10

准备工作

  1. 需要接入的子比网站x1
  2. Telegram机器人x1 (用于操作您的钱包和接收交易通知)
  3. Epusdt开源程序
  4. 子比主题Epusdt插件已兼容v7.7版本 (购买本页付费内容即可下载)
  5. 服务器x1 (用于部署Epusdt程序,配置≥2g2h)
  6. 域名x1 (用于支付请求发起和扫码页面,支持二级域名)

开始教程

创建Telegram机器人

打开Telegram,在顶部搜索栏中搜索BotFather机器人,注意甄别ID为@BotFather

图片[1]-Wordpress子比主题接入EPUSDT插件支付收款功能

打开与BotFather的对话框,点击开始,您会收到BotFather回复的一些代码命令,我们点击第一个命令 /newbot创建机器人

图片[2]-Wordpress子比主题接入EPUSDT插件支付收款功能
图片[3]-Wordpress子比主题接入EPUSDT插件支付收款功能

机器人Token

接下来BotFather会依次提示您您输入机器人的昵称@ID_BOT,创建成功后,会得到机器人Token

  • 昵称自定义填写 (可以中文)
  • @ID_BOT 为唯一标识,如果取名重复则会提示重新输入,不能中文(输入格式为:xxx_bot)
图片[4]-Wordpress子比主题接入EPUSDT插件支付收款功能

接着,在顶部搜索栏中用@ID_bot搜索刚才创建成功的机器人,并任意发送一条消息,激活机器人(此时机器人不会做任何回复)

图片[5]-Wordpress子比主题接入EPUSDT插件支付收款功能

管理员ID

激活后,在顶部搜索框输入getmyid_bot,打开对话框,点击开始,机器人会自动回复您Telegram账号的ID,(也就是管理员ID

图片[6]-Wordpress子比主题接入EPUSDT插件支付收款功能

搭建EPusdt程序

服务器安装宝塔面板,不会安装请点击前往宝塔官网查看详细安装教程

图片[7]-Wordpress子比主题接入EPUSDT插件支付收款功能

Epusdt安装环境

登录宝塔 侧边栏点击-软件商店 安装 MySQLphpMyAdminRedis进程守护管理器(只需安装这几个即可)

图片[8]-Wordpress子比主题接入EPUSDT插件支付收款功能

安装完成后,侧边栏点击-网站-添加站点,填写您准备的域名、创建数据库、PHP选择伪静态,最后点击提交

图片[9]-Wordpress子比主题接入EPUSDT插件支付收款功能

创建数据库

添加完站点,侧边栏点击-数据库,找到刚才创建的数据库,点击管理-登录到该数据库

图片[10]-Wordpress子比主题接入EPUSDT插件支付收款功能

复制下面的代码,粘贴至phpmyadmin的SQL面板,然后执行

-- auto-generated definition
create table orders
(
    id                   int auto_increment
        primary key,
    trade_id             varchar(32)    not null comment 'epusdt订单号',
    order_id             varchar(32)    not null comment '客户交易id',
    block_transaction_id varchar(128)   null comment '区块唯一编号',
    actual_amount        decimal(19, 4) not null comment '订单实际需要支付的金额,保留4位小数',
    amount               decimal(19, 4) not null comment '订单金额,保留4位小数',
    token                varchar(50)    not null comment '所属钱包地址',
    status               int default 1  not null comment '1:等待支付,2:支付成功,3:已过期',
    notify_url           varchar(128)   not null comment '异步回调地址',
    redirect_url         varchar(128)   null comment '同步回调地址',
    callback_num         int default 0  null comment '回调次数',
    callback_confirm     int default 2  null comment '回调是否已确认? 1是 2否',
    created_at           timestamp      null,
    updated_at           timestamp      null,
    deleted_at           timestamp      null,
    constraint orders_order_id_uindex
        unique (order_id),
    constraint orders_trade_id_uindex
        unique (trade_id)
);

create index orders_block_transaction_id_index
    on orders (block_transaction_id);

-- auto-generated definition
create table wallet_address
(
    id         int auto_increment
        primary key,
    token      varchar(50)   not null comment '钱包token',
    status     int default 1 not null comment '1:启用 2:禁用',
    created_at timestamp     null,
    updated_at timestamp     null,
    deleted_at timestamp     null
)
    comment '钱包表';

create index wallet_address_token_index
    on wallet_address (token);
图片[11]-Wordpress子比主题接入EPUSDT插件支付收款功能

接下来点击下载Epusdt已编译程序 (注意下载图中版本,否则无法运行)

图片[12]-Wordpress子比主题接入EPUSDT插件支付收款功能

上传至刚才新增站点的网站目录下,并将 .env.example 重命名为 .env

图片[13]-Wordpress子比主题接入EPUSDT插件支付收款功能

配置.env文件

编辑 .env 文件,只需修改或填写:您的收款域名数据库机器人Token管理员IDapi接口认证

app_name=epusdt
#下面配置你的域名,收银台会需要
app_uri=您的收款域名
#是否开启debug,默认false
app_debug=false
#http服务监听端口
http_listen=:8000

#静态资源文件目录
static_path=/static
#缓存路径
runtime_root_path=/runtime

#日志配置
log_save_path=/logs
log_max_size=32
log_max_age=7
max_backups=3

# mysql配置
mysql_host=127.0.0.1
mysql_port=3306
mysql_user=mysql账号
mysql_passwd=mysql密码
mysql_database=数据库
mysql_table_prefix=
mysql_max_idle_conns=10
mysql_max_open_conns=100
mysql_max_life_time=6

# redis配置
redis_host=127.0.0.1
redis_port=6379
redis_passwd=
redis_db=5
redis_pool_size=5
redis_max_retries=3
redis_idle_timeout=1000

# 消息队列配置
queue_concurrency=10
queue_level_critical=6
queue_level_default=3
queue_level_low=1

#机器人Apitoken
tg_bot_token= 机器人Token
#telegram代理url(大陆地区服务器可使用一台国外服务器做反代tg的url),如果运行的本来就是境外服务器,则无需填写
tg_proxy=
#管理员userid
tg_manage= 管理员ID

#api接口认证token(用于发起交易的签名认证,请勿外泄)
api_auth_token= 自定义(格式:数字+字母)

#订单过期时间(单位分钟)
order_expiration_time=10

#强制汇率(设置此参数后每笔交易将按照此汇率计算,例如:6.4)
forced_usdt_rate=

添加反向代理

编辑并保存后,侧边栏点击-网站-设置-添加反向代理,如图填写并提交

图片[14]-Wordpress子比主题接入EPUSDT插件支付收款功能

可执行文件赋权

完成后,返回到网站目录下,找到Epusdt文件,修改权限为777

图片[15]-Wordpress子比主题接入EPUSDT插件支付收款功能

添加进程守护

在 软件商店中 打开进程守护管理器 添加守护进程

  • 运行目录 选择新增站点根目录下
  • 启动命令 = 运行目录+/epusdt http start (列如:/www/wwwroot/usdt/epusdt http start)
图片[16]-Wordpress子比主题接入EPUSDT插件支付收款功能

添加钱包地址

到这里程序就安装好了,之后打开自己机器人的对话框,输入/start 按照提示绑定自己的钱包地址即可

图片[17]-Wordpress子比主题接入EPUSDT插件支付收款功能

子比Epusdt插件安装

常见问题及解答

  1. 检查服务器800063973306端口是否开启
  2. 检查数据库用户名密码信息是否填写正确
  3. 核对机器人Token管理员ID是否无误

  1. 核对子比插件目录是否上传正确
  2. 如果您的Epusdt程序安装在国内服务器,则需要反代Telegram Bot API
  3. 核对Epusdt收款接口信息是否填写无误

可以正常收款,子比站点用国内国外都不影响,主要是Epusdt程序需要用国外服务器搭建

扩展

Telegram BOT API 自建反代

如果您的Epusdt程序是用的国内服务器搭建,那么则需要自建反代API

#telegram代理url(大陆地区服务器可使用一台国外服务器做反代tg的url),如果运行的本来就是境外服务器,则无需填写
tg_proxy=

这需要准备一台国外的服务器,安装宝塔 环境安装 NginxPHP7.4 (只安装这两个即可)

图片[18]-Wordpress子比主题接入EPUSDT插件支付收款功能

新建一个站点,在网站根目录下创建index.php以及tgproxy.php,复制对应文件代码粘贴并保存

index.php

<!DOCTYPE html>
<html>
<head>
	<!-- UI from here: https://codepen.io/FlorinPop17/pen/dyPvNKK -->
	<title>Telegram Bot API Proxy</title>
	<link rel="icon" href="https://cdn.staticaly.com/gh/xiaowansm5/img@master/logo/telegram.3b3qa2l7qwg0.webp">
	<style type="text/css">
		@import url('https://fonts.googleapis.com/css?family=Muli&display=swap');

		* {
			box-sizing: border-box;
		}

		body {
			background-image: linear-gradient(45deg, #7175da, #9790F2);
			font-family: 'Muli', sans-serif;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			min-height: 100vh;
			margin: 0;
		}

		.courses-container {
			
		}

		.course {
			background-color: #fff;
			border-radius: 10px;
			box-shadow: 0 10px 10px rgba(0, 0, 0, 0.2);
			display: flex;
			max-width: 100%;
			margin: 20px;
			overflow: hidden;
			width: 700px;
		}

		.course h6 {
			opacity: 0.6;
			margin: 0;
			letter-spacing: 1px;
			text-transform: uppercase;
		}

		.course h2 {
			letter-spacing: 1px;
			margin: 10px 0;
		}

		.course-preview {
			background-color: #2A265F;
			color: #fff;
			padding: 30px;
			max-width: 250px;
		}

		.course-preview a {
			color: #fff;
			display: inline-block;
			font-size: 12px;
			opacity: 0.6;
			margin-top: 30px;
			text-decoration: none;
		}

		.course-info {
			padding: 30px;
			position: relative;
			width: 100%;
		}

		.progress-container {
			position: absolute;
			top: 30px;
			right: 30px;
			text-align: right;
			width: 150px;
		}

		.progress {
			background-color: #ddd;
			border-radius: 3px;
			height: 5px;
			width: 100%;
		}

		.progress::after {
			border-radius: 3px;
			background-color: #2A265F;
			content: '';
			position: absolute;
			top: 0;
			left: 0;
			height: 5px;
			width: 66%;
		}

		.progress-text {
			font-size: 10px;
			opacity: 0.6;
			letter-spacing: 1px;
		}

		.btn {
			background-color: #2A265F;
			border: 0;
			border-radius: 50px;
			box-shadow: 0 10px 10px rgba(0, 0, 0, 0.2);
			color: #fff;
			font-size: 16px;
			padding: 12px 25px;
			position: absolute;
			bottom: 15px;
			right: 15px;
			letter-spacing: 1px;
			text-decoration: none;
		}

		#domain {
			cursor: pointer;
		}
	</style>
</head>
<body>
	<div class="courses-container">
		<div class="course">
			<div class="course-preview">
				<h2>TelegramRC Bot</h2>
			</div>
			<div class="course-info">
				<h2>Proxy for Telegram Bot API</h2>
				<p>URI for using this proxy: <b id="domain" onclick="selectText(this)">https://<?php echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; ?></b></p>
				<a class="btn" href="https://anlenotes.com" target="_blank">ANLENOTES</a>
			</div>
		</div>
	</div>

	<script type="text/javascript">
		function selectText(node) {
		    if (document.body.createTextRange) {
		        const range = document.body.createTextRange();
		        range.moveToElementText(node);
		        range.select();
		    } else if (window.getSelection) {
		        const selection = window.getSelection();
		        const range = document.createRange();
		        range.selectNodeContents(node);
		        selection.removeAllRanges();
		        selection.addRange(range);
		    } else {
		        console.warn("Could not select text in node: Unsupported browser.");
		    }
		}
	</script>
</body>
</html>

tgproxy.php

<?php 
/**
 * Script retranslates queries to telegram bot API
 */
class TelegramApiProxy {
	private $url;
	private $ch;
	private $log = false;

	public function __construct(){
		$this->getUrl();
		$this->initCurl();
	}

	public function setLog(bool $log){
		$this->log = $log;
	}

	private function log(string $m){
		if(!$this->log) return;
		file_put_contents('proxy.log', $m . PHP_EOL, FILE_APPEND);
	}

	public function start(){
		$this->log('[' . date('Y-m-d H:i:s') . '] Query init. URL: ' . $this->url);
		$this->sendRequest();

		$response = curl_exec($this->ch);
		$debug = curl_getinfo($this->ch);
		$this->log('Response headers: code=' . $debug['http_code'] . '; content_type=' . $debug['content_type'] . '; size_upload=' . $debug['size_upload'] . '; size_download=' . $debug['size_upload'] . ';');
		$this->log('Response body: ' . $response);
		$this->log(' ');

		$this->sendResponse($response, $debug['content_type'], $debug['http_code']);
	}

	private function sendResponse(string $response, string $type, int $code){
		header('Content-type: ' . $type, $code);
		die($response);
	}

	public function getUrl(){
		$dir = dirname($_SERVER['SCRIPT_NAME']); // detect path to dir
		if(strpos($_SERVER['REQUEST_URI'], $dir) === 0){
			$uri = substr($_SERVER['REQUEST_URI'], strlen($dir));
		} else {
			$uri = $_SERVER['REQUEST_URI'];
		}

		if(substr($uri, 0, 1) != '/'){
			$uri = '/' . $uri;
		}
		
		return $this->url = "https://api.telegram.org" . $uri;
	}

	private function initCurl(){
		$this->ch = curl_init($this->url);
		curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);			
		return $this->ch;
	}

	private function sendRequest(){
		$method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
		$this->log('HTTP Request: ' . $method);

		if($method == 'POST'){
			curl_setopt($this->ch, CURLOPT_POST, true);
		
			if(sizeof($_FILES) > 0){
				$post = [];
				foreach ($_FILES as $name => $file) {
					$post[$name] = new CURLFile($file['tmp_name'], $file['type'], $file['name']);	
				}

				foreach ($_POST as $name => $value) {
					$post[$name] = $value;	
				}

			} else {
				$post = file_get_contents('php://input');
				$ct = $_SERVER['HTTP_CONTENT_TYPE'] ?? $_SERVER['CONTENT_TYPE'];
				curl_setopt($this->ch, CURLOPT_HTTPHEADER, ['Content-type: ' . $ct]);
			}

			curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post);
			$this->log('Send data: ' . var_export($post, true));

		} else {
			curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, $method);
		}
	}
}

$proxy = new TelegramApiProxy;
$proxy->setLog(false); // use logs only for debug
$proxy->start();
?>

设置站点ssl,并开启强制https,设置伪静态

rewrite ^/bot.*$ /tgproxy.php last;

然后在这里填写您的站点域名即可 列如:

#telegram代理url(大陆地区服务器可使用一台国外服务器做反代tg的url),如果运行的本来就是境外服务器,则无需填写
tg_proxy=https://tgapi.anlenotes.com

收款页面美化

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容