Laravel redirect() method not working with Android google chrome

846 Views Asked by At

I am a backend developer having redirection issue with Android google chrome.

The website i developed is integrated with a payment gateway.

The process for payment is as follow:-

1- Payment order created on website DB.

2- API request sent to payment gateway for creating a payment request.

3- API gateway response with providing a payment URL.

4- User been redirected to that payment URL.

5- Once user successfully paid and payment status get captured, the payment gateway website redirect user back to my website through the following link:-

http://mywebsite.com/payment/callback?cancelled=0&hash=5e02f05b78766&order_id=277&tx_date=31-December-2019%2008:16:03&tx_amt=4.1000&Result=CAPTURED&PaymentID=106201936565342280&PostDate=1231&TranID=201936565319193&Auth=259819&Ref=936533003451&tx_id=386306&tx_mode=KNET&tx_status=

6- In backend code Controller that process the route (/payment/callback) i have the following php code:-

public function callback(Request $request)
    {


        // Check if cancelled value = 1 (user cancelled) OR cancelled in knet payment page
        if ($request->cancelled OR (!$request->cancelled && $request->Result == 'CANCELED') OR $request->Result != 'CAPTURED')
        {
            //Here to return to view if the payment is cancelled in gateway payment page
            echo 'the request cancelled';


            return redirect()->route('payment_status')->with($request->all());


        }


        //Query order
        $order = Order::where('payment_ref',$request->hash)->first();
        \Auth::login($order->user);
        if ($order == null) {
            return 'Could Not Find Order, Please Contact IT Support';


        }


        if (!$request->cancelled  && $request->Result = 'CAPTURED')
        {
            if ($order->status === 'closed'){
               die('This Page Has Been Expired');
            }


            $order->status = 'closed';
            $order->save();
           return redirect()->route('payment_status')->with($request->all());
}

The issue is when user using a google chrome (Android version) is show him a message :-

This Page Has Been Expired

While it suppose to show him the transaction details, as been made from the following code (other browsing is working fine):-

return redirect()->route('payment_status')->with($request->all());

I tried with the following google chrome mobile phone (Samsung Note 9 and OnePlus 3T).

*The php framework used (Laravel).

Please advice.

1

There are 1 best solutions below

1
On

I believe the first problem is:

if (!$request->cancelled  && $request->Result = 'CAPTURED')

you assign here CAPTURED to result and it should be probably

if (!$request->cancelled  && $request->Result == 'CAPTURED')