-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
## 介绍 | ||
|
||
支持arm,修改自:https://github.com/v03413/bepusdt?tab=readme-ov-file | ||
支持arm,修改自:https://github.com/v03413/bepusdt?tab=readme-ov-file | ||
|
||
独角数卡接口地址配置格式:https://usdt.xxx.com/api/v1/order/create-transaction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
|
||
class bepusdt_plugin | ||
{ | ||
static public $info = [ | ||
'name' => '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; | ||
} | ||
} |