mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
Compare commits
4 Commits
97e9f7297d
...
48f7539918
Author | SHA1 | Date | |
---|---|---|---|
|
48f7539918 | ||
|
7acae3dcc4 | ||
|
dff2e721cb | ||
|
fc6bb8cf34 |
7
.github/workflows/docker-publish.yml
vendored
7
.github/workflows/docker-publish.yml
vendored
@ -2,7 +2,7 @@ name: Docker Build and Publish
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ["legacy"]
|
branches: ["legacy", "dev"]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
@ -73,6 +73,9 @@ jobs:
|
|||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
tags: |
|
tags: |
|
||||||
${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:legacy
|
${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:legacy
|
||||||
|
${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:dev
|
||||||
|
${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard
|
||||||
|
${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:latest
|
||||||
${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:${{ steps.get_version.outputs.version }}
|
${{ env.REGISTRY }}/${{ github.repository_owner }}/xboard:${{ steps.get_version.outputs.version }}
|
||||||
build-args: |
|
build-args: |
|
||||||
BUILDKIT_INLINE_CACHE=1
|
BUILDKIT_INLINE_CACHE=1
|
||||||
@ -88,4 +91,4 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
COSIGN_EXPERIMENTAL: 1
|
COSIGN_EXPERIMENTAL: 1
|
||||||
run: |
|
run: |
|
||||||
echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign --yes "{}@${{ steps.build-and-push.outputs.digest }}"
|
echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign --yes "{}@${{ steps.build-and-push.outputs.digest }}"
|
||||||
|
97
app/Payments/EpusdtPay.php
Normal file
97
app/Payments/EpusdtPay.php
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
//author by GoodGoodStudy
|
||||||
|
namespace App\Payments;
|
||||||
|
|
||||||
|
use \Curl\Curl;
|
||||||
|
|
||||||
|
class EpusdtPay {
|
||||||
|
public function __construct($config)
|
||||||
|
{
|
||||||
|
$this->config = $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function form()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'epusdt_pay_url' => [
|
||||||
|
'label' => 'API 地址',
|
||||||
|
'description' => '您的 EpusdtPay API 接口地址(例如: https://epusdt-pay.xxx.com)',
|
||||||
|
'type' => 'input',
|
||||||
|
],
|
||||||
|
'epusdt_pay_apitoken' => [
|
||||||
|
'label' => 'API Token',
|
||||||
|
'description' => '您的 EpusdtPay API Token',
|
||||||
|
'type' => 'input',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pay($order)
|
||||||
|
{
|
||||||
|
$params = [
|
||||||
|
"amount" => round($order['total_amount']/100,2),
|
||||||
|
"order_id" => $order['trade_no'],
|
||||||
|
'redirect_url' => $order['return_url'],
|
||||||
|
'notify_url' => $order['notify_url'],
|
||||||
|
];
|
||||||
|
$params['signature'] = $this->sign($params);
|
||||||
|
|
||||||
|
$curl = new Curl();
|
||||||
|
$curl->setUserAgent('EpusdtPay');
|
||||||
|
$curl->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
|
||||||
|
$curl->setOpt(CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
|
||||||
|
$curl->post($this->config['epusdt_pay_url'] . '/api/v1/order/create-transaction', json_encode($params));
|
||||||
|
$result = $curl->response;
|
||||||
|
$curl->close();
|
||||||
|
if (!isset($result->status_code) || $result->status_code != 200) {
|
||||||
|
abort(500, "Failed to create order. Error: {$result->message}");
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
'type' => 1, // 0:qrcode 1:url
|
||||||
|
'data' => $result->data->payment_url
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function notify($params)
|
||||||
|
{
|
||||||
|
$status = $params['status'];
|
||||||
|
// 1:等待支付,2:支付成功,3:已过期
|
||||||
|
if ($status != 2) {
|
||||||
|
die('failed');
|
||||||
|
}
|
||||||
|
//不合法的数据
|
||||||
|
if (!$this->verify($params)) {
|
||||||
|
die('cannot pass verification');
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
'trade_no' => $params['order_id'],
|
||||||
|
'callback_no' => $params['trade_id'],
|
||||||
|
'custom_result' => 'ok'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verify($params) {
|
||||||
|
return $params['signature'] === $this->sign($params);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function sign(array $params)
|
||||||
|
{
|
||||||
|
ksort($params);
|
||||||
|
reset($params); //内部指针指向数组中的第一个元素
|
||||||
|
$sign = '';
|
||||||
|
$urls = '';
|
||||||
|
foreach ($params as $key => $val) {
|
||||||
|
if ($val == '') continue;
|
||||||
|
if ($key != 'signature') {
|
||||||
|
if ($sign != '') {
|
||||||
|
$sign .= "&";
|
||||||
|
$urls .= "&";
|
||||||
|
}
|
||||||
|
$sign .= "$key=$val"; //拼接为url参数形式
|
||||||
|
$urls .= "$key=" . urlencode($val); //拼接为url参数形式
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sign = md5($sign . $this->config['epusdt_pay_apitoken']);//密码追加进入开始MD5签名
|
||||||
|
return $sign;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user