I have a Laravel 5 application where the user buys stuff and goes to checkout form to confirm his purchases.
This is how the user reaches the checkout form:
//This function takes values from form on welcome page or user dashboard page, does validation and redirects to checkout page to confirm by user
public function buyingPost(Request $request) {
$validator = [
***
];
$inputs = $request->all();
$validator = Validator::make($inputs, $validator);
if($validator->fails()){
$this->sendAdminEmail('Backend form validation failed.');
return Response::json([
'error' => true,
'message' => $validator->messages(),
'code' => 400
], 400);
}
}
else {
return view('pages.checkout', compact('inputs'));
}
}
The checkout form redirects to /order
route:
<form action="/order" method="post">
This route leads to this controller:
//the checkout form posts form to this function.
//This functions posts the values to the payment gateway
public function postOrder(Request $request) {
.
.
.
return redirect()->away($paymentGatewayURL);
However, if the user tries to go from the checkout form to the payment gateway 5 to 6 times in a row, he faces this error:
Bad Gateway The proxy server received an invalid response from an upstream server.
The problem is that when this error happens the payment gateway URL that is supposed to go from the server to the payment gateway appears raw in front of the user.
The error only goes away when browser cache is cleared. Thus, I tried to add these commands with no luck:
Artisan::call('cache:clear');
Cache::flush()
How can I solve this error or just catch it as it happens outside my app (happens when the user leaves to the third party payment gateway).
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire