Example #1
0
 /**
  * @return bool|null
  */
 function plgVmOnUserPaymentCancel()
 {
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
     }
     $order_number = JRequest::getString('on', '');
     $virtuemart_paymentmethod_id = JRequest::getInt('pm', '');
     if (empty($order_number) or empty($virtuemart_paymentmethod_id) or !$this->selectedThisByMethodId($virtuemart_paymentmethod_id)) {
         return NULL;
     }
     if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) {
         return NULL;
     }
     if (!($paymentTable = $this->getDataByOrderId($virtuemart_order_id))) {
         return NULL;
     }
     VmInfo(Jtext::_('VMPAYMENT_PAYPAL_PAYMENT_CANCELLED'));
     $session = JFactory::getSession();
     $return_context = $session->getId();
     if (strcmp($paymentTable->paypal_custom, $return_context) === 0) {
         $this->handlePaymentUserCancel($virtuemart_order_id);
     }
     return TRUE;
 }
Example #2
0
 /**
  * @return bool|null
  */
 function plgVmOnUserPaymentCancel()
 {
     $order_number = vRequest::getString('on', '');
     $virtuemart_paymentmethod_id = vRequest::getInt('pm', '');
     if (empty($order_number) or empty($virtuemart_paymentmethod_id) or !$this->selectedThisByMethodId($virtuemart_paymentmethod_id)) {
         vmdebug('plgVmOnUserPaymentCancel', $order_number, $virtuemart_paymentmethod_id);
         return NULL;
     }
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) {
         return NULL;
     }
     if (!($paymentTable = $this->getDataByOrderId($virtuemart_order_id))) {
         return NULL;
     }
     vmdebug('plgVmOnUserPaymentCancel', 'VMPAYMENT_SOFORT_PAYMENT_CANCELLED');
     VmInfo(vmText::_('VMPAYMENT_SOFORT_PAYMENT_CANCELLED'));
     $session = JFactory::getSession();
     $return_context = $session->getId();
     if (strcmp($paymentTable->sofort_custom, $return_context) === 0) {
         vmDebug('handlePaymentUserCancel');
         $this->handlePaymentUserCancel($virtuemart_order_id);
     } else {
         vmDebug('Return context', $paymentTable->sofort_custom, $return_context);
     }
     return TRUE;
 }
Example #3
0
	/**
	 * For Express Checkout
	 * @param $type
	 * @param $name
	 * @param $render
	 * @return bool|null
	 */

	function plgVmOnSelfCallFE($type, $name, &$render) {
		if ($name != $this->_name || $type != 'vmpayment') {
			return FALSE;
		}
		$action = jRequest::getWord('action');
		$virtuemart_paymentmethod_id = JRequest::getInt('virtuemart_paymentmethod_id');
		//Load the method
		if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
			return NULL; // Another method was selected, do nothing
		}
		if ($action != 'SetExpressCheckout') {
			return false;
		}
		if (!class_exists('VirtueMartCart')) {
			require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');
		}
		$cart = VirtueMartCart::getCart();
		$cart->virtuemart_paymentmethod_id = $virtuemart_paymentmethod_id;
		$cart->setCartIntoSession();

		$paypalInterface = $this->_loadPayPalInterface();
		$paypalInterface->setCart($cart);
		$paypalInterface->setTotal($cart->pricesUnformatted['billTotal']);
		$paypalInterface->loadCustomerData();
		$paypalInterface->getExtraPluginInfo($this->_currentMethod);

		if (!$paypalInterface->validate()) {
			VmInfo('VMPAYMENT_PAYPAL_PAYMENT_NOT_VALID');
			return false;
		} else {
			$app = JFactory::getApplication();
			$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&Itemid=' . JRequest::getInt('Itemid'), false));
		}
	}
	/**
	 *  Ask Question form
	 * Recommend form for Mail
	 */
	public function MailForm () {

		if (JRequest::getCmd ('task') == 'recommend') {

			/*OSP 2012-03-14 ...Track #375; allowed by setting */
			if (VmConfig::get ('recommend_unauth', 0) == '0') {
				$user = JFactory::getUser ();
				if (empty($user->id)) {
					VmInfo (JText::_ ('JGLOBAL_YOU_MUST_LOGIN_FIRST'));
					return;
				}
			}
			$view = $this->getView ('recommend', 'html');
		} else {
			$view = $this->getView ('askquestion', 'html');
		}

		/* Set the layout */
		$view->setLayout ('form');

		// Display it all
		$view->display ();
	}
