Example #1
0
 function plgVmOnPaymentResponseReceived(&$html)
 {
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
     }
     VmConfig::loadJLang('com_virtuemart_orders', TRUE);
     $virtuemart_paymentmethod_id = pbxRequest::getInt('pm', 0);
     if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return NULL;
     }
     $paybox_data = pbxRequest::getGet();
     $this->debugLog('"<pre>plgVmOnPaymentResponseReceived :' . var_export($paybox_data, true) . "</pre>", 'debug');
     $payboxInterface = $this->_loadPayboxInterface($this);
     $html = $payboxInterface->paymentResponseReceived($paybox_data);
     pbxRequest::setVar('display_title', false);
     pbxRequest::setVar('html', $html);
     return true;
 }
Example #2
0
 /**
  * @param $cart
  * @param $order
  * @return bool
  */
 function confirmedOrder($cart, $order)
 {
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php';
     }
     $this->plugin->getPaymentCurrency($this->_method);
     $q = 'SELECT `currency_numeric_code` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $this->_method->payment_currency . '" ';
     $db = JFactory::getDBO();
     $db->setQuery($q);
     $currency_numeric_code = $db->loadResult();
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $this->_method->payment_currency);
     $orderTotalVendorCurrency = $order['details']['BT']->order_total;
     $pbxOrderTotalInPaymentCurrency = $this->getPbxAmount($totalInPaymentCurrency['value']);
     $email_currency = $this->plugin->getEmailCurrency($this->_method);
     // If the file is not there anylonger, just create it
     $this->plugin->createRootFile($this->_method->virtuemart_paymentmethod_id);
     if (!$this->getPayboxServerUrl()) {
         $this->redirectToCart();
         return false;
     }
     if (!($payboxReturnUrls = $this->getPayboxReturnUrls())) {
         $this->redirectToCart();
         return false;
     }
     $post_variables = array("PBX_SITE" => $this->_method->site_id, "PBX_RANG" => $this->_method->rang, "PBX_IDENTIFIANT" => $this->_method->identifiant, "PBX_TOTAL" => $this->getPbxTotal($pbxOrderTotalInPaymentCurrency), "PBX_DEVISE" => $currency_numeric_code, "PBX_CMD" => $order['details']['BT']->order_number, "PBX_PORTEUR" => $order['details']['BT']->email, "PBX_RETOUR" => $this->getReturn(), "PBX_HASH" => $this->getHashAlgo(), "PBX_TIME" => $this->getTime(), "PBX_LANGUE" => $this->getLangue(), "PBX_EFFECTUE" => $payboxReturnUrls['url_effectue'], "PBX_ANNULE" => $payboxReturnUrls['url_annule'], "PBX_REFUSE" => $payboxReturnUrls['url_refuse'], "PBX_ERREUR" => $payboxReturnUrls['url_erreur'], "PBX_REPONDRE_A" => $payboxReturnUrls['url_notification'], "PBX_RUF1" => 'POST');
     if ($this->_method->debit_type == 'authorization_only') {
         $post_variables["PBX_DIFF"] = str_pad($this->_method->diff, 2, '0', STR_PAD_LEFT);
     }
     // min_amount_3dsecure is in vendor currency
     if (!$this->isActivate3ds($orderTotalVendorCurrency)) {
         $post_variables["PBX_3DS"] = 'N';
     }
     jimport('joomla.environment.browser');
     $browser = JBrowser::getInstance();
     if ($browser->isMobile()) {
         $post_variables["PBX_SOURCE"] = 'XHTML';
     }
     $subscribe = array();
     $recurring = array();
     $post_variables["PBX_CMD"] = $order['details']['BT']->order_number;
     if ($this->_method->integration == "recurring" and $orderTotalVendorCurrency > $this->_method->recurring_min_amount) {
         $recurring = $this->getRecurringPayments($pbxOrderTotalInPaymentCurrency);
         // PBX_TOTAL will be replaced in the array_merge.
         $post_variables = array_merge($post_variables, $recurring);
     } else {
         if ($this->_method->integration == "subscribe") {
             $subscribe_data = $this->getSubscribePayments($cart, $this->getPbxAmount($orderTotalVendorCurrency));
             if ($subscribe_data) {
                 // PBX_TOTAL is the order total in this case
                 $post_variables["PBX_TOTAL"] = $subscribe_data["PBX_TOTAL"];
                 $post_variables["PBX_CMD"] .= $subscribe_data['PBX_CMD'];
             }
         }
     }
     $post_variables["PBX_HMAC"] = $this->getHmac($post_variables, $this->_method->key);
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id;
     $dbValues['payment_name'] = $this->plugin->renderPluginName($this->_method);
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['paybox_custom'] = $this->getContext();
     $dbValues['cost_per_transaction'] = $this->_method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $this->_method->cost_percent_total;
     $dbValues['payment_currency'] = $this->_method->payment_currency;
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $post_variables["PBX_TOTAL"];
     if (!empty($recurring)) {
         $dbValues['recurring'] = json_encode($recurring);
         $dbValues['recurring_number'] = $this->_method->recurring_number;
         $dbValues['recurring_periodicity'] = $this->_method->recurring_periodicity;
     } else {
         $dbValues['recurring'] = NULL;
     }
     if (!empty($subscribe)) {
         $dbValues['subscribe'] = json_encode($subscribe);
         //$dbValues['recurring_number'] = $this->_method->recurring_number;
         //$dbValues['recurring_periodicity'] = $this->_method->recurring_periodicity;
     } else {
         $dbValues['subscribe'] = NULL;
     }
     $dbValues['tax_id'] = $this->_method->tax_id;
     $this->plugin->storePSPluginInternalData($dbValues);
     $html = $this->getConfirmedHtml($post_variables, $this);
     // 	2 = don't delete the cart, don't send email and don't redirect
     $cart->_confirmDone = FALSE;
     $cart->_dataValidated = FALSE;
     $cart->setCartIntoSession();
     pbxRequest::setVar('display_title', false);
     pbxRequest::setVar('html', $html);
     return;
 }