This commit is contained in:
root 2019-11-29 19:43:01 +08:00
parent 621658ba84
commit be37bcb3bf
4 changed files with 17 additions and 4 deletions

View File

@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
use App\Models\Order;
use Omnipay\Omnipay;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;
class OrderController extends Controller
{
@ -70,9 +71,13 @@ class OrderController extends Controller
$obj = $event->data->object;
if ($obj['status'] == 'chargeable') {
$order = Order::where('callback_no', $obj['id'])->first();
$trade_no = Redis::get($obj['id']);
if (!$trade_no) {
abort(500, 'redis is not found trade no by stripe source id.');
}
$order = Order::where('trade_no', $trade_no)->first();
if (!$order) {
abort(500, 'fail');
abort(500, 'order is not found');
}
if ($order->status !== 0) {
die('order is paid');
@ -81,6 +86,7 @@ class OrderController extends Controller
if (!$order->save()) {
abort(500, 'fail');
}
Redis::del($obj['id']);
die('success');
}
}

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Http\Requests\OrderSave;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Redis;
use App\Models\Order;
use App\Models\Plan;
use App\Models\User;
@ -230,6 +231,9 @@ class OrderController extends Controller
if (!$source['redirect']['url']) {
abort(500, '支付网关请求失败');
}
Redis::set($source['id'], $order->trade_no);
Redis::expire($source['id'], 3600);
$order->callback_no = $source['id'];
if (!$order->save()) {
abort(500, '订单更新失败');
@ -254,6 +258,9 @@ class OrderController extends Controller
if (!$source['wechat']['qr_code_url']) {
abort(500, '支付网关请求失败');
}
Redis::set($source['id'], $order->trade_no);
Redis::expire($source['id'], 3600);
$order->callback_no = $source['id'];
if (!$order->save()) {
abort(500, '订单更新失败');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long