Example #5
0
	/**
	 * For Express Checkout
	 * @param $type
	 * @param $name
	 * @param $render
	 * @return bool|null
	 */

	function plgVmOnSelfCallFE($type, $name, &$render) {
		if ($name != $this->_name || $type != 'vmpayment') {
			return FALSE;
		}
		$action = vRequest::getCmd('action');
		$virtuemart_paymentmethod_id = vRequest::getInt('pm');
		//Load the method
		if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
			return NULL; // Another method was selected, do nothing
		}
		if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
			return FALSE;
		}
		if ($action != 'SetExpressCheckout') {
			return false;
		}
		$expressCheckout = vRequest::getVar('SetExpressCheckout', '');

		if($expressCheckout=='done') {
			if (!class_exists('VirtueMartCart')) {
				require(VMPATH_SITE . DS . 'helpers' . DS . 'cart.php');
			}
			$cart = VirtueMartCart::getCart();
			$cart->prepareCartData();
			$cart->virtuemart_paymentmethod_id = $virtuemart_paymentmethod_id;
			$cart->setCartIntoSession();
			//$this->_currentMethod = $currentMethod;
			$paypalInterface = $this->_loadPayPalInterface();
			$paypalInterface->setCart($cart);
			$paypalInterface->setTotal($cart->cartPrices['billTotal']);
			$paypalInterface->loadCustomerData();
			// will perform $this->getExpressCheckoutDetails();
			$paypalInterface->getExtraPluginInfo($this->_currentMethod);

			if (!$paypalInterface->validate()) {
				VmInfo('VMPAYMENT_PAYPAL_PAYMENT_NOT_VALID');
				return false;
			} else {
				$app = JFactory::getApplication();
				$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&Itemid=' . vRequest::getInt('Itemid'), false));
			}
		}	elseif($expressCheckout=='cancel') {
				$this->customerData->clear();
				if (!class_exists('VirtueMartCart')) {
					require(VMPATH_SITE . DS . 'helpers' . DS . 'cart.php');
				}
				$cart = VirtueMartCart::getCart();
				$cart->virtuemart_paymentmethod_id = 0;
				$cart->setCartIntoSession();
				$app = JFactory::getApplication();
				$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&Itemid=' . vRequest::getInt('Itemid'), false), vmText::_('VMPAYMENT_PAYPAL_PAYMENT_CANCELLED'));
		}

	}
