diff --git a/bepusdt/README.md b/bepusdt/README.md index 8817ed7..7cb3248 100644 --- a/bepusdt/README.md +++ b/bepusdt/README.md @@ -1,3 +1,5 @@ ## 介绍 -支持arm,修改自:https://github.com/v03413/bepusdt?tab=readme-ov-file \ No newline at end of file +支持arm,修改自:https://github.com/v03413/bepusdt?tab=readme-ov-file + +独角数卡接口地址配置格式:https://usdt.xxx.com/api/v1/order/create-transaction \ No newline at end of file diff --git a/epay/Dockerfile b/epay/Dockerfile index 29bc90a..1a143de 100644 --- a/epay/Dockerfile +++ b/epay/Dockerfile @@ -45,6 +45,8 @@ RUN git clone https://github.com/LightCountry/TokenPay && \ # Expose端口 EXPOSE 80 +ADD plugins /tmp/epay/plugins + COPY start.sh /opt/start.sh RUN chmod +x /opt/start.sh diff --git a/epay/plugins/bepusdt/bepusdt_plugin.php b/epay/plugins/bepusdt/bepusdt_plugin.php new file mode 100644 index 0000000..2e45c38 --- /dev/null +++ b/epay/plugins/bepusdt/bepusdt_plugin.php @@ -0,0 +1,106 @@ + 'bepusdt', + 'showname' => 'Bepusdt(一款更好用的个人USDT收款网关)', + 'author' => '莫名', + 'link' => 'https://github.com/v03413/bepusdt', //支付插件作者链接 + 'types' => ['usdt'], //支付插件支持的支付方式,可选的有alipay,qqpay,wxpay,bank + 'inputs' => [ //支付插件要求传入的参数以及参数显示名称,可选的有appid,appkey,appsecret,appurl,appmchid + 'appid' => [ + 'name' => '接口地址', + 'type' => 'input', + 'note' => '必须以http://或https://开头,以/结尾', + ], + 'appsecret' => [ + 'name' => 'Token', + 'type' => 'input', + 'note' => '', + ] + ], + 'select' => null, + 'note' => '' + ]; + + public static function submit(): array + { + global $siteurl, $channel, $order, $conf; + + $data = [ + "order_id" => TRADE_NO, + "amount" => (float)$order['realmoney'], + "notify_url" => $conf['localurl'] . 'pay/notify/' . TRADE_NO . '/', + "redirect_url" => $siteurl . 'pay/return/' . TRADE_NO . '/', + ]; + $resp = self::createTransaction($data, $channel['appid'], $channel['appsecret']); + $json = json_decode($resp, true); + if (!is_array($json) || $json['status_code'] != 200) { + + return ['type' => 'error', 'msg' => 'Bepusdt 订单创建失败,请检测相关配置是否错误!']; + } + + return ['type' => 'jump', 'url' => $json['data']['payment_url']]; + } + + public static function notify() + { + global $channel, $order; + + $data = json_decode(file_get_contents('php://input'), true); + if (!is_array($data)) { + + exit('fail'); + } + + $sign = $data['signature']; + unset($data['signature']); + + if ($sign != self::toSign($data, $channel['appsecret'])) { + + exit('sign error'); + } + + processNotify($order, $data['trade_id']); + + exit('ok'); + } + + public static function return() + { + global $order; + + processReturn($order, $order['api_trade_no']); + } + + private static function toSign(array $data, $token): string + { + ksort($data); + $sign = ''; + foreach ($data as $k => $v) { + if ($v == '') continue; + $sign .= $k . '=' . $v . '&'; + } + $sign = trim($sign, '&'); + return md5($sign . $token); + } + + private static function createTransaction(array $data, $api, $token) + { + $data['signature'] = self::toSign($data, $token); + + $url = $api . 'api/v1/order/create-transaction'; + $header = ['Content-Type: application/json; charset=UTF-8']; + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); //SSL证书认证false + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); //严格认证false + curl_setopt($curl, CURLOPT_HTTPHEADER, $header); //设置HTTPHEADER + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 显示输出结果 + curl_setopt($curl, CURLOPT_POST, true); // post传输数据 + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); // post传输数据 + $res = curl_exec($curl); + curl_close($curl); + return $res; + } +} \ No newline at end of file