Esempio n. 1
0
 /**
  * Handle the request to generate Mobile PayU hash code.
  * 
  * @access	public
  * @param	array	 
  * @return	json
  * @since	1.0.0
  */
 public function getMobileHash()
 {
     //reading data input by the user
     $data = $this->request->all();
     //validating user data
     $validator = Validator::make($data, Payment::$arrRules);
     if ($validator->fails()) {
         $message = $validator->messages();
         $errorMessage = "";
         foreach ($data as $key => $value) {
             if ($message->has($key)) {
                 $errorMessage .= $message->first($key) . '\\n ';
             }
         }
         $arrResponse['status'] = Config::get('constants.API_ERROR');
         $arrResponse['error'] = $errorMessage;
     } else {
         $code = Payment::getHashes($data);
         $arrResponse['status'] = Config::get('constants.API_SUCCESS');
         $arrResponse['data'] = $code;
     }
     return response()->json($arrResponse, 200);
 }
Esempio n. 2
0
 /**
  * Writes the details of the reservation in the DB.
  * 
  * @static	true
  * @access	public
  * @param	array 	$arrData
  * @return	boolean
  * @since	1.0.0
  */
 public static function addReservationDetails($arrData, $userID, $objMailChimp, $userType = 'website_user')
 {
     //creating a new instance of the table
     $reservation = new ReservationDetails();
     $date = date_create($arrData['reservationTime']);
     $arrData['reservationTime'] = date_format($date, "h:i A");
     //initializing the data
     $reservation->reservation_status = 'new';
     $reservation->reservation_date = $arrData['reservationDate'];
     $reservation->reservation_time = $arrData['reservationTime'];
     $reservation->no_of_persons = $arrData['partySize'];
     $reservation->guest_name = $arrData['guestName'];
     $reservation->guest_email = $arrData['guestEmail'];
     $reservation->guest_phone = $arrData['phone'];
     $reservation->reservation_type = $arrData['reservationType'];
     $reservation->order_amount = 0;
     $reservation->user_id = $userID;
     $reservation->added_by = $userType;
     //setting up the variables that may be present
     if (isset($arrData['specialRequest'])) {
         $reservation->special_request = $arrData['specialRequest'];
     }
     if (isset($arrData['giftCardID'])) {
         $reservation->giftcard_id = $arrData['giftCardID'];
     }
     //get the user city for mailchimp
     if (isset($reservation->user_id)) {
         $city_name = self::getLocationOfUser($reservation->user_id);
     }
     //setting up the value of the location id as per type
     if ($arrData['reservationType'] == 'alacarte') {
         //reading the resturants detail
         $aLaCarteDetail = self::readVendorDetailByLocationID($arrData['vendorLocationID']);
         $reservation->points_awarded = $aLaCarteDetail['reward_point'];
         $reservation->vendor_location_id = $arrData['vendorLocationID'];
         $reservation->product_vendor_location_id = 0;
     } else {
         if ($arrData['reservationType'] == 'experience') {
             //reading the product detail
             $productDetail = self::readProductDetailByProductVendorLocationID($arrData['vendorLocationID']);
             $arrResult = self::readProductIdAndVendorLocation($arrData['vendorLocationID']);
             //print_r($arrResult);die;
             $reservation->points_awarded = $productDetail['reward_point'];
             $reservation->vendor_location_id = $arrResult->vendor_location_id;
             $reservation->product_id = $arrResult->product_id;
             $reservation->product_vendor_location_id = $arrData['vendorLocationID'];
         }
     }
     #saving the information into the DB
     $savedData = $reservation->save();
     if ($savedData) {
         $reservation_id = ReservationDetails::where('user_id', '=', $userID)->where('reservation_date', '=', $arrData['reservationDate'])->where('reservation_time', '=', $arrData['reservationTime'])->where('reservation_status', '!=', 'cancel')->select('id')->first();
         //Reading user detail to get membership number(GIU_Membership_ID)
         $token = $_SERVER['HTTP_X_WOW_TOKEN'];
         $userDetail = Profile::getUserProfile($token);
         if ($arrData['reservationType'] == 'alacarte') {
             $arrResponse['status'] = Config::get('constants.API_SUCCESS');
             $arrResponse['data']['reservation_id'] = $reservation_id['id'];
             $arrResponse['data']['name'] = $aLaCarteDetail['name'];
             $arrResponse['data']['url'] = URL::to('/') . '/alacarte/' . $aLaCarteDetail['vl_id'];
             $arrResponse['data']['reservationDate'] = $arrData['reservationDate'];
             $arrResponse['data']['reservationTime'] = $arrData['reservationTime'];
             $arrResponse['data']['partySize'] = $arrData['partySize'];
             $arrResponse['data']['reward_point'] = $aLaCarteDetail['reward_point'];
             //Increment the Reservation count by 1
             $reservationCount = self::incrementReservationCount($userID, $arrData['reservationType']);
             //Increment reward point in user table
             DB::table('users')->where('id', $userID)->increment('points_earned', $aLaCarteDetail['reward_point']);
             //Insert record for new reward point
             $storeRewardPoint = self::storeRewardPoint($userID, $aLaCarteDetail['reward_point'], $reservation_id['id']);
             //Reading offers detail
             $offersResult = self::getSpecialOfferDetail($arrData['vendorLocationID']);
             //for the new db structure support
             $combined_date_and_time = $arrData['reservationDate'] . ' ' . $arrData['reservationTime'];
             $newDb['attributes']['reserv_datetime'] = Carbon::createFromFormat('Y-m-d H:i A', $combined_date_and_time)->toDateTimeString();
             $newDb['attributes']['no_of_people_booked'] = $arrData['partySize'];
             $newDb['attributes']['cust_name'] = $arrData['guestName'];
             $newDb['attributes']['email'] = $arrData['guestEmail'];
             $newDb['attributes']['contact_no'] = $arrData['phone'];
             $newDb['attributes']['reserv_type'] = "Alacarte";
             //$newDb['attributes']['gift_card_id_reserv'] = $dataPost['giftCardID'];
             $newDb['attributes']['loyalty_points_awarded'] = $aLaCarteDetail['reward_point'];
             $newDb['attributes']['special_request'] = isset($arrData['specialRequest']) && !empty($arrData['specialRequest']) ? $arrData['specialRequest'] : "";
             $newDb['attributes']['experience'] = $aLaCarteDetail['name'] . ' - Ala Carte';
             $newDb['attributes']['api_added'] = "Mobile";
             $newDb['attributes']['giu_membership_id'] = $userDetail['data']['membership_number'];
             $newDb['attributes']['outlet'] = $aLaCarteDetail['location'];
             $newDb['attributes']['auto_reservation'] = "Not available";
             $newDb['attributes']['ar_confirmation_id'] = "0";
             $newDb['attributes']['alternate_id'] = 'A' . sprintf("%06d", $reservation_id['id']);
             $newDb['attributes']['reservation_status_id'] = 1;
             $newDb['userdetails']['user_id'] = $userID;
             $newDb['userdetails']['status'] = 1;
             //print_r($newDb);die;
             $reservDetails = new ReservationModel();
             $newDbStatus = $reservDetails->updateAttributes($reservation_id['id'], $newDb);
             //print_r($newDbStatus);die;
             /*TODO: Add the status of success check and include added_by and transaction_id attributes */
             //echo "alacarte success";die;
             //Mail by mailchimp
             $mailStatus = self::mailByMailChimp($arrData, $userID, $objMailChimp, $city_name);
             $zoho_data = array('Name' => $arrData['guestName'], 'Email_ids' => $arrData['guestEmail'], 'Contact' => $arrData['phone'], 'Experience_Title' => $aLaCarteDetail['name'] . ' - Ala Carte', 'No_of_People' => $arrData['partySize'], 'Date_of_Visit' => date('d-M-Y', strtotime($arrData['reservationDate'])), 'Time' => date("g:ia", strtotime($arrData['reservationTime'])), 'Alternate_ID' => 'A' . sprintf("%06d", $reservation_id['id']), 'Special_Request' => isset($arrData['specialRequest']) && !empty($arrData['specialRequest']) ? $arrData['specialRequest'] : "", 'Type' => "Alacarte", 'API_added' => 'Mobile', 'GIU_Membership_ID' => $userDetail['data']['membership_number'], 'Outlet' => $aLaCarteDetail['location'], 'AR_Confirmation_ID' => '0', 'Auto_Reservation' => 'Not available', 'Special_offer_title' => $offersResult['special_offer_title'], 'Special_offer_desc' => $offersResult['special_offer_desc'], 'Calling_option' => 'No');
             //Calling zoho api method
             $zoho_res = Self::zohoAddBooking($zoho_data);
             //Call zoho send mail method
             Self::zohoSendMail($zoho_res, $zoho_data, $reservation_id['id'], $arrData);
         } else {
             if ($arrData['reservationType'] == 'experience') {
                 $arrResponse['status'] = Config::get('constants.API_SUCCESS');
                 if (array_key_exists('addon', $arrData) && !empty($arrData['addon'])) {
                     //self::addReservationAddonDetails($reservation->id, $arrData['addon']);
                     //Reading value for addon
                     $count = $arrData['addon'];
                     if ($count == "") {
                         $arrData['addon'] = array();
                     }
                     // echo "<pre>"; print_r($dataPost);
                     $addonsText = '';
                     foreach ($arrData['addon'] as $key => $value) {
                         if ($value['qty'] > 0) {
                             //echo "prod id = ".$prod_id." , qty = ".$qty;
                             $prod_id = $value['prod_id'];
                             $addonsDetails = DB::select("SELECT attribute_value from product_attributes_text where product_id = {$prod_id} and product_attribute_id = 17");
                             //echo "<pre>"; print_r($addonsDetails);
                             $addonsText .= $addonsDetails[0]->attribute_value . " (" . $value['qty'] . ") , ";
                         }
                     }
                     /*
                     			        foreach($arrData['addon'] as $prod_id => $qty) {
                     			            if($qty > 0){
                     			                //echo "prod id = ".$prod_id." , qty = ".$qty;
                     			                $addonsDetails = DB::select("SELECT attribute_value from product_attributes_text where product_id = $prod_id and product_attribute_id = 17");
                     
                     			                //echo "<pre>"; print_r($addonsDetails);
                     			                $addonsText .= $addonsDetails[0]->attribute_value." (".$qty.") , ";
                     			            }
                     
                     }
                     */
                     $finalAddontext = isset($addonsText) && $addonsText != "" ? "Addons: " . $addonsText : " ";
                     $special_request = isset($arrData['specialRequest']) && !empty($arrData['specialRequest']) ? "Spl Req: " . $arrData['specialRequest'] : "";
                     $arrData['addons_special_request'] = $finalAddontext . " " . $special_request;
                     //---------------------------------------------------------------------------
                 } else {
                     $finalAddontext = " ";
                     $special_request = isset($arrData['specialRequest']) && !empty($arrData['specialRequest']) ? "Spl Req: " . $arrData['specialRequest'] : "";
                     $arrData['addons_special_request'] = $finalAddontext . " " . $special_request;
                 }
                 $arrResponse['data']['reservation_id'] = $reservation_id['id'];
                 $arrResponse['data']['name'] = $productDetail['name'];
                 $arrResponse['data']['url'] = URL::to('/') . '/experience/' . $productDetail['id'];
                 $arrResponse['data']['reservationDate'] = $arrData['reservationDate'];
                 $arrResponse['data']['reservationTime'] = $arrData['reservationTime'];
                 $arrResponse['data']['partySize'] = $arrData['partySize'];
                 $arrResponse['data']['reward_point'] = $productDetail['reward_point'];
                 //Increment the Reservation count by 1
                 $reservationCount = self::incrementReservationCount($userID, $arrData['reservationType']);
                 //Insert reward point in user table
                 DB::table('users')->where('id', $userID)->increment('points_earned', $productDetail['reward_point']);
                 //Insert record for new reward point
                 $storeRewardPoint = self::storeRewardPoint($userID, $productDetail['reward_point'], $reservation_id['id']);
                 $arrData['giftCardID'] = isset($arrData['giftCardID']) && !empty($arrData['giftCardID']) ? $arrData['giftCardID'] : "";
                 //for the new db structure support
                 $combined_date_and_time = $arrData['reservationDate'] . ' ' . $arrData['reservationTime'];
                 $newDb['attributes']['reserv_datetime'] = Carbon::createFromFormat('Y-m-d H:i A', $combined_date_and_time)->toDateTimeString();
                 $newDb['attributes']['no_of_people_booked'] = $arrData['partySize'];
                 $newDb['attributes']['cust_name'] = $arrData['guestName'];
                 $newDb['attributes']['email'] = $arrData['guestEmail'];
                 $newDb['attributes']['contact_no'] = $arrData['phone'];
                 $newDb['attributes']['reserv_type'] = "Experience";
                 $newDb['attributes']['gift_card_id_reserv'] = $arrData['giftCardID'];
                 $newDb['attributes']['loyalty_points_awarded'] = $productDetail['reward_point'];
                 $newDb['attributes']['special_request'] = $arrData['addons_special_request'];
                 $newDb['attributes']['experience'] = $productDetail['vendor_name'] . ' - ' . $productDetail['descriptive_title'];
                 $newDb['attributes']['api_added'] = "Mobile";
                 $newDb['attributes']['giu_membership_id'] = $userDetail['data']['membership_number'];
                 $newDb['attributes']['outlet'] = $productDetail['location'];
                 $newDb['attributes']['auto_reservation'] = "Not available";
                 $newDb['attributes']['ar_confirmation_id'] = "0";
                 $newDb['attributes']['alternate_id'] = 'E' . sprintf("%06d", $reservation_id['id']);
                 $newDb['attributes']['reservation_status_id'] = 1;
                 $newDb['userdetails']['user_id'] = $userID;
                 $newDb['userdetails']['status'] = 1;
                 $newDb['userdetails']['addons'] = isset($arrData['addon']) ? $arrData['addon'] : "";
                 $newDb['userdetails']['mobile'] = 1;
                 //print_r($newDb);die;
                 $reservDetails = new ReservationModel();
                 $newDbStatus = $reservDetails->updateAttributes($reservation_id['id'], $newDb);
                 //print_r($newDbStatus);die;
                 /*TODO: Add the status of success check and include added_by and transaction_id attributes */
                 //echo "experience success";die;
                 //Mail by mailchimp
                 $mailStatus = self::mailByMailChimp($arrData, $userID, $objMailChimp, $city_name);
                 $zoho_data = array('Name' => $arrData['guestName'], 'Email_ids' => $arrData['guestEmail'], 'Contact' => $arrData['phone'], 'Experience_Title' => $productDetail['vendor_name'] . ' - ' . $productDetail['descriptive_title'], 'No_of_People' => $arrData['partySize'], 'Date_of_Visit' => date('d-M-Y', strtotime($arrData['reservationDate'])), 'Time' => date("g:ia", strtotime($arrData['reservationTime'])), 'Alternate_ID' => 'E' . sprintf("%06d", $reservation_id['id']), 'Special_Request' => $arrData['addons_special_request'], 'Type' => "Experience", 'API_added' => 'Mobile', 'GIU_Membership_ID' => $userDetail['data']['membership_number'], 'Outlet' => $productDetail['location'], 'AR_Confirmation_ID' => '0', 'Auto_Reservation' => 'Not available', 'Calling_option' => 'No', 'gift_card_id_from_reservation' => $arrData['giftCardID']);
                 //Calling zoho api method
                 $zoho_res = Self::zohoAddBooking($zoho_data);
                 //Call zoho send mail method
                 Self::zohoSendMail($zoho_res, $zoho_data, $reservation_id['id'], $arrData);
                 //code for generating the payu hash
                 if (self::isPaidExperience($arrResult->product_id)) {
                     //its a paid product so generating the hash
                     if (!array_key_exists('total_amount', $arrData)) {
                         $arrData['total_amount'] = 0;
                     }
                     $arrPayUData = array('guestName' => $arrData['guestName'], 'reservationID' => $reservation->id, 'amount' => $arrData['total_amount'], 'shortDescription' => $productDetail['descriptive_title'], 'email' => $arrData['guestEmail'], 'userCredentials' => $arrData['userCredentials']);
                     $arrHash = Payment::getPayUHash($arrPayUData);
                     //setting up the hash value
                     $arrResponse['data']['hash'] = array('paymentHash' => $arrHash['paymentHash'], 'paymentRelatedDetailsForMobileSDKHash' => array_key_exists('paymentRelatedDetailsForMobileSDKHash', $arrHash) ? $arrHash['paymentRelatedDetailsForMobileSDKHash'] : '', 'getUserCardsHash' => array_key_exists('getUserCardsHash', $arrHash) ? $arrHash['getUserCardsHash'] : '', 'saveUserCardHash' => array_key_exists('saveUserCardHash', $arrHash) ? $arrHash['saveUserCardHash'] : '');
                 }
             } else {
                 $arrResponse['status'] = Config::get('constants.API_ERROR');
             }
         }
         return $arrResponse;
     }
     return FALSE;
 }