Paytm gateway laravel error

Posted in CategoryLaravel
  • Z
    Zubair nazer 3 months ago

    i have done paytm integration with my website using "anandsidharth paytm package". here is my controller:

     

    class OrdersController extends Controller
    {
    
    
        /**
         * Redirect the user to the Payment Gateway.
         *
         * @return Response
         */
        public function register()
        {
            return view('payment');
        }
    
    
        /**
         * Redirect the user to the Payment Gateway.
         *
         * @return Response
         */
        public function order(Request $request)
        {
    
            // 
            // $this->validate($request, [
            //     'name' => 'required',
            //     'mobile_no' => 
    
        'required|numeric|digits:10|unique:event_registration,mobile_no',
                //     'email' => 'required',
                // ]);
    
    
                $input = $request->all();
                $input['order_id'] = $request->mobile_no.rand(1,100);
                $input['fee'] = 50;
    
    
                EventRegistration::create($input);
    
    
                $payment = PaytmWallet::with('receive');
                $payment->prepare([
                  'order' => $input['order_id'],
                  'user' => 'your paytm user',
                  'mobile_number' => 'your paytm number',
                  'email' => 'your paytm email',
                  'amount' => $input['fee'],
                  'callback_url' => url('api/payment/status')
                ]);
                return $payment->receive();
            }
    
    
            /**
             * Obtain the payment information.
             *
             * @return Object
             */
            public function paymentCallback()
            {
                $transaction = PaytmWallet::with('receive');
    
    
                $response = $transaction->response();
                $order_id = $transaction->getOrderId();
    
    
                if($transaction->isSuccessful()){
                  EventRegistration::where('order_id',$order_id)->update(['status'=>2, 'transaction_id'=>$transaction->getTransactionId()]);
    
    
                  dd('Payment Successfully Paid.');
                }else if($transaction->isFailed()){
                  EventRegistration::where('order_id',$order_id)->update(['status'=>1, 'transaction_id'=>$transaction->getTransactionId()]);
                  dd('Payment Failed.');
                }
            }
        }


    here is my routes:

    Route::get('event-registration', 'OrdersController@register');
    Route::post('payment', 'OrdersController@order');
    Route::post

Please login or register to leave a response.

* You May Also Like Bellow Issue to check *