feat: new xboard

This commit is contained in:
xboard
2025-01-21 14:57:54 +08:00
parent de18cfe596
commit 0f43fff242
373 changed files with 17923 additions and 20264 deletions
+7 -4
View File
@@ -4,16 +4,18 @@
* 自己写别抄,抄NMB抄
*/
namespace App\Payments;
use App\Contracts\PaymentInterface;
use App\Exceptions\ApiException;
class AlipayF2F {
class AlipayF2F implements PaymentInterface
{
protected $config;
public function __construct($config)
{
$this->config = $config;
}
public function form()
public function form(): array
{
return [
'app_id' => [
@@ -39,7 +41,7 @@ class AlipayF2F {
];
}
public function pay($order)
public function pay($order): array
{
try {
$gateway = new \Library\AlipayF2F();
@@ -66,7 +68,8 @@ class AlipayF2F {
public function notify($params)
{
if ($params['trade_status'] !== 'TRADE_SUCCESS') return false;
if ($params['trade_status'] !== 'TRADE_SUCCESS')
return false;
$gateway = new \Library\AlipayF2F();
$gateway->setAppId($this->config['app_id']);
$gateway->setPrivateKey($this->config['private_key']); // 可以是路径,也可以是密钥内容
+6 -6
View File
@@ -3,9 +3,9 @@
namespace App\Payments;
use App\Exceptions\ApiException;
use App\Contracts\PaymentInterface;
class BTCPay
class BTCPay implements PaymentInterface
{
protected $config;
public function __construct($config)
@@ -13,7 +13,7 @@ class BTCPay
$this->config = $config;
}
public function form()
public function form(): array
{
return [
'btcpay_url' => [
@@ -39,7 +39,7 @@ class BTCPay
];
}
public function pay($order)
public function pay($order): array
{
$params = [
@@ -66,9 +66,9 @@ class BTCPay
];
}
public function notify($params)
public function notify($params): array|bool
{
$payload = trim(get_request_content());
$payload = trim(request()->getContent());
$headers = getallheaders();
+5 -4
View File
@@ -2,9 +2,10 @@
namespace App\Payments;
use App\Contracts\PaymentInterface;
use App\Exceptions\ApiException;
class CoinPayments
class CoinPayments implements PaymentInterface
{
protected $config;
public function __construct($config)
@@ -12,7 +13,7 @@ class CoinPayments
$this->config = $config;
}
public function form()
public function form(): array
{
return [
'coinpayments_merchant_id' => [
@@ -33,7 +34,7 @@ class CoinPayments
];
}
public function pay($order)
public function pay($order): array
{
// IPN notifications are slow, when the transaction is successful, we should return to the user center to avoid user confusion
@@ -59,7 +60,7 @@ class CoinPayments
return [
'type' => 1, // Redirect to url
'data' => 'https://www.coinpayments.net/index.php?' . $params_string
'data' => 'https://www.coinpayments.net/index.php?' . $params_string
];
}
+6 -5
View File
@@ -2,9 +2,10 @@
namespace App\Payments;
use App\Contracts\PaymentInterface;
use App\Exceptions\ApiException;
class Coinbase
class Coinbase implements PaymentInterface
{
protected $config;
public function __construct($config)
@@ -12,7 +13,7 @@ class Coinbase
$this->config = $config;
}
public function form()
public function form(): array
{
return [
'coinbase_url' => [
@@ -33,7 +34,7 @@ class Coinbase
];
}
public function pay($order)
public function pay($order): array
{
$params = [
@@ -64,10 +65,10 @@ class Coinbase
];
}
public function notify($params)
public function notify($params): array
{
$payload = trim(get_request_content());
$payload = trim(request()->getContent());
$json_param = json_decode($payload, true);
+7 -5
View File
@@ -2,7 +2,9 @@
namespace App\Payments;
class EPay
use App\Contracts\PaymentInterface;
class EPay implements PaymentInterface
{
protected $config;
public function __construct($config)
@@ -10,7 +12,7 @@ class EPay
$this->config = $config;
}
public function form()
public function form(): array
{
return [
'url' => [
@@ -36,7 +38,7 @@ class EPay
];
}
public function pay($order)
public function pay($order): array
{
$params = [
'money' => $order['total_amount'] / 100,
@@ -46,7 +48,7 @@ class EPay
'out_trade_no' => $order['trade_no'],
'pid' => $this->config['pid']
];
if(optional($this->config)['type']){
if (optional($this->config)['type']) {
$params['type'] = $this->config['type'];
}
ksort($params);
@@ -60,7 +62,7 @@ class EPay
];
}
public function notify($params)
public function notify($params): array|bool
{
$sign = $params['sign'];
unset($params['sign']);
+7 -6
View File
@@ -7,8 +7,9 @@ namespace App\Payments;
use App\Exceptions\ApiException;
use \Curl\Curl;
class MGate {
use App\Contracts\PaymentInterface;
class MGate implements PaymentInterface
{
private $config;
public function __construct($config)
@@ -16,7 +17,7 @@ class MGate {
$this->config = $config;
}
public function form()
public function form(): array
{
return [
'mgate_url' => [
@@ -42,7 +43,7 @@ class MGate {
];
}
public function pay($order)
public function pay($order): array
{
$params = [
'out_trade_no' => $order['trade_no'],
@@ -67,7 +68,7 @@ class MGate {
}
if ($curl->error) {
if (isset($result->errors)) {
$errors = (array)$result->errors;
$errors = (array) $result->errors;
throw new ApiException($errors[array_keys($errors)[0]][0]);
}
if (isset($result->message)) {
@@ -85,7 +86,7 @@ class MGate {
];
}
public function notify($params)
public function notify($params): array|bool
{
$sign = $params['sign'];
unset($params['sign']);