remove redundant and unused payment methods

This commit is contained in:
xboard
2025-07-12 03:43:39 +08:00
parent 97788e3c8f
commit 1bb1e032d6
5 changed files with 9 additions and 434 deletions

9
app/Payments/.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
*
!.gitignore
!AlipayF2F.php
!BTCPay.php
!Coinbase.php
!CoinPayments.php
!EPay.php
!MGate.php

View File

@@ -1,118 +0,0 @@
<?php
namespace App\Payments;
use Illuminate\Support\Facades\Log;
class BinancePay
{
protected $config;
public function __construct($config)
{
$this->config = $config;
}
public function form()
{
return [
'api_key' => [
'label' => 'API Key',
'type' => 'input',
'description' => '请输入您的 Binance API Key'
],
'secret_key' => [
'label' => 'Secret Key',
'type' => 'input',
'description' => '请输入您的 Binance Secret Key'
]
];
}
public function pay($order)
{
$timestamp = intval(microtime(true) * 1000); // Timestamp in milliseconds
$nonceStr = bin2hex(random_bytes(16)); // Generating a nonce
$request = [
"env" => [
"terminalType" => "APP"
],
'merchantTradeNo' => strval($order['trade_no']),
'fiatCurrency' => 'CNY',
'fiatAmount' => ($order["total_amount"] / 100),
'supportPayCurrency' => "USDT,BNB",
'description' => strval($order['trade_no']),
'webhookUrl' => $order['notify_url'],
'returnUrl' => $order['return_url'],
"goodsDetails" => [
[
"goodsType" => "01",
"goodsCategory" => "D000",
"referenceGoodsId" => "7876763A3B",
"goodsName" => "Ice Cream",
"goodsDetail" => "Greentea ice cream cone"
]
]
];
$body = json_encode($request, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://bpay.binanceapi.com/binancepay/openapi/v3/order');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json; charset=utf-8',
'BinancePay-Timestamp: ' . $timestamp,
'BinancePay-Nonce: ' . $nonceStr,
'BinancePay-Certificate-SN: ' . $this->config['api_key'],
'BinancePay-Signature: ' . $this->generateSignature($body, $this->config['secret_key'], $timestamp, $nonceStr),
]);
curl_setopt($ch, CURLOPT_PROXY, "socks5h://154.3.37.204:47714");
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "GGn28Io5fW:9VkWfoPGiG");
$response = curl_exec($ch);
curl_close($ch);
if (!$response) {
abort(400, '支付失败,请稍后再试');
}
$res = json_decode($response, true);
\Log::channel('daily')->info($res);
if (!is_array($res)) {
abort(400, '支付失败,请稍后再试');
}
if (isset($res['code']) && $res['code'] == '400201') {
$res['data'] = \Cache::get('CheckoutInfo_' . strval($order['trade_no']));
}
if (!isset($res['data'])) {
abort(400, '支付失败,请稍后再试');
}
if (!is_array($res['data']) || !isset($res['data']['checkoutUrl'])) {
abort(400, '支付失败,请稍后再试');
}
// 缓存支付信息
\Cache::put('CheckoutInfo_' . strval($order['trade_no']), $res['data']);
return [
'type' => 1, // 0:qrcode 1:url
'data' => $res['data']['checkoutUrl']
];
}
public function notify($params)
{
$bizStatus = $params['bizStatus'];
if ($bizStatus !== 'PAY_SUCCESS'){
return false;
}
$data = json_decode($params['data'], true);
return [
'trade_no' => $data['merchantTradeNo'],
'callback_no' => $params['bizIdStr'],
'custom_result' => '{"returnCode":"SUCCESS","returnMessage":null}'
];
}
private function generateSignature($body, $secret, $timestamp, $nonceStr)
{
$payload = $timestamp . chr(0x0A) . $nonceStr . chr(0x0A) . $body . chr(0x0A);
return strtoupper(hash_hmac('sha512', $payload, $secret));
}
}

View File

