【发布时间】:2020-09-09 12:28:01
【问题描述】:
您好,我正在使用 RaveFlutterWave 作为我的支付网关。我想在客户完成付款时存储订单,但我无法通过该错误。我不知道那里缺少什么。 感谢您的帮助,这是我的代码。
public function callback(Request $request)
{
// $data = Rave::verifyTransaction(request()->txref);
$resp = $request->resp;
$body = json_decode($resp, true);
$txRef = $body['data']['data']['txRef'];
$data = Rave::verifyTransaction($txRef);
return redirect()->route('success');
}
这是我的路线
Route::get('/success', 'RaveController@addToOrdersTables')->name('success');
这是我保存订单的方法
protected function addToOrdersTables($request, $error)
{
$order = Order::create([
'user_id' => auth()->user() ? auth()->user()->id : null,
'billing_email' => $request->email,
'billing_first_name' => $request->first_name,
'billing_last_name' => $request->last_name,
'billing_address' => $request->address,
'billing_city' => $request->city,
'billing_town' => $request->town,
'billing_postalcode' => $request->postalcode,
'billing_phone' => $request->phone,
'billing_total' => Cart::getTotal(),
'error' => $error,
]);
foreach (Cart::getContent() as $item)
{
OrderProduct::create([
'order_id' => $order->id,
'product_id' => $item->model->id,
'quantity' => $item->quantity,
]);
}
}
感谢关心。
【问题讨论】:
-
请不要发送垃圾邮件标签,您使用的是 5 还是 7?
-
我正在使用 laravel-7-x
-
您需要在通话中使用
Request $request输入提示请求。我不知道$error是什么,但是您要么需要将它传入,从函数调用中取出并从$request获取它,要么弄清楚它应该来自哪里。 -
我还建议重命名路线。
success和$error在我看来很矛盾。它可能是result/{$status?},您的方法定义为(Request $request,$status)