mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-12 23:48:53 +00:00
1. 优化支付文件框架为后续大改做准备; 2. 重构了支付宝面对面支付; - 本次重构解决了PHP版本>7.3 导致该支付无法使用的问题; - 自行开发的接入方式,简化&快捷化了代码; 3. 修正 Stripe 汇率API 查询的代码 & 部分报错代码; TODO: 1. 汇率查询API 应该集中统一化(Paypal & Stripe 都需要汇率转换); 2. 简化支付对接成本(单文件自动对接);
36 lines
949 B
PHP
36 lines
949 B
PHP
<?php
|
|
|
|
namespace App\Payments;
|
|
|
|
use App\Components\Helpers;
|
|
use App\Models\Goods;
|
|
use App\Models\Order;
|
|
use App\Payments\Library\Gateway;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Response;
|
|
|
|
class Local extends Gateway
|
|
{
|
|
public function purchase($request): JsonResponse
|
|
{
|
|
$order = Order::find($request->input('id'));
|
|
$goods = Goods::find($request->input('goods_id'));
|
|
$user = $order->user;
|
|
|
|
if ($user && $goods) {
|
|
$user->update(['credit' => $user->credit - $order->amount]);
|
|
// 记录余额操作日志
|
|
Helpers::addUserCreditLog($user->id, $order->id, $user->credit + $order->amount, $user->credit, -1 * $order->amount, '购买商品'.$goods->name);
|
|
}
|
|
|
|
$order->complete();
|
|
|
|
return Response::json(['status' => 'success', 'message' => '购买完成!']);
|
|
}
|
|
|
|
public function notify(Request $request): void
|
|
{
|
|
}
|
|
}
|