Example #6
0
 public function plgVmInterpreteMathOp($calculationHelper, $rule, $price, $revert)
 {
     $rule = (object) $rule;
     if (empty($rule->published)) {
         return $price;
     }
     $mathop = $rule->calc_value_mathop;
     $tax = 0.0;
     if ($calculationHelper->inCart) {
         static $done = false;
         if ($done) {
             return $price;
         }
     }
     if ($mathop == 'avalara') {
         $requestedProductId = vRequest::getVar('virtuemart_product_id', 0);
         if (is_array($requestedProductId) and count($requestedProductId) > 0) {
             $requestedProductId = $requestedProductId[0];
         }
         $requestedProductId = (int) $requestedProductId;
         if (isset($calculationHelper->_product)) {
             $productId = $calculationHelper->_product->virtuemart_product_id;
         } else {
             $productId = $requestedProductId;
         }
         if ($calculationHelper->inCart) {
             $products = $this->getCartProducts($calculationHelper);
             if (!$products) {
                 $this->blockCheckout();
                 return $price;
             }
         }
         //avadebug('plgVmInterpreteMathOp avalara ',$rule);
         if ($productId != 0 and $productId == $requestedProductId or $calculationHelper->inCart) {
             VmTable::bindParameterable($rule, $this->_xParams, $this->_varsToPushParam);
             if ($rule->activated == 0) {
                 return $price;
             }
             if (empty($this->addresses)) {
                 $vmadd = $this->getShopperDataFromCart($rule);
                 $this->addresses = $this->fillValidateAvalaraAddress($rule, $vmadd);
             }
             if ($this->addresses) {
                 if (empty($products)) {
                     $products = $this->prepareSingleProduct($calculationHelper, $price);
                 }
                 if ($calculationHelper->inCart) {
                     $prices = $calculationHelper->getCartPrices();
                     if (!empty($prices['salesPriceCoupon'])) {
                         if (!isset($products['discountAmount'])) {
                             $products['discountAmount'] = 0.0;
                         }
                         $products['discountAmount'] -= $prices['salesPriceCoupon'];
                         vmdebug('Adding couponvalue to discount ' . $products['discountAmount']);
                     }
                 }
                 $tax = $this->getAvaTax($rule, $products);
                 if ($calculationHelper->inCart) {
                     $tax = 0.0;
                     $prices = $calculationHelper->getCartPrices();
                     $toSet = self::$_taxResult;
                     $toSet['salesPrice'] = 0.0;
                     foreach (self::$_taxResult as $k => $line) {
                         if (is_integer($k)) {
                             $toSet[$k]['salesPrice'] = $prices[$k]['salesPrice'] + $line['taxAmount'];
                             $toSet[$k]['subtotal_with_tax'] = $prices[$k]['subtotal_with_tax'] + $line['taxAmountQuantity'];
                             $toSet['salesPrice'] += $toSet[$k]['subtotal_with_tax'];
                         }
                     }
                     $toSet['taxAmount'] = self::$_taxResult['totalTax'];
                     if (isset($prices['shipmentValue']) and isset(self::$_taxResult['shipmentTax'])) {
                         $toSet['shipmentTax'] = self::$_taxResult['shipmentTax'];
                         $toSet['salesPriceShipment'] = $prices['shipmentValue'] + self::$_taxResult['shipmentTax'];
                     }
                     if (isset($prices['paymentValue'])) {
                         //and isset(self::$_taxResult['paymentTax'] )) {
                         $toSet['paymentTax'] = 0.0;
                         $toSet['salesPricePayment'] = $prices['paymentValue'];
                         // + self::$_taxResult['paymentTax'] );
                     }
                     vmdebug('avatax plgVmInterpreteMathOp result', self::$_taxResult, $toSet);
                     $calculationHelper->setCartPricesMerge($toSet);
                 }
             } else {
                 if ($rule->prevCheckoutAddInv) {
                     if ($calculationHelper->inCart) {
                         VmInfo('VMCALCULATION_AVALARA_INVALID_INFO');
                     }
                     $this->blockCheckout();
                 }
             }
         }
     }
     if ($revert) {
         $tax = -$tax;
     }
     return $price + (double) $tax;
 }
