Send Enquiry
Youtube
img

i homecontroller replace this file
1. send_otp_for_dealer_payment
public function send_otp_for_dealer_payment(Request $request)
   {
       $request->session()->forget('otp');
       $dealer = Dealer::where('dealer_code',$request->dealer_code)->with('ParentDealerData')->first();
       if ($dealer != '') {
           // if($dealer->payment_from == 'deposit'){
           //     if(!is_null($dealer->ParentDealerData)) {
           //         $getDealerCreditDebitData = DealerCreditDebit::where('dealer_id',$dealer->ParentDealerData->id)->whereNotNull('current_balance')->latest()->first();
           //     } else {
           //         $getDealerCreditDebitData = DealerCreditDebit::where('dealer_id',$dealer->id)->whereNotNull('current_balance')->latest()->first();
           //     }

           //     if(is_null($getDealerCreditDebitData)){
           //         return "balance";
           //         //return back()->with('error','You have not enough balance to buy this product.');
           //     }

           //     $margin_amount          = round(Session::get('sub_total') * $dealer->eo_margin_percentage / 100);
           //     $parent_margin_amount   = round(Session::get('sub_total') * $dealer->ParentDealerData->eo_margin_percentage / 100);

           //     $taxable_amount         = round(Session::get('sub_total') - $parent_margin_amount);
           //     $gst_amount             = round($taxable_amount *  18 / 100);
           //     $dealer_debit_amount    = round($taxable_amount + $gst_amount);

           //     $dealer_last_balance    = $getDealerCreditDebitData->current_balance;
           //     if($dealer_debit_amount > $getDealerCreditDebitData->current_balance){
           //         return "balance";
           //         //return back()->with('error','You have not enough balance to buy this product.');
           //     }
           // }

           // Generate an OTP
           $otp = generateNumericOTP($this->otpLength);
           // Store the OTP in the session
           $request->session()->put('otp',$otp);
           $request->session()->put('user_type','dealer');
           $request->session()->put('email',$dealer->email);
           $email = $dealer->email;

           //add in otp table
           $insertOtpData['event'] = 'PUR';
           $insertOtpData['otp'] = $otp;
           $insertOtpData['year'] = date('Y');
           $insertOtpData['validity'] = $this->otpValidity;
           $insertOtpData['valid_till'] = date('Y-m-d H:i:s',strtotime("+" . $this->otpValidity . " minutes",strtotime(date('y-m-d H:i:s'))));

           $insertedOtp = $this->Otp->create($insertOtpData);

           try {
               //send mail
               if ($this->settingsData->send_dealer_email == 1) {
                   $emailData = array();
                   $emailData['clientName'] = $name = $dealer->name;
                   $emailData['event'] = 'for New Purchase';
                   $emailData['otp'] = str_split($otp);
                   $emailData['validity'] = 10;

                   if ($this->settingsData->send_email_to_party_or_mailbox == 'mailbox')
                       $email = $this->settingsData->mailbox_email_id;

                   Mail::send('mail.otp-mail',$emailData,function ($message) use ($email,$name) {
                       $message->to($email,$name)
                           ->subject('OTP - New Purchase!')
                           ->from($this->fromAddress,$this->fromName);
                   });
               }
           } catch (\Exception $e) {
               \Log::error($e);
           }
           //return "sent";
           return response()->json([
               'status' => 'sent',
               'message' => 'OTP generated and sent'
           ]);

       } else {
           //return "error";
           return response()->json([
               'status' => 'error',
               'message' => 'OTP generated and sent'
           ]);
       }
   }


2. Verify_dealer_payment_otp

public function verify_dealer_payment_otp(Request $request)
   {
       if ($request->otp == $request->session()->get('otp')) {
           $deleted = $this->Otp->where('otp',$request->otp)->delete();
           //return "verifyed";
           return response()->json([
               'status' => 'verified',
               'message' => 'OTP verified successfully!'
           ]);
       } else {
           //return "not";
           return response()->json([
               'status' => 'not',
               'message' => 'OTP verified successfully!'
           ]);
       }
   }
 

Get a EASYOFFICE Income Tax | TDS | Audit | CMA | GST

A Special Initiative for Practicing CA's
Truested by 10,000+ CA and Tax Professionals

Related Blogs






Our Products
Latest Blogs