问题描述
嗨,我正在使用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,]);
}
}
感谢关注。
解决方法
您还必须通过路由传递参数:
Route::get('/success/{error}','RaveController@addToOrdersTables')->name('success');
在addToOrdersTables
方法中,使用Request
提示请求,如下所示:
protected function addToOrdersTables(Request $request,$error)