mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
update
This commit is contained in:
parent
b3b0988730
commit
dc6317db97
@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Services\PaymentService;
|
use App\Services\PaymentService;
|
||||||
|
use App\Utils\Helper;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
@ -56,7 +57,8 @@ class PaymentController extends Controller
|
|||||||
if (!Payment::create([
|
if (!Payment::create([
|
||||||
'name' => $request->input('name'),
|
'name' => $request->input('name'),
|
||||||
'payment' => $request->input('payment'),
|
'payment' => $request->input('payment'),
|
||||||
'config' => $request->input('config')
|
'config' => $request->input('config'),
|
||||||
|
'uuid' => Helper::guid()
|
||||||
])) {
|
])) {
|
||||||
abort(500, '保存失败');
|
abort(500, '保存失败');
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,10 @@ use App\Http\Controllers\Controller;
|
|||||||
|
|
||||||
class PaymentController extends Controller
|
class PaymentController extends Controller
|
||||||
{
|
{
|
||||||
public function notify($method, $id, Request $request)
|
public function notify($method, $uuid, Request $request)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$paymentService = new PaymentService($method, $id);
|
$paymentService = new PaymentService($method, null, $uuid);
|
||||||
$verify = $paymentService->notify($request->input());
|
$verify = $paymentService->notify($request->input());
|
||||||
if (!$verify) abort(500, 'verify error');
|
if (!$verify) abort(500, 'verify error');
|
||||||
if (!$this->handle($verify['trade_no'], $verify['callback_no'])) {
|
if (!$this->handle($verify['trade_no'], $verify['callback_no'])) {
|
||||||
|
@ -21,7 +21,7 @@ class GuestRoute
|
|||||||
// Telegram
|
// Telegram
|
||||||
$router->post('/telegram/webhook', 'Guest\\TelegramController@webhook');
|
$router->post('/telegram/webhook', 'Guest\\TelegramController@webhook');
|
||||||
// Payment
|
// Payment
|
||||||
$router->match(['get', 'post'], '/payment/notify/{method}/{id}', 'Guest\\PaymentController@notify');
|
$router->match(['get', 'post'], '/payment/notify/{method}/{uuid}', 'Guest\\PaymentController@notify');
|
||||||
// Comm
|
// Comm
|
||||||
$router->get ('/comm/config', 'Guest\\CommController@config');
|
$router->get ('/comm/config', 'Guest\\CommController@config');
|
||||||
});
|
});
|
||||||
|
@ -7,17 +7,19 @@ use App\Models\Payment;
|
|||||||
|
|
||||||
class PaymentService
|
class PaymentService
|
||||||
{
|
{
|
||||||
public function __construct($method, $id = NULL)
|
public function __construct($method, $id = NULL, $uuid = NULL)
|
||||||
{
|
{
|
||||||
$this->method = $method;
|
$this->method = $method;
|
||||||
$this->class = '\\App\\Payments\\' . $this->method;
|
$this->class = '\\App\\Payments\\' . $this->method;
|
||||||
if (!class_exists($this->class)) abort(500, 'gate is not found');
|
if (!class_exists($this->class)) abort(500, 'gate is not found');
|
||||||
if ($id) $payment = Payment::find($id)->toArray();
|
if ($id) $payment = Payment::find($id)->toArray();
|
||||||
|
if ($uuid) $payment = Payment::where('uuid', $uuid)->first()->toArray();
|
||||||
$this->config = [];
|
$this->config = [];
|
||||||
if (isset($payment)) {
|
if (isset($payment)) {
|
||||||
$this->config = json_decode($payment['config'], true);
|
$this->config = json_decode($payment['config'], true);
|
||||||
$this->config['enable'] = $payment['enable'];
|
$this->config['enable'] = $payment['enable'];
|
||||||
$this->config['id'] = $payment['id'];
|
$this->config['id'] = $payment['id'];
|
||||||
|
$this->config['uuid'] = $payment['uuid'];
|
||||||
};
|
};
|
||||||
$this->payment = new $this->class($this->config);
|
$this->payment = new $this->class($this->config);
|
||||||
}
|
}
|
||||||
@ -31,7 +33,7 @@ class PaymentService
|
|||||||
public function pay($order)
|
public function pay($order)
|
||||||
{
|
{
|
||||||
return $this->payment->pay([
|
return $this->payment->pay([
|
||||||
'notify_url' => url("/api/v1/guest/payment/notify/{$this->method}/{$this->config['id']}"),
|
'notify_url' => url("/api/v1/guest/payment/notify/{$this->method}/{$this->config['uuid']}"),
|
||||||
'return_url' => config('v2board.app_url', env('APP_URL')) . '/#/order/' . $order['trade_no'],
|
'return_url' => config('v2board.app_url', env('APP_URL')) . '/#/order/' . $order['trade_no'],
|
||||||
'trade_no' => $order['trade_no'],
|
'trade_no' => $order['trade_no'],
|
||||||
'total_amount' => $order['total_amount'],
|
'total_amount' => $order['total_amount'],
|
||||||
|
@ -119,6 +119,7 @@ CREATE TABLE `v2_order` (
|
|||||||
DROP TABLE IF EXISTS `v2_payment`;
|
DROP TABLE IF EXISTS `v2_payment`;
|
||||||
CREATE TABLE `v2_payment` (
|
CREATE TABLE `v2_payment` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`uuid` char(32) NOT NULL,
|
||||||
`payment` varchar(16) NOT NULL,
|
`payment` varchar(16) NOT NULL,
|
||||||
`name` varchar(255) NOT NULL,
|
`name` varchar(255) NOT NULL,
|
||||||
`config` text NOT NULL,
|
`config` text NOT NULL,
|
||||||
@ -346,4 +347,4 @@ CREATE TABLE `v2_user` (
|
|||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
-- 2021-04-28 08:53:45
|
-- 2021-05-06 16:14:04
|
||||||
|
@ -408,3 +408,6 @@ CREATE TABLE `v2_payment` (
|
|||||||
|
|
||||||
ALTER TABLE `v2_order`
|
ALTER TABLE `v2_order`
|
||||||
ADD `payment_id` int(11) NULL AFTER `coupon_id`;
|
ADD `payment_id` int(11) NULL AFTER `coupon_id`;
|
||||||
|
|
||||||
|
ALTER TABLE `v2_payment`
|
||||||
|
ADD `uuid` char(32) NOT NULL AFTER `id`;
|
||||||
|
Loading…
Reference in New Issue
Block a user