Example #7
0
 /**
  * This event is fired after the payment method has been selected. It can be used to store
  * additional payment info in the cart.
  * @author Valérie isaksen
  *
  * @param VirtueMartCart $cart: the actual cart
  * @return null if the payment was not selected, true if the data is valid, error message if the data is not vlaid
  *
  */
 public function plgVmOnSelectCheckPayment(VirtueMartCart $cart)
 {
     if (!$this->selectedThisByMethodId($cart->virtuemart_paymentmethod_id)) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!($method = $this->getVmPluginMethod($cart->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!class_exists('KlarnaAddr')) {
         require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'api' . DS . 'klarnaaddr.php';
     }
     $session = JFactory::getSession();
     $sessionKlarna = new stdClass();
     //$post = JRequest::get('post');
     $klarnaData_paymentmethod = JRequest::getVar('klarna_paymentmethod', '');
     if ($klarnaData_paymentmethod == 'klarna_invoice') {
         $klarnaData_payment = "klarna_invoice";
         $sessionKlarna->klarna_option = 'invoice';
     } elseif ($klarnaData_paymentmethod == 'klarna_partPayment') {
         $klarnaData_payment = "klarna_partpay";
         $sessionKlarna->klarna_option = 'part';
     } elseif ($klarnaData_paymentmethod == 'klarna_speccamp') {
         $klarnaData_payment = "klarna_speccamp";
         $sessionKlarna->klarna_option = 'spec';
     } else {
         return NULL;
     }
     // Store payment_method_id so we can activate the
     // right payment in case something goes wrong.
     $sessionKlarna->virtuemart_payment_method_id = $cart->virtuemart_paymentmethod_id;
     $sessionKlarna->klarna_paymentmethod = $klarnaData_paymentmethod;
     $this->_getCartAddressCountryCode($cart, $country3, $countryId, 'country_3_code');
     // $country2=  strtolower($country2);
     if (empty($country3)) {
         $country3 = "SWE";
         $countryId = ShopFunctions::getCountryIDByName($country3);
     }
     $cData = KlarnaHandler::countryData($method, strtoupper($country3));
     $klarnaData = KlarnaHandler::getDataFromEditPayment();
     $klarnaData['country'] = $cData['country_code'];
     //$country = $cData['country_code']; //KlarnaHandler::convertCountry($method, $country2);
     //$lang = $cData['language_code']; //KlarnaHandler::getLanguageForCountry($method, $country);
     // Get the correct data
     //Removes spaces, tabs, and other delimiters.
     // If it is a swedish customer we use the information from getAddress
     if (strtolower($cData['country_code']) == "se") {
         if (empty($klarnaData['socialNumber'])) {
             VmInfo('VMPAYMENT_KLARNA_MUST_VALID_PNO');
             return false;
         }
         $swedish_addresses = klarnaHandler::getAddresses($klarnaData['socialNumber'], $cData, $method);
         if (empty($swedish_addresses)) {
             VmInfo('VMPAYMENT_KLARNA_NO_GETADDRESS');
             return false;
         }
         //This example only works for GA_GIVEN.
         foreach ($swedish_addresses as $address) {
             if ($address->isCompany) {
                 $klarnaData['company_name'] = $address->getCompanyName();
             } else {
                 $klarnaData['first_name'] = $address->getFirstName();
                 $klarnaData['last_name'] = $address->getLastName();
             }
             $klarnaData['street'] = $address->getStreet();
             $klarnaData['zip'] = $address->getZipCode();
             $klarnaData['city'] = $address->getCity();
             $klarnaData['country'] = $address->getCountryCode();
             $countryId = $klarnaData['virtuemart_country_id'] = shopFunctions::getCountryIDByName($klarnaData['country']);
         }
         foreach ($klarnaData as $key => $value) {
             $klarnaData[$key] = mb_convert_encoding($klarnaData[$key], 'UTF-8', 'ISO-8859-1');
         }
     } elseif (!KlarnaHandler::checkDataFromEditPayment($klarnaData)) {
         //VmInfo('VMPAYMENT_KLARNA_MISSING_DATA');
         //return false;
     }
     $st = $this->getCartAddress($cart, $address_type, true);
     if ($address_type == 'BT') {
         $prefix = '';
     } else {
         $prefix = 'shipto_';
     }
     // Update the Shipping Address to what is specified in the register.
     $update_data = array($prefix . 'address_type_name' => 'Klarna', $prefix . 'company' => $klarnaData['company_name'], $prefix . 'first_name' => $klarnaData['first_name'], $prefix . 'middle_name' => $st['middle_name'], $prefix . 'last_name' => $klarnaData['last_name'], $prefix . 'address_1' => $klarnaData['street'], $prefix . 'address_2' => $klarnaData['house_ext'], $prefix . 'house_no' => $klarnaData['house_no'], $prefix . 'zip' => html_entity_decode($klarnaData['zip']), $prefix . 'city' => $klarnaData['city'], $prefix . 'virtuemart_country_id' => $countryId, $prefix . 'state' => '', $prefix . 'phone_1' => $klarnaData['phone'], $prefix . 'phone_2' => $st['phone_2'], $prefix . 'fax' => $st['fax'], $prefix . 'birthday' => empty($klarnaData['birthday']) ? $st['birthday'] : $klarnaData['birthday'], $prefix . 'social_number' => empty($klarnaData['pno']) ? $klarnaData['socialNumber'] : $klarnaData['pno'], 'address_type' => $address_type);
     if ($address_type == 'BT') {
         $update_data['email'] = $klarnaData['email'];
     }
     // save address in cart if different
     // 	if (false) {
     $cart->saveAddressInCart($update_data, $update_data['address_type'], true);
     //vmdebug('plgVmOnSelectCheckPayment $cart',$cart);
     //vmInfo(JText::_('VMPAYMENT_KLARNA_ADDRESS_UPDATED_NOTICE'));
     // 	}
     //}
     // Store the Klarna data in a session variable so
     // we can retrevie it later when we need it
     //$klarnaData['pclass'] = ($klarnaData_paymentmethod == 'klarna_invoice' ? -1 : intval(JRequest::getVar($kIndex . "paymentPlan")));
     $klarnaData['pclass'] = $klarnaData_paymentmethod == 'klarna_invoice' ? -1 : intval(JRequest::getVar("klarna_paymentPlan"));
     $sessionKlarna->KLARNA_DATA = $klarnaData;
     // 2 letters small
     //$settings = KlarnaHandler::getCountryData($method, $cart_country2);
     try {
         $address = new KlarnaAddr($klarnaData['email'], $klarnaData['phone'], "", $klarnaData['first_name'], $klarnaData['last_name'], '', $klarnaData['street'], $klarnaData['zip'], $klarnaData['city'], $klarnaData['country'], $klarnaData['house_no'], $klarnaData['house_ext']);
     } catch (Exception $e) {
         VmInfo($e->getMessage());
         return false;
         //KlarnaHandler::redirectPaymentMethod('message', $e->getMessage());
     }
     if (isset($errors) && count($errors) > 0) {
         $msg = JText::_('VMPAYMENT_KLARNA_ERROR_TITLE_1');
         foreach ($errors as $error) {
             $msg .= "<li> -" . $error . "</li>";
         }
         $msg .= JText::_('VMPAYMENT_KLARNA_ERROR_TITLE_2');
         unset($errors);
         VmError($msg);
         return false;
         //KlarnaHandler::redirectPaymentMethod('error', $msg);
     }
     $session->set('Klarna', serialize($sessionKlarna), 'vm');
     return true;
 }
Example #8
0
	public function plgVmInterpreteMathOp ($calculationHelper, $rule, $price,$revert){

		$rule = (object)$rule;
		if(empty($rule->published)) return $price;

		$mathop = $rule->calc_value_mathop;
		$tax = 0.0;

		if ($mathop=='avalara') {
			$requestedProductId = vRequest::getVar ('virtuemart_product_id',0);
			if(is_array($requestedProductId) and count($requestedProductId) > 0) {
				$requestedProductId = $requestedProductId[0];
			}
			$requestedProductId = (int) $requestedProductId;

			if(isset($calculationHelper->_product)){
				$productId = $calculationHelper->_product->virtuemart_product_id;
			} else {
				$productId = $requestedProductId;
			}

			if($calculationHelper->inCart){
				$products = $this->getCartProducts($calculationHelper);
				if(!$products){
					$this->blockCheckout();
					return $price;
				}
			}
			//avadebug('plgVmInterpreteMathOp avalara ',$rule);
			if(($productId!=0 and $productId==$requestedProductId) or $calculationHelper->inCart ){
				VmTable::bindParameterable ($rule, $this->_xParams, $this->_varsToPushParam);
				if($rule->activated==0) return $price;
				if(empty($this->addresses)){
					$vmadd = $this->getShopperDataFromCart($rule);
					$this->addresses = $this->fillValidateAvalaraAddress($rule,$vmadd);
				}

				if($this->addresses){

					if(empty($products))$products = $this->prepareSingleProduct($calculationHelper,$price);

					if($calculationHelper->inCart){
						$prices =  $calculationHelper->getCartPrices();
						if(!empty($prices['salesPriceCoupon'])){
							if(!isset($products['discountAmount'])) $products['discountAmount'] = 0.0;
							$products['discountAmount'] -= $prices['salesPriceCoupon'];
							vmdebug('Adding couponvalue to discount '.$products['discountAmount']);
						}
					}
					$tax = $this->getAvaTax( $rule,$products);
					if($calculationHelper->inCart){

						$prices =  $calculationHelper->getCartPrices();
						if(isset($prices['shipmentValue']) and isset(self::$_taxResult['shipmentTax'] )) {
							self::$_taxResult['salesPriceShipment'] = ($prices['shipmentValue'] + self::$_taxResult['shipmentTax'] );
							//self::$_taxResult['paymentTax'] = 0.0;
						}

						/*if(isset($prices['paymentValue']) and isset(self::$_taxResult['paymentTax'] )) {
							self::$_taxResult['paymentTax'] = 0.0;
							self::$_taxResult['salesPricePayment'] = ($prices['paymentValue'] + self::$_taxResult['paymentTax'] );
						}*/

						$calculationHelper->setCartPricesMerge(self::$_taxResult);
					}
				} else if($rule->prevCheckoutAddInv){
					if($calculationHelper->inCart){
						VmInfo('VMCALCULATION_AVALARA_INVALID_INFO');
					}
					$this->blockCheckout();
				}
			}
		}

		if($revert){
			$tax = -$tax;
		}

		return $price + (float)$tax;
	}
 /**
  * Returns a collection of addresses that are connected to the
  * supplied SSN
  *
  * @param <type> $pno The SSN of the user. This method is only available
  * for swedish customers
  * @return array
  */
 public static function getAddresses($pno, $settings, $method)
 {
     // Only available for sweden.
     $addresses = array();
     $klarna = new Klarna_virtuemart();
     $mode = KlarnaHandler::getKlarnaMode($method, $settings['country_code_3']);
     $klarna->config($settings['eid'], $settings['secret'], KlarnaCountry::SE, KlarnaLanguage::SV, KlarnaCurrency::SEK, $mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $mode);
     try {
         $addresses = $klarna->getAddresses($pno, NULL, KlarnaFlags::GA_GIVEN);
     } catch (Exception $e) {
         // the message is returned NOT in UTF-8
         $msg = mb_convert_encoding($e->getMessage(), 'UTF-8', 'ISO-8859-1');
         VmInfo($msg);
     }
     unset($klarna);
     return $addresses;
 }
Example #10
0
 /**
  *
  */
 function cancelReservation($order, $payments)
 {
     $rno = $this->getReservationNumber($payments);
     if (!$rno) {
         return;
         // error already sent
     }
     $this->initKlarnaParams($this->method);
     $klarna = new Klarna_virtuemart();
     $klarna->config($this->merchantid, $this->sharedsecret, $this->country_code_3, NULL, $this->currency_code_3, $this->mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $this->ssl);
     $modelOrder = VmModel::getModel('orders');
     try {
         $result = $klarna->cancelReservation($rno);
         $info = vmText::sprintf('VMPAYMENT_KLARNACHECKOUT_RESERVATION_CANCELED', $rno);
         VmInfo($info);
         $history = array();
         $history['customer_notified'] = 1;
         //$history['order_status'] = $this->method->checkout_complete;
         $history['comments'] = $info;
         // $order['details']['BT']->order_number);
         $modelOrder->updateStatusForOneOrder($order->virtuemart_paymentmethod_id, $history, TRUE);
         $dbValues['order_number'] = $payments[0]->order_number;
         $dbValues['payment_name'] = '';
         $dbValues['virtuemart_paymentmethod_id'] = $payments[0]->virtuemart_paymentmethod_id;
         $dbValues['action'] = 'cancelReservation';
         $dbValues['klarna_status'] = 'cancelReservation';
         $dbValues['data'] = $info;
         $this->debugLog($dbValues, 'storePSPluginInternalData cancelReservation', 'debug');
         $values = $this->storePSPluginInternalData($dbValues, $this->_tablepkey);
     } catch (Exception $e) {
         $error = $e->getMessage();
         VmError($e->getMessage(), vmText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $this->method->payment_name));
         $this->debugLog($e->getMessage(), 'cancelReservation', 'error');
         return FALSE;
     }
     //$dbValues['data'] = $vm_invoice_name;
     return true;
 }