@@ -1,71 +0,0 @@
<?php
namespace App\Payments;
class EPayWxpay {
protected $config;
public function __construct($config)
{
$this->config = $config;
}
public function form()
{
return [
'url' => [
'label' => 'URL',
'description' => '',
'type' => 'input',
],
'pid' => [
'label' => 'PID',
'description' => '',
'type' => 'input',
],
'key' => [
'label' => 'KEY',
'description' => '',
'type' => 'input',
]
];
}
public function pay($order)
{
$params = [
'money' => $order['total_amount'] / 100,
'type' => 'wxpay',
'name' => $order['trade_no'],
'notify_url' => $order['notify_url'],
'return_url' => $order['return_url'],
'out_trade_no' => $order['trade_no'],
'pid' => $this->config['pid']
];
ksort($params);
reset($params);
$str = stripslashes(urldecode(http_build_query($params))) . $this->config['key'];
$params['sign'] = md5($str);
$params['sign_type'] = 'MD5';
return [
'type' => 1, // 0:qrcode 1:url
'data' => $this->config['url'] . '/submit.php?' . http_build_query($params)
];
}
public function notify($params)
{
$sign = $params['sign'];
unset($params['sign']);
unset($params['sign_type']);
ksort($params);
reset($params);
$str = stripslashes(urldecode(http_build_query($params))) . $this->config['key'];
if ($sign !== md5($str)) {
return false;
}
return [
'trade_no' => $params['out_trade_no'],
'callback_no' => $params['trade_no']
];
}
}

View File

