0
votes

I have integrated the Razorpay payment gateway in my laravel project. It works well on desktop but does not work on mobile .

Here is my code

public function pay(Request $request)
    {
        //Input items of form
        $input = $request->all();
        //get API Configuration 
        $api = new Api(ENV('RZP_KEY_ID'), ENV('RZP_KEY_SECRET'));
        //Fetch payment information by razorpay_payment_id
        $payment = $api->payment->fetch($input['razorpay_payment_id']);
 
        if(count($input)  && !empty($input['razorpay_payment_id'])) {
            try {
                $paymentDetails = $api->payment->fetch($input['razorpay_payment_id'])->capture(array('amount'=>$payment['amount'])); 
 
            } catch (\Exception $e) {
                //delete params from session                
                if(Session::has('amount')){
                    Session::pull('amount');
                    Session::pull('converted_amount');
                    Session::pull('currency');
                    Session::pull('charge');
                
                }
                return redirect(route('user.deposit.index'))->with('fail', 'Your Deposit request failed');
            }
            
            //record payment
             //somwe codes for validating and recording payment removed
            
            
        }         
              
    }

When i try to make payment using a mobile device, after inputing the credit card details, Instead of a popup windown that appears on desktop, I get redirected to https://api.razorpay.com/v1/payments/create/checkout to enter otp and confirm the payment.

AFter a Payment, it will redirect back to my site, here are the problems;

  1. All sessions would be deleted and I would need to login again,
  2. The redirect is a post request but if I relogin, it becomes a get request

How can i solve this problem