Example #11
0
 /**
  * @return bool|null
  */
 function plgVmOnUserPaymentCancel()
 {
     $order_number = vRequest::getString('on', '');
     // cancel / abort link must be insterted in the SOFORT BE
     // must be http://mysite.com/index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=-REASON1-
     $virtuemart_paymentmethod_id = vRequest::getInt('pm', '');
     if (empty($order_number) or empty($virtuemart_paymentmethod_id) or !$this->selectedThisByMethodId($virtuemart_paymentmethod_id)) {
         return NULL;
     }
     $error_codes = vRequest::getString('error_codes', '');
     if (!empty($error_codes)) {
         $errors = explode(",", $error_codes);
         foreach ($errors as $error) {
             // TODO
             $lang = JFactory::getLanguage();
             $lang_key = 'VMPAYMENT_SOFORT_IDEAL_ERROR_CODES_' . $error;
             if ($lang->hasKey($lang_key)) {
                 vmInfo(vmText::_($lang_key));
             } else {
                 vmInfo(vmText::sprintf('VMPAYMENT_SOFORT_IDEAL_ERROR_CODES_UNKNOWN_CODE', $error));
             }
         }
         //return false;
     }
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) {
         return NULL;
     }
     if (!($paymentTable = $this->getDataByOrderId($virtuemart_order_id))) {
         return NULL;
     }
     if (!($method = $this->getVmPluginMethod($paymentTable->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         //vmdebug('IDEAL plgVmOnPaymentResponseReceived NOT selectedThisElement'  );
         return NULL;
     }
     vmdebug(__CLASS__ . '::' . __FUNCTION__, 'VMPAYMENT_SOFORT_PAYMENT_CANCELLED', $error_codes);
     if (empty($error_codes)) {
         VmInfo(vmText::_('VMPAYMENT_SOFORT_PAYMENT_CANCELLED'));
         $comment = '';
     } else {
         $comment = vmText::_($lang_key);
     }
     $session = JFactory::getSession();
     $return_context = $session->getId();
     vmDebug('handlePaymentUserCancel', $virtuemart_order_id, $paymentTable->sofort_custom, $return_context);
     if (strcmp($paymentTable->sofort_custom, $return_context) === 0) {
         vmDebug('handlePaymentUserCancel', $virtuemart_order_id);
         $this->handlePaymentUserCancel($virtuemart_order_id, $method->status_canceled, $comment);
     } else {
         vmDebug('Return context', $paymentTable->sofort_custom, $return_context);
     }
     return TRUE;
 }
Example #12
0
 /**
  * Dangerous tools get disabled after execution an operation which needed that rights.
  * This is the function actually doing it.
  *
  * @author Max Milbers
  */
 function setDangerousToolsOff()
 {
     // 		VmConfig::loadConfig(true);
     $dangerousTools = VmConfig::readConfigFile(true);
     if ($dangerousTools) {
         $uri = JFactory::getURI();
         $link = $uri->root() . 'administrator/index.php?option=com_virtuemart&view=config';
         $lang = JText::sprintf('COM_VIRTUEMART_SYSTEM_DANGEROUS_TOOL_STILL_ENABLED', JText::_('COM_VIRTUEMART_ADMIN_CFG_DANGEROUS_TOOLS'), $link);
         VmInfo($lang);
     } else {
         $data['dangeroustools'] = 0;
         $data['virtuemart_config_id'] = 1;
         $this->store($data);
     }
 }
Example #13
0
 function plgVmOnUserPaymentCancel()
 {
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     $order_number = vRequest::getUword('on');
     $virtuemart_paymentmethod_id = vRequest::getInt('pm', '');
     if (empty($order_number) or empty($virtuemart_paymentmethod_id) or !$this->selectedThisByMethodId($virtuemart_paymentmethod_id)) {
         return NULL;
     }
     $numerr = vRequest::getString('E', '');
     if ($numerr) {
         VmInfo('VMPAYMENT_' . $this->_name . '_PBX_NUMERR_' . abs($numerr));
     }
     if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) {
         return NULL;
     }
     if (!($paymentTable = $this->getDataByOrderId($virtuemart_order_id))) {
         return NULL;
     }
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $field = $this->_name . '_custom';
     if (strcmp($paymentTable->{$field}, $return_context) === 0) {
         $this->handlePaymentUserCancel($virtuemart_order_id);
     }
     return TRUE;
 }
