hi guys i’m trying to redirect user to bank but laravel is ignoring my return redirect
in here
JavaScript
x
public function checkout()
{
$order = $this->makeOrder();
$this->makePayment($order);
$pal = resolve(zarinpal::class);
$pal -> pay($order);
$this->basket->clear();
return $order;
}
i’m calling pay() in zarinpal class :
JavaScript
public function pay(Order $order)
{
$this->redirectToBank($order);
}
private function redirectToBank($order)
{
$zarinpal = zarinpal()
->amount($order->amount_rial)
->request()
->callback('http://lanjani/payment/zarinpal/callback')
->description($order->code)
->mobile($order->phone_number)
->send();
if (!$zarinpal->success()){
return $zarinpal->error()->message();
}
$authority=$zarinpal->authority();
$input = [
'authority' => $authority
];
$orderItem = Order::find($order->id);
$orderItem -> update($input);
return redirect()->away('https://sandbox.zarinpal.com/pg/StartPay/'.$authority);
}
at the end of redirectToBank() user must redirect to bank but it is ignoring redirect and is returning $order in cheackout()
Advertisement
Answer
I think that the redirect returns a redirect object. And this object needs to be returned from the method on the route. So you would return
JavaScript
$pal -> pay($order);
from the checkout method and
JavaScript
$this->redirectToBank($order);
from the pay method. This obviously does not really have the effect you want. So you will need to return the redirect url form the redirectToBank
method and then clear the basket and then in the checkout method redirect away.