コード例 #1
0
    function display($tpl = NULL, $preparecontent = false)
    {
        $document = JFactory::getDocument();
        $language = $document->getLanguage();
        // load scripts
        $document->addScript('components/com_bookingforconnector/assets/js/jquery.validate.min.js');
        $document->addScript('components/com_bookingforconnector/assets/js/additional-methods.min.js');
        // Initialise variables
        $trackorder = false;
        $state = $this->get('State');
        $actionmode = JRequest::getVar('actionmode', "");
        $item = $this->get('Item');
        $params =& $state->params;
        $this->assignRef('state', $state);
        $this->assignRef('params', $params);
        $this->assignRef('language', $language);
        $this->assignRef('item', $item);
        $this->assignRef('actionmode', $actionmode);
        if ($actionmode == "orderpayment") {
            //recupero quanti pagamenti sono stati effettuati
            $item->paymentCount = BFCHelper::getTotalOrderPayments($item->order->OrderId);
            $item->overrideAmount = JRequest::getFloat('overrideAmount');
            //sostituisco i dati dell'ordine da pagare con i dati passati e l'ordine con un suffisso in più
            /*$item = $this->get('Item');*/
            /*$item = "fet";*/
        }
        if ($actionmode == "orderpaid") {
            $trackorder = true;
        }
        if ($actionmode != '' && $actionmode != 'cancel' && $actionmode != 'donation' && $actionmode != 'orderpayment') {
            if ($item->order->Status != 5) {
                $hasPayed = $this->processPayment($actionmode, $item->order->OrderId);
                /* eccezione per setefi che pretende un url di ritorno */
            } else {
                //$hasPayed = true;
                $hasPayed = $this->processOrderPayment($actionmode, $item->order->OrderId, $language);
            }
            /*
            $link = '';
            if ($hasPayed){
             	
            }
            $app = JFactory::getApplication();
            $app->redirect($link, $msg);
            */
        }
        if ($actionmode == '' && $actionmode != 'donation') {
            if ($item->order->Status != 5) {
                $this->inizializePayment($item->order->OrderId);
            }
        }
        if ($actionmode == 'orderpaid') {
            $hasPayed = $item->order->Status == 5;
        }
        if (isset($trackorder) && $trackorder) {
            $merchants = array();
            $merchants[] = $item->order->MerchantId;
            $criteoConfig = BFCHelper::getCriteoConfiguration(4, $merchants, $item->order->OrderId);
            if (isset($criteoConfig) && isset($criteoConfig->enabled) && $criteoConfig->enabled && count($criteoConfig->merchants) > 0) {
                $document->addScript('//static.criteo.net/js/ld/ld.js');
                $document->addScriptDeclaration('window.criteo_q = window.criteo_q || []; 
				window.criteo_q.push( 
					{ event: "setAccount", account: ' . $criteoConfig->campaignid . '}, 
					{ event: "setSiteType", type: "d" }, 
					{ event: "setEmail", email: "" }, 
					{ event: "trackTransaction", id: "' . $criteoConfig->transactionid . '",  item: [' . json_encode($criteoConfig->orderdetails) . '] }
				);');
            }
            $analyticsEnabled = $this->checkAnalytics("Sales Resource List");
            if ($analyticsEnabled && $config->get('eecenabled', 0) == 1) {
                $purchaseObject = new stdClass();
                $purchaseObject->id = "" . $item->order->OrderId;
                $purchaseObject->affiliation = "" . $item->order->Label;
                $purchaseObject->revenue = "" . $item->order->TotalAmount;
                $purchaseObject->tax = 0.0;
                $allobjects = array();
                $svcTotal = 0;
                $allservices = array_values(array_filter(simpledom_load_string($order->NotesData)->xpath("//price"), function ($prc) {
                    return (string) $prc->tag == "extrarequested";
                }));
                foreach ($allservices as $svc) {
                    $svcObj = new stdClass();
                    $svcObj->id = "" . (int) $svc->priceId . " - Service";
                    $svcObj->name = (string) $svc->name;
                    $svcObj->category = "Services";
                    $svcObj->brand = $item->Name;
                    $svcObj->variant = (string) BFCHelper::getItem($order->NotesData, 'nome', 'unita');
                    $svcObj->price = round((double) $svc->discountedamount / (int) $svc->quantity, 2);
                    $svcObj->quantity = (int) $svc->quantity;
                    $allobjects[] = $svcObj;
                    $svcTotal += (double) $svc->discountedamount;
                }
                $mainObj = new stdClass();
                $mainObj->id = "" . $item->order->RequestedItemId . " - Resource";
                $mainObj->name = (string) BFCHelper::getItem($order->NotesData, 'nome', 'unita');
                $mainObj->variant = (string) BFCHelper::getItem($order->NotesData, 'refid', 'rateplan');
                $mainObj->category = $item->MainCategoryName;
                $mainObj->brand = $item->Name;
                $mainObj->price = $item->order->TotalAmount - $svcTotal;
                $mainObj->quantity = 1;
                $allobjects[] = $mainObj;
                $document->addScriptDeclaration('callAnalyticsEEc("addProduct", ' . json_encode($allobjects) . ', "purchase", "", ' . json_encode($purchaseObject) . ');');
            }
        }
        // assegno il riferimento dopo gli altri altrimenti non ho nessuna associazione
        $this->assignRef('hasPayed', $hasPayed);
        /*
        		$items		= $this->get('Items');
        		$pagination	= $this->get('Pagination');
        		$sortColumn 	= $state->get('list.ordering');
        		$sortDirection 	= $state->get('list.direction');
        
        // Check for errors.
        		if (count($errors = $this->get('Errors'))) {
        			JError::raiseWarning(500, implode("\n", $errors));
        			return false;
        		}
        $pagination->setAdditionalUrlParam("filter_order", $ordering);
        		$pagination->setAdditionalUrlParam("filter_order_Dir", $direction);
        
        
        $this->assignRef('items', $items);
        		$this->assignRef('pagination', $pagination);
        */
        // Display the view
        parent::display($tpl);
    }
コード例 #2
0
ファイル: bfi.php プロジェクト: Bookingfor/wordpress-plugin
function bfi_payment()
{
    $hasPayed = null;
    $orderId = isset($_REQUEST['orderId']) ? $_REQUEST['orderId'] : $_REQUEST['payedOrderId'];
    $actionmode = isset($_REQUEST['actionmode']) ? $_REQUEST['actionmode'] : '';
    $paymentModel = new BookingForConnectorModelPayment();
    $item = $paymentModel->getItem($orderId);
    $order = $item->order;
    $merchantPayments = $item->merchantPayments;
    $merchantPayment = $item->merchantPayment;
    $data = explode('|', $merchantPayment->Data);
    if ($actionmode == "orderpaid") {
        $base_url = get_site_url();
        $merchant_id = $order->MerchantId;
        $modelmerchant = new BookingForConnectorModelMerchantDetails();
        $merchant = $modelmerchant->getItem($merchant_id);
        $result = isset($_REQUEST['result']) ? $_REQUEST['result'] : '';
        if ($result == "true") {
        }
        $redirecturl = $base_url . '/thanks/orderpaid/merchant-details/merchantdetails/' . $merchant->MerchantId . '-' . seoUrl($merchant->Name);
        wp_redirect($redirecturl);
        exit;
    }
    if ($actionmode == "orderpayment") {
        $item->paymentCount = BFCHelper::getTotalOrderPayments($item->order->OrderId);
    }
    if ($actionmode != '' && $actionmode != 'cancel' && $actionmode != 'donation' && $actionmode != 'orderpayment') {
        if ($item->order->Status != 5) {
            $hasPayed = processPayment($actionmode, $order, $data, $merchantPayment->SandboxMode);
        } else {
            $hasPayed = processOrderPayment($actionmode, $item->order, $language, $data);
        }
    }
    if ($actionmode == '' && $actionmode != 'donation') {
        if ($item->order->Status != 5) {
            $order = BFCHelper::setOrderStatus($orderId, 1, false, false, '');
        }
    }
    if ($actionmode == "cancel") {
        $base_url = get_site_url();
        $merchant_id = $order->MerchantId;
        $modelmerchant = new BookingForConnectorModelMerchantDetails();
        $merchant = $modelmerchant->getItem($merchant_id);
        $redirecturl = $base_url . '/cancel/orderpaid/merchant-details/merchantdetails/' . $merchant->MerchantId . '-' . seoUrl($merchant->Name);
        wp_redirect($redirecturl);
        exit;
    }
    if (isset($item->merchantPayment)) {
        $merchantPayment = $item->merchantPayment;
        $paymentSystemId = $merchantPayment->PaymentSystemId;
        $paymentSystemRef = $merchantPayment->PaymentSystemName;
        if ($actionmode == 'donation') {
        } else {
            if ($hasPayed !== null) {
                if ($hasPayed) {
                    echo '<p class="success">' . __('Payment successful', 'bfi') . '</p>';
                } else {
                    echo '<p class="error">' . __('Payment failed', 'bfi') . '</p>';
                }
            } else {
                if ($actionmode == 'cancel') {
                    echo '<p class="error">' . __('Payment failed and has been cancelled', 'bfi') . '</p>';
                }
                if ($actionmode == 'error' || $actionmode == 'errordonation') {
                    echo '<p class="error">' . __('Payment failed and has been cancelled', 'bfi') . '</p></br>';
                }
                if ($actionmode != 'errordonation' && $order != null && $paymentSystemRef != null) {
                    if ($actionmode != 'error') {
                        $output = call_user_func('payment_' . $paymentSystemRef, $order, $merchantPayment, $actionmode);
                    }
                }
            }
        }
    }
    return $output;
}
コード例 #3
0
 function display($tpl = NULL, $preparecontent = false)
 {
     $document = JFactory::getDocument();
     $language = $document->getLanguage();
     // load scripts
     $document->addScript('components/com_bookingforconnector/assets/js/jquery.validate.min.js');
     $document->addScript('components/com_bookingforconnector/assets/js/additional-methods.min.js');
     // Initialise variables
     $state = $this->get('State');
     $actionmode = JRequest::getVar('actionmode', "");
     $item = $this->get('Item');
     $params =& $state->params;
     $this->assignRef('state', $state);
     $this->assignRef('params', $params);
     $this->assignRef('language', $language);
     $this->assignRef('item', $item);
     $this->assignRef('actionmode', $actionmode);
     if ($actionmode == "orderpayment") {
         //recupero quanti pagamenti sono stati effettuati
         $item->paymentCount = BFCHelper::getTotalOrderPayments($item->order->OrderId);
         $item->overrideAmount = JRequest::getFloat('overrideAmount');
         //sostituisco i dati dell'ordine da pagare con i dati passati e l'ordine con un suffisso in più
         /*$item = $this->get('Item');*/
         /*$item = "fet";*/
     }
     if ($actionmode != '' && $actionmode != 'cancel' && $actionmode != 'donation' && $actionmode != 'orderpayment') {
         if ($item->order->Status != 5) {
             $hasPayed = $this->processPayment($actionmode, $item->order->OrderId);
             /* eccezione per setefi che pretende un url di ritorno */
         } else {
             //$hasPayed = true;
             $hasPayed = $this->processOrderPayment($actionmode, $item->order->OrderId, $language);
         }
         /*
         $link = '';
         if ($hasPayed){
          	
         }
         $app = JFactory::getApplication();
         $app->redirect($link, $msg);
         */
     }
     if ($actionmode == '' && $actionmode != 'donation') {
         if ($item->order->Status != 5) {
             $this->inizializePayment($item->order->OrderId);
         }
     }
     if ($actionmode == 'orderpaid') {
         $hasPayed = $item->order->Status == 5;
     }
     // assegno il riferimento dopo gli altri altrimenti non ho nessuna associazione
     $this->assignRef('hasPayed', $hasPayed);
     /*
     		$items		= $this->get('Items');
     		$pagination	= $this->get('Pagination');
     		$sortColumn 	= $state->get('list.ordering');
     		$sortDirection 	= $state->get('list.direction');
     
     // Check for errors.
     		if (count($errors = $this->get('Errors'))) {
     			JError::raiseWarning(500, implode("\n", $errors));
     			return false;
     		}
     $pagination->setAdditionalUrlParam("filter_order", $ordering);
     		$pagination->setAdditionalUrlParam("filter_order_Dir", $direction);
     
     
     $this->assignRef('items', $items);
     		$this->assignRef('pagination', $pagination);
     */
     // Display the view
     parent::display($tpl);
 }