Example #14
0
 /**
  *
  */
 function cancelReservation($order, $payments)
 {
     $rno = $this->getReservationNumber($payments);
     if (!$rno) {
         return;
         // error already sent
     }
     $klarna = new Klarna_virtuemart();
     $klarna->config($this->_currentMethod->merchantid, $this->_currentMethod->sharedsecret, $this->country_code_3, NULL, $this->currency_code_3, $this->mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $this->ssl);
     $modelOrder = tmsModel::getModel('orders');
     try {
         $result = $klarna->cancelReservation($rno);
         $info = tsmText::sprintf('VMPAYMENT_KLARNACHECKOUT_RESERVATION_CANCELED', $rno);
         VmInfo($info);
         $history = array();
         $history['customer_notified'] = 1;
         //$history['order_status'] = $this->_currentMethod->checkout_complete;
         $history['comments'] = $info;
         // $order['details']['BT']->order_number);
         $modelOrder->updateStatusForOneOrder($order->virtuemart_order_id, $history, TRUE);
     } catch (Exception $e) {
         $error = $e->getMessage();
         $this->KlarnacheckoutError($e->getMessage(), tsmText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $this->_currentMethod->payment_name));
         return FALSE;
     }
     //$dbValues['data'] = $vm_invoice_name;
     return $result;
 }
