function sendOrder($formData) { $formData['orderType'] = 'a'; $formData['cultureCode'] = $GLOBALS['bfi_lang']; $customer = RSFormHelper::getCustomerData($formData); $suggestedStay = json_decode(stripslashes($formData['staysuggested'])); $req = json_decode(stripslashes($formData['stayrequest']), true); // $suggestedStay = json_decode($_SESSION['search.params']['suggestedstay']); // $req = array('resourceId' => $_SESSION['search.params']['resourceId'], 'checkin' => $formData['checkin']['date'], 'checkout' =>$formData['checkout']['date'] , 'duration' => $_SESSION['search.params']['duration'], 'paxages' => '['.implode(',', $_SESSION['search.params']['paxages']).']', 'extras' => $_SESSION['search.params']['extras'], 'packages' => $_SESSION['search.params']['packages'], 'pricetype' => $_SESSION['search.params']['pricetype'], 'rateplanId' => $_SESSION['search.params']['rateplanId'], 'state' => 'booking' , 'variationPlanId' => $_SESSION['search.params']['variationPlanId'], 'gotCalculator' => false); $redirect = $formData['Redirect']; $redirecterror = $formData['Redirecterror']; $isgateway = $formData['isgateway']; $otherData = "paxages:" . str_replace("]", "", str_replace("[", "", $req['paxages'])) . "|" . "checkin_eta_hour:" . $formData['checkin_eta_hour']; $ccdata = null; if (RSFormHelper::canAcquireCCData($formData)) { $ccdata = json_encode(RSFormHelper::getCCardData($formData)); $ccdata = BFCHelper::encrypt($ccdata); } $orderData = BFCHelper::prepareOrderData($formData, $customer, $suggestedStay, $otherData, $ccdata); $orderData['pricetype'] = $req['pricetype']; // $orderData['label'] = 'developerdemo'; $orderData['label'] = $formData['label']; $processOrder = null; /* if(!empty($isgateway) && ($isgateway =="true" ||$isgateway =="1")){ $processOrder=false; } */ $order = BFCHelper::setOrder($orderData['customerData'], $orderData['suggestedStay'], $orderData['creditCardData'], $orderData['otherNoteData'], $orderData['merchantId'], $orderData['orderType'], $orderData['userNotes'], $orderData['label'], $orderData['cultureCode'], $processOrder, $orderData['pricetype']); if (empty($order)) { $order = ""; $redirect = $redirecterror; } if (!empty($order)) { if (!empty($isgateway) && ($isgateway == "true" || $isgateway == "1")) { wp_redirect(get_site_url() . '/payment/?orderId=' . $order->OrderId); exit; } else { $numAdults = 0; $persons = explode("|", $suggestedStay->Paxes); foreach ($persons as $person) { $totper = explode(":", $person); $numAdults += (int) $totper[1]; } $startDate = DateTime::createFromFormat('Y-m-d', BFCHelper::parseJsonDate($order->StartDate, 'Y-m-d')); $endDate = DateTime::createFromFormat('Y-m-d', BFCHelper::parseJsonDate($order->EndDate, 'Y-m-d')); $redirect = $redirect . '?act=Order&orderid=' . $order->OrderId . '&merchantid=' . $order->MerchantId . '&OrderType=' . $order->OrderType . '&OrderTypeId=' . $order->OrderTypeId . '&totalamount=' . $order->TotalAmount * 100 . '&startDate=' . $startDate->format('Y-m-d') . '&endDate=' . $endDate->format('Y-m-d') . '&numAdults=' . $numAdults; wp_redirect($redirect); exit; } } }
function sendScalarRequest() { $formData = $_POST['form']; $customer = RSFormHelper::getCustomerData($formData); $redirect = $formData['Redirect']; // create otherData (string) $otherData = "adulti:" . RSFormHelper::getOptionsFromSelect($formData, 'TotPersons') . "|" . "bambini:" . RSFormHelper::getOptionsFromSelect($formData, 'Totchildrens') . "|" . "etabambini:" . $formData['ChildrenAge'] . "|" . "tipologiastruttura:" . RSFormHelper::getOptionsFromSelect($formData, 'merchantcategory') . "|" . "trattamento:" . RSFormHelper::getOptionsFromSelect($formData, 'treatments') . "|" . "maxrisposte:" . RSFormHelper::getOptionsFromSelect($formData, 'Maxresponse') . "|" . "accettazione:" . RSFormHelper::getOptionsFromSelect($formData, 'accettazione'); $suggestedStay = null; // create SuggestedStay if ($formData['CheckIn'] != null && $formData['CheckOut'] != null) { $sStay = array('CheckIn' => DateTime::createFromFormat('d/m/Y', $formData['CheckIn'])->format('Y-m-d\\TH:i:sO'), 'CheckOut' => DateTime::createFromFormat('d/m/Y', $formData['CheckOut'])->format('Y-m-d\\TH:i:sO')); $suggestedStay = new stdClass(); foreach ($sStay as $key => $value) { $suggestedStay->{$key} = $value; } $otherData .= "|" . "CheckIn:" . DateTime::createFromFormat('d/m/Y', $formData['CheckIn'])->format('Y-m-d') . "|" . "CheckOut:" . DateTime::createFromFormat('d/m/Y', $formData['CheckOut'])->format('Y-m-d'); } $orderData = BFCHelper::prepareOrderData($formData, $customer, $suggestedStay, $otherData, null); $orderData['processOrder'] = true; $orderData['label'] = $this->formlabel; $order = BFCHelper::setOrder($orderData['customerData'], $orderData['suggestedStay'], $orderData['creditCardData'], $orderData['otherNoteData'], $orderData['merchantId'], $orderData['orderType'], $orderData['userNotes'], $orderData['label'], $orderData['cultureCode']); /*if (isset($order)) $thankYouMessage = "Grazie"; else $thankYouMessage = "Errore invio dati";*/ if (empty($order)) { $order = ""; } echo json_encode($order); $app = JFactory::getApplication(); $app->redirect($redirect, false); $app->close(); }