@@ -1,113 +0,0 @@
<?php
namespace App\Payments;
class HiiCashPayment
{
protected $config;
public function __construct($config)
{
$this->config = $config;
}
public function form()
{
return [
'rate' => [
'label' => '汇率',
'description' => 'HiiCash支付单位为美元如果您站点金额单位不为美元则需要填写汇率',
'type' => 'input',
'default' => '2333'
],
'pid' => [
'label' => '商户号',
'description' => '',
'type' => 'input',
],
'appid' => [
'label' => '应用ID',
'description' => '',
'type' => 'input'
],
'key' => [
'label' => '私钥',
'description' => '',
'type' => 'input',
]
];
}
public function pay($order)
{
$request = [
"mchNo" => $this->config["pid"],
"appId" => $this->config["appid"],
"mchOrderNo" => $order["trade_no"],
"amount" => ceil(($order["total_amount"] * 100) / ($this->config['rate'] ?? "1")) / 100,
"payDataType" => "Cashier",
"currency" => "USD",
"subject" => $order["trade_no"],
"notifyUrl" => $order["notify_url"],
"returnUrl" => $order["return_url"],
];
$headers = [
"HiicashPay-Timestamp" => (int)(string)floor(microtime(true) * 1000),
"HiicashPay-Nonce" => \Str::random(32),
"HiicashPay-AppId" => $this->config["appid"]
];
$body = json_encode($request, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$payload = $headers['HiicashPay-Timestamp'] . chr(0x0A) . $headers['HiicashPay-Nonce'] . chr(0x0A) . $body . chr(0x0A);
$signature = $this->generate_signature($payload, $this->config['key']);
$headers["HiicashPay-Signature"] = $signature;
$jsonStr = json_encode($request, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$httpHeaders = [];
foreach ($headers as $key => $header) {
$httpHeaders[] = $key . ': ' . $header;
}
$httpHeaders[] = 'Content-Type: application/json; charset=utf-8';
$httpHeaders[] = 'Content-Length: ' . strlen($jsonStr);
$ch = curl_init(file_get_contents('https://hiicash.oss-ap-northeast-1.aliyuncs.com/gateway.txt') . 'pay/order/create');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeaders);
$response = curl_exec($ch);
curl_close($ch);
if (!$response) {
abort(400, '支付失败,请稍后再试');
}
$res = json_decode($response, true);
if (!is_array($res) || !isset($res['data'])) {
abort(400, '支付失败,请稍后再试');
}
if (!is_array($res['data']) || !isset($res['data']['payData'])) {
abort(400, '支付失败,请稍后再试');
}
return [
'type' => 1, // 0:qrcode 1:url
'data' => $res['data']['payData']
];
}
public function notify($params)
{
if (!isset($params['mchOrderNo']) || !isset($params['mchOrderNo'])) {
return false;
}
return [
'trade_no' => $params['mchOrderNo'],
'callback_no' => $params['payOrderId'],
'custom_result' => '{"returnCode": "success","returnMsg": ""}'
];
}
// 使用 HMAC-SHA512 算法生成签名
function generate_signature(string $payload, string $secret_key)
{
$hash = hash_hmac("sha512", $payload, $secret_key, true);
// 将签名转换为大写字符串
return strtoupper(bin2hex($hash));
}
}

View File

@@ -1,132 +0,0 @@
<?php
namespace App\Payments;
use GuzzleHttp\Client;
class PayPal
{
private $config;
private $client;
private $token;
private $apiHost;
public function __construct($config)
{
$this->config = $config;
$this->client = new Client();
$this->apiHost = optional($this->config)['mode'] == 'sandbox' ? "https://api.sandbox.paypal.com" : "https://api.paypal.com";
}
public function form()
{
return [
'mode' => [
'label' => 'Mode',
'description' => '沙箱/生产模式 sandbox/live',
'type' => 'input',
],
'client_id' => [
'label' => 'Client ID',
'description' => 'PayPal Client ID',
'type' => 'input',
],
'client_secret' => [
'label' => 'Client Secret',
'description' => 'PayPal Client Secret',
'type' => 'input',
],
'rate' => [
'label' => '汇率',
'description' => 'Paypal支付单位为USD如果您站点金额单位不为USD则需要填写汇率',
'type' => 'input',
'default' => '2333'
],
];
}
public function pay($order)
{
$this->token = json_decode($this->client->post("{$this->apiHost}/v1/oauth2/token", [
'auth' => [$this->config['client_id'], $this->config['client_secret']],
'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
'form_params' => ['grant_type' => 'client_credentials']
])->getBody(), true)['access_token'];
// 创建订单
$order = json_decode($this->client->request('POST', "{$this->apiHost}/v2/checkout/orders", [
'headers' => [
'Content-Type' => 'application/json',
'PayPal-Request-Id' => $order['trade_no'],
'Authorization' => "Bearer {$this->token}"
],
'json' => [
'intent' => 'CAPTURE',
'purchase_units' => [
[
"reference_id" => $order['trade_no'],
"amount" => [
"currency_code" => "USD",
"value" => number_format(ceil(($order["total_amount"] * 100) / ($this->config['rate'] ?? "1")) / 10000, 2, '.', '')
]
]
],
"payment_source" => [
"paypal" => [
"experience_context" => [
"payment_method_preference" => "UNRESTRICTED",
"brand_name" => $order['trade_no'],
"locale" => "zh-CN",
"landing_page" => "NO_PREFERENCE",
"shipping_preference" => "NO_SHIPPING",
"user_action" => "PAY_NOW",
"return_url" => $order['return_url'],
"cancel_url" => $order['return_url']
]
]
]
]
])->getBody(), true);
$payerActionUrl = '';
foreach ($order['links'] as $link) {
if ($link['rel'] === 'payer-action') {
$payerActionUrl = $link['href'];
break;
}
}
return [
'type' => 1, // 0:qrcode 1:url
'data' => $payerActionUrl
];
}
public function notify($params)
{
$this->token = json_decode($this->client->post("{$this->apiHost}/v1/oauth2/token", [
'auth' => [$this->config['client_id'], $this->config['client_secret']],
'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
'form_params' => ['grant_type' => 'client_credentials']
])->getBody(), true)['access_token'];
$resource = $params['resource'];
$purchase_units = $resource['purchase_units'];
if ($params['event_type'] == 'CHECKOUT.ORDER.APPROVED') {
$order = json_decode($this->client->request('POST', "{$this->apiHost}/v2/checkout/orders/{$resource['id']}/capture", [
"headers" => [
'Content-Type' => 'application/json',
'Authorization' => "Bearer {$this->token}"
]
])->getBody(), true);
if ($order['status'] == 'COMPLETED') {
return [
'trade_no' => $purchase_units[0]['reference_id'],
'callback_no' => $order['id']
];
}
}
return false;
}
}