Example #15
0
 /**
  * Dangerous tools get disabled after execution an operation which needed that rights.
  * This is the function actually doing it.
  *
  * @author Max Milbers
  */
 function setDangerousToolsOff()
 {
     $dangerousTools = VirtueMartModelConfig::readConfigFile(true);
     if ($dangerousTools) {
         $link = JURI::root() . 'administrator/index.php?option=com_virtuemart&view=config';
         $lang = vmText::sprintf('COM_VIRTUEMART_SYSTEM_DANGEROUS_TOOL_STILL_ENABLED', vmText::_('COM_VIRTUEMART_ADMIN_CFG_DANGEROUS_TOOLS'), $link);
         VmInfo($lang);
     } else {
         if (self::checkConfigTableExists()) {
             $data['dangeroustools'] = 0;
             $data['virtuemart_config_id'] = 1;
             $this->store($data);
         }
     }
 }
Example #16
0
 /**
  * Returns a collection of addresses that are connected to the
  * supplied SSN
  *
  * @param <type> $pno The SSN of the user. This method is only available
  * for swedish customers
  * @return array
  */
 public static function getAddresses($pno, $settings, $method)
 {
     // Only available for sweden.
     $addresses = array();
     $klarna = new Klarna_virtuemart();
     $mode = KlarnaHandler::getKlarnaMode($method);
     $klarna->config($settings['eid'], $settings['secret'], KlarnaCountry::SE, KlarnaLanguage::SV, KlarnaCurrency::SEK, $mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $mode);
     try {
         $addresses = $klarna->getAddresses($pno, NULL, KlarnaFlags::GA_GIVEN);
     } catch (Exception $e) {
         VmInfo($e->getMessage());
     }
     unset($klarna);
     return $addresses;
 }