コード例 #1
0
 function _setShippingInformation($usrST)
 {
     // Customer Name and Billing Address
     return array('x_ship_to_first_name' => isset($usrST->first_name) ? $this->_getField($usrST->first_name, 50) : '', 'x_ship_to_last_name' => isset($usrST->first_name) ? $this->_getField($usrST->last_name, 50) : '', 'x_ship_to_company' => isset($usrST->company) ? $this->_getField($usrST->company, 50) : '', 'x_ship_to_address' => isset($usrST->first_name) ? $this->_getField($usrST->address_1, 60) : '', 'x_ship_to_city' => isset($usrST->city) ? $this->_getField($usrST->city, 40) : '', 'x_ship_to_zip' => isset($usrST->zip) ? $this->_getField($usrST->zip, 20) : '', 'x_ship_to_state' => isset($usrST->virtuemart_state_id) ? $this->_getField(ShopFunctions::getStateByID($usrST->virtuemart_state_id), 40) : '', 'x_ship_to_country' => isset($usrST->virtuemart_country_id) ? $this->_getField(ShopFunctions::getCountryByID($usrST->virtuemart_country_id), 60) : '');
 }
コード例 #2
0
ファイル: paypal.php プロジェクト: SeventF/ikea.com
 /**
  * @param $cart
  * @param $order
  * @return bool|null
  */
 function plgVmConfirmedOrder($cart, $order)
 {
     if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return FALSE;
     }
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $this->_debug = $method->debug;
     $this->logInfo('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     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';
     }
     $address = isset($order['details']['ST']) ? $order['details']['ST'] : $order['details']['BT'];
     if (!class_exists('TableVendors')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'tables' . DS . 'vendors.php';
     }
     $vendorModel = VmModel::getModel('Vendor');
     $vendorModel->setId(1);
     $vendor = $vendorModel->getVendor();
     $vendorModel->addImages($vendor, 1);
     $this->getPaymentCurrency($method);
     $email_currency = $this->getEmailCurrency($method);
     $currency_code_3 = shopFunctions::getCurrencyByID($method->payment_currency, 'currency_code_3');
     $paymentCurrency = CurrencyDisplay::getInstance($method->payment_currency);
     $totalInPaymentCurrency = round($paymentCurrency->convertCurrencyTo($method->payment_currency, $order['details']['BT']->order_total, FALSE), 2);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     if ($totalInPaymentCurrency <= 0) {
         vmInfo(JText::_('VMPAYMENT_PAYPAL_PAYMENT_AMOUNT_INCORRECT'));
         return FALSE;
     }
     $merchant_email = $this->_getMerchantEmail($method);
     if (empty($merchant_email)) {
         vmInfo(JText::_('VMPAYMENT_PAYPAL_MERCHANT_EMAIL_NOT_SET'));
         return FALSE;
     }
     $quantity = 0;
     foreach ($cart->products as $key => $product) {
         $quantity = $quantity + $product->quantity;
     }
     $post_variables = array('cmd' => '_ext-enter', 'redirect_cmd' => '_xclick', 'upload' => '1', 'business' => $merchant_email, 'receiver_email' => $merchant_email, 'order_number' => $order['details']['BT']->order_number, "invoice" => $order['details']['BT']->order_number, 'custom' => $return_context, 'item_name' => JText::_('VMPAYMENT_PAYPAL_ORDER_NUMBER') . ': ' . $order['details']['BT']->order_number, "amount" => $totalInPaymentCurrency, "currency_code" => $currency_code_3, "address_override" => isset($method->address_override) ? $method->address_override : 0, "first_name" => $address->first_name, "last_name" => $address->last_name, "address1" => $address->address_1, "address2" => isset($address->address_2) ? $address->address_2 : '', "zip" => $address->zip, "city" => $address->city, "state" => isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id, 'state_2_code') : '', "country" => ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'), "email" => $order['details']['BT']->email, "night_phone_b" => $address->phone_1, "return" => substr(JURI::root(false, ''), 0, -1) . JROUTE::_('index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid'), false), "notify_url" => substr(JURI::root(false, ''), 0, -1) . JROUTE::_('index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component', false), "cancel_return" => substr(JURI::root(false, ''), 0, -1) . JROUTE::_('index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid'), false), "ipn_test" => $method->debug, "rm" => '2', "bn" => "VirtueMart_Cart_PPA", "image_url" => JURI::root() . $vendor->images[0]->file_url, "no_shipping" => isset($method->no_shipping) ? $method->no_shipping : 0, "no_note" => "1");
     /*
      $i = 1;
      foreach ($cart->products as $key => $product) {
      $post_variables["item_name_" . $i] = substr(strip_tags($product->product_name), 0, 127);
      $post_variables["item_number_" . $i] = $i;
      $post_variables["amount_" . $i] = $cart->pricesUnformatted[$key]['salesPrice'];
      $post_variables["quantity_" . $i] = $product->quantity;
      $i++;
      }
      if ($cart->pricesUnformatted ['shipmentValue']) {
      $post_variables["item_name_" . $i] = JText::_('VMPAYMENT_PAYPAL_SHIPMENT_PRICE');
      $post_variables["item_number_" . $i] = $i;
      $post_variables["amount_" . $i] = $cart->pricesUnformatted ['shipmentValue'];
      $post_variables["quantity_" . $i] = 1;
      $i++;
      }
      if ($cart->pricesUnformatted ['paymentValue']) {
      $post_variables["item_name_" . $i] = JText::_('VMPAYMENT_PAYPAL_PAYMENT_PRICE');
      $post_variables["item_number_" . $i] = $i;
      $post_variables["amount_" . $i] = $cart->pricesUnformatted ['paymentValue'];
      $post_variables["quantity_" . $i] = 1;
      $i++;
      }
      if (!empty($order->cart->coupon)) {
      $post_variables["discount_amount_cart"] = $cart->pricesUnformatted['discountAmount'];
      }
     */
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = $this->renderPluginName($method, $order);
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['paypal_custom'] = $return_context;
     $dbValues['cost_per_transaction'] = $method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $method->cost_percent_total;
     $dbValues['payment_currency'] = $method->payment_currency;
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency;
     $dbValues['tax_id'] = $method->tax_id;
     $this->storePSPluginInternalData($dbValues);
     $url = $this->_getPaypalUrlHttps($method);
     // add spin image
     $html = '<html><head><title>Redirection</title></head><body><div style="margin: auto; text-align: center;">';
     $html .= '<form action="' . "https://" . $url . '" method="post" name="vm_paypal_form"  accept-charset="UTF-8">';
     $html .= '<input type="submit"  value="' . JText::_('VMPAYMENT_PAYPAL_REDIRECT_MESSAGE') . '" />';
     $html .= '<input type="hidden" name="charset" value="utf-8">';
     foreach ($post_variables as $name => $value) {
         $html .= '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" />';
     }
     $html .= '</form>';
     $html .= ' <script type="text/javascript">';
     $html .= ' document.vm_paypal_form.submit();';
     $html .= ' </script></body></html>';
     // 	2 = don't delete the cart, don't send email and don't redirect
     $cart->_confirmDone = FALSE;
     $cart->_dataValidated = FALSE;
     $cart->setCartIntoSession();
     JRequest::setVar('html', $html);
     /*
     
      $qstring = '?';
      foreach ($post_variables AS $k => $v) {
      $qstring .= ( empty($qstring) ? '' : '&')
      . urlencode($k) . '=' . urlencode($v);
      }
      // we can display the logo, or do the redirect
      $mainframe = JFactory::getApplication();
      $mainframe->redirect("https://" . $url . $qstring);
     
     
      return false; // don't delete the cart, don't send email
     */
 }
コード例 #3
0
ファイル: paypalhosted.php プロジェクト: sergy444/joomla
	function addShipTo(&$post_variables) {

		$addressST = ((isset($this->order['details']['ST'])) ? $this->order['details']['ST'] : $this->order['details']['BT']);

		//Ship To
		$post_variables['L_BUTTONVAR']['first_name'] = isset($addressST->first_name) ? $this->truncate($addressST->first_name, 50) : ''; // First name of person the item is being shipped to.
		$post_variables['L_BUTTONVAR']['last_name'] = isset($addressST->last_name) ? $this->truncate($addressST->last_name, 60) : ''; // Last name of person the item is being shipped to.
		$post_variables['L_BUTTONVAR']['address1'] = isset($addressST->address_1) ? $this->truncate($addressST->address_1, 60) : '';
		$post_variables['L_BUTTONVAR']['address2'] = isset($addressST->address_2) ? $this->truncate($addressST->address_2, 60) : '';
		$post_variables['L_BUTTONVAR']['city'] = isset($addressST->city) ? $this->truncate($addressST->city, 40) : '';
		$post_variables['L_BUTTONVAR']['zip'] = isset($addressST->zip) ? $this->truncate($addressST->zip, 40) : '';
		$post_variables['L_BUTTONVAR']['state'] = isset($addressST->virtuemart_state_id) ? $this->truncate(ShopFunctions::getStateByID($addressST->virtuemart_state_id), 20) : '';
		$post_variables['L_BUTTONVAR']['country'] = ShopFunctions::getCountryByID($addressST->virtuemart_country_id, 'country_2_code');
	}
コード例 #4
0
	/**
	 * @param $cart
	 * @param $order
	 * @return bool|null
	 */
	function plgVmConfirmedOrder ($cart, $order) {

		if (!($method = $this->getVmPluginMethod ($order['details']['BT']->virtuemart_paymentmethod_id))) {
			return NULL; // Another method was selected, do nothing
		}
		if (!$this->selectedThisElement ($method->payment_element)) {
			return FALSE;
		}
		$session = JFactory::getSession ();
		$return_context = $session->getId ();
		$this->_debug = $method->debug;
		$this->logInfo ('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');

		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');
		}

		$address = ((isset($order['details']['ST'])) ? $order['details']['ST'] : $order['details']['BT']);

		if (!class_exists ('TableVendors')) {
			require(JPATH_VM_ADMINISTRATOR . DS . 'table' . DS . 'vendors.php');
		}
		$vendorModel = VmModel::getModel ('Vendor');
		$vendorModel->setId (1);
		$vendor = $vendorModel->getVendor ();
		$vendorModel->addImages ($vendor, 1);
		$this->getPaymentCurrency ($method);
		$q = 'SELECT `currency_code_3` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $method->payment_currency . '" ';
		$db = JFactory::getDBO ();
		$db->setQuery ($q);
		$currency_code_3 = $db->loadResult ();

		$paymentCurrency = CurrencyDisplay::getInstance ($method->payment_currency);
		$totalInPaymentCurrency = round ($paymentCurrency->convertCurrencyTo ($method->payment_currency, $order['details']['BT']->order_total, FALSE), 2);
		$cd = CurrencyDisplay::getInstance ($cart->pricesCurrency);
		if ($totalInPaymentCurrency <= 0) {
			vmInfo (JText::_ ('VMPAYMENT_PAYPAL_PAYMENT_AMOUNT_INCORRECT'));
			return FALSE;
		}
		$merchant_email = $this->_getMerchantEmail ($method);
		if (empty($merchant_email)) {
			vmInfo (JText::_ ('VMPAYMENT_PAYPAL_MERCHANT_EMAIL_NOT_SET'));
			return FALSE;
		}

		$post_variables = Array(
			'cmd'              => '_ext-enter',
			'redirect_cmd'     => '_xclick',
			'upload'           => '1', //Indicates the use of third-party shopping cart
			'business'         => $merchant_email, //Email address or account ID of the payment recipient (i.e., the merchant).
			'receiver_email'   => $merchant_email, //Primary email address of the payment recipient (i.e., the merchant
			'order_number'     => $order['details']['BT']->order_number,
			"invoice"          => $order['details']['BT']->order_number,
			'custom'           => $return_context,
			'item_name'        => JText::_ ('VMPAYMENT_PAYPAL_ORDER_NUMBER') . ': ' . $order['details']['BT']->order_number,
			"amount"           => $totalInPaymentCurrency,
			"currency_code"    => $currency_code_3,
			/*
					 * 1 – L'adresse spécifiée dans les variables pré-remplies remplace l'adresse de livraison enregistrée auprès de PayPal.
					 * Le payeur voit l'adresse qui est transmise mais ne peut pas la modifier.
					 * Aucune adresse n'est affichée si l'adresse n'est pas valable
					 * (par exemple si des champs requis, tel que le pays, sont manquants) ou pas incluse.
					 * Valeurs autorisées : 0, 1. Valeur par défaut : 0
					 */
			"address_override" => isset($method->address_override) ? $method->address_override : 0, // 0 ??   Paypal does not allow your country of residence to ship to the country you wish to
			"first_name"       => $address->first_name,
			"last_name"        => $address->last_name,
			"address1"         => $address->address_1,
			"address2"         => isset($address->address_2) ? $address->address_2 : '',
			"zip"              => $address->zip,
			"city"             => $address->city,
			"state"            => isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID ($address->virtuemart_state_id) : '',
			"country"          => ShopFunctions::getCountryByID ($address->virtuemart_country_id, 'country_2_code'),
			"email"            => $order['details']['BT']->email,
			"night_phone_b"    => $address->phone_1,
			"return"           => JROUTE::_ (JURI::root () . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt ('Itemid')),
			// Keep this line, needed when testing
			//"return" => JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component'),
			"notify_url"       => JROUTE::_ (JURI::root () . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component'),
			"cancel_return"    => JROUTE::_ (JURI::root () . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt ('Itemid')),
			//"undefined_quantity" => "0",
			"ipn_test"         => $method->debug,
			"rm"               => '2', // the buyer’s browser is redirected to the return URL by using the POST method, and all payment variables are included
			//"pal" => "NRUBJXESJTY24",
			"image_url"        => JURI::root () . $vendor->images[0]->file_url,
			"no_shipping"      => isset($method->no_shipping) ? $method->no_shipping : 0,
			"no_note"          => "1");


		/*
			  $i = 1;
			  foreach ($cart->products as $key => $product) {
			  $post_variables["item_name_" . $i] = substr(strip_tags($product->product_name), 0, 127);
			  $post_variables["item_number_" . $i] = $i;
			  $post_variables["amount_" . $i] = $cart->pricesUnformatted[$key]['salesPrice'];
			  $post_variables["quantity_" . $i] = $product->quantity;
			  $i++;
			  }
			  if ($cart->pricesUnformatted ['shipmentValue']) {
			  $post_variables["item_name_" . $i] = JText::_('VMPAYMENT_PAYPAL_SHIPMENT_PRICE');
			  $post_variables["item_number_" . $i] = $i;
			  $post_variables["amount_" . $i] = $cart->pricesUnformatted ['shipmentValue'];
			  $post_variables["quantity_" . $i] = 1;
			  $i++;
			  }
			  if ($cart->pricesUnformatted ['paymentValue']) {
			  $post_variables["item_name_" . $i] = JText::_('VMPAYMENT_PAYPAL_PAYMENT_PRICE');
			  $post_variables["item_number_" . $i] = $i;
			  $post_variables["amount_" . $i] = $cart->pricesUnformatted ['paymentValue'];
			  $post_variables["quantity_" . $i] = 1;
			  $i++;
			  }
			  if (!empty($order->cart->coupon)) {
			  $post_variables["discount_amount_cart"] = $cart->pricesUnformatted['discountAmount'];
			  }
			 */

		// Prepare data that should be stored in the database
		$dbValues['order_number'] = $order['details']['BT']->order_number;
		$dbValues['payment_name'] = $this->renderPluginName ($method, $order);
		$dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
		$dbValues['paypal_custom'] = $return_context;
		$dbValues['cost_per_transaction'] = $method->cost_per_transaction;
		$dbValues['cost_percent_total'] = $method->cost_percent_total;
		$dbValues['payment_currency'] = $method->payment_currency;
		$dbValues['payment_order_total'] = $totalInPaymentCurrency;
		$dbValues['tax_id'] = $method->tax_id;
		$this->storePSPluginInternalData ($dbValues);

		$url = $this->_getPaypalUrlHttps ($method);

		// add spin image
		$html = '<html><head><title>Redirection</title></head><body><div style="margin: auto; text-align: center;">';
		$html .= '<form action="' . "https://" . $url . '" method="post" name="vm_paypal_form" >';
		$html .= '<input type="submit"  value="' . JText::_ ('VMPAYMENT_PAYPAL_REDIRECT_MESSAGE') . '" />';
		foreach ($post_variables as $name => $value) {
			$html .= '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars ($value) . '" />';
		}
		$html .= '</form></div>';
		$html .= ' <script type="text/javascript">';
		$html .= ' document.vm_paypal_form.submit();';
		$html .= ' </script></body></html>';

		// 	2 = don't delete the cart, don't send email and don't redirect
		$cart->_confirmDone = FALSE;
		$cart->_dataValidated = FALSE;
		$cart->setCartIntoSession ();
		JRequest::setVar ('html', $html);

		/*

			  $qstring = '?';
			  foreach ($post_variables AS $k => $v) {
			  $qstring .= ( empty($qstring) ? '' : '&')
			  . urlencode($k) . '=' . urlencode($v);
			  }
			  // we can display the logo, or do the redirect
			  $mainframe = JFactory::getApplication();
			  $mainframe->redirect("https://" . $url . $qstring);


			  return false; // don't delete the cart, don't send email
			 */
	}
コード例 #5
0
ファイル: avalara.php プロジェクト: sam-akopyan/hamradio
 private function fillValidateAvalaraAddress($calc, $vmadd)
 {
     if (!empty($vmadd)) {
         if (is_object($vmadd)) {
             $vmadd = get_object_vars($vmadd);
         }
         if (is_object($calc)) {
             $calc = get_object_vars($calc);
         }
         //avadebug('my $vmadd',$vmadd);
         //First country check
         if (empty($vmadd['virtuemart_country_id'])) {
             self::$validatedAddresses = FALSE;
             return self::$validatedAddresses;
         } else {
             if (empty($calc['avatax_virtuemart_country_id'])) {
                 vmError('AvaTax, please select countries, to validate. Use fallback for USA and Canada');
                 //But lets use a fallback
                 $calc['avatax_virtuemart_country_id'] = array('223', '38');
                 //For USA and Canada
             }
             if (!is_array($calc['avatax_virtuemart_country_id'])) {
                 //Suppress Warning
                 $calc['avatax_virtuemart_country_id'] = json_decode($calc['avatax_virtuemart_country_id'], true);
             }
             if (!in_array($vmadd['virtuemart_country_id'], $calc['avatax_virtuemart_country_id'])) {
                 avadebug('fillValidateAvalaraAddress not validated, country not set', $vmadd['virtuemart_country_id'], $calc['avatax_virtuemart_country_id']);
                 self::$validatedAddresses = FALSE;
                 return self::$validatedAddresses;
             }
         }
         if (!class_exists('Address')) {
             require VMAVALARA_CLASS_PATH . DS . 'Address.class.php';
         }
         $address = new Address();
         if (isset($vmadd['address_1'])) {
             $address->setLine1($vmadd['address_1']);
         }
         if (isset($vmadd['address_2'])) {
             $address->setLine2($vmadd['address_2']);
         }
         if (isset($vmadd['city'])) {
             $address->setCity($vmadd['city']);
         }
         if (isset($vmadd['virtuemart_country_id'])) {
             $vmadd['country'] = ShopFunctions::getCountryByID($vmadd['virtuemart_country_id'], 'country_2_code');
             if (isset($vmadd['country'])) {
                 $address->setCountry($vmadd['country']);
             }
         }
         if (isset($vmadd['virtuemart_state_id'])) {
             $vmadd['state'] = ShopFunctions::getStateByID($vmadd['virtuemart_state_id'], 'state_2_code');
             if (isset($vmadd['state'])) {
                 $address->setRegion($vmadd['state']);
             }
         }
         if (isset($vmadd['zip'])) {
             $address->setPostalCode($vmadd['zip']);
         }
         $hash = md5(implode($vmadd, ','));
         $session = JFactory::getSession();
         $validatedAddress = $session->get('vm_avatax_address_checked.' . $hash, FALSE, 'vm');
         if (!$validatedAddress) {
             $config = $this->newATConfig($calc);
             if (!class_exists('AddressServiceSoap')) {
                 require VMAVALARA_CLASS_PATH . DS . 'AddressServiceSoap.class.php';
             }
             $client = new AddressServiceSoap($this->_connectionType, $config);
             if (!class_exists('SeverityLevel')) {
                 require VMAVALARA_CLASS_PATH . DS . 'SeverityLevel.class.php';
             }
             if (!class_exists('Message')) {
                 require VMAVALARA_CLASS_PATH . DS . 'Message.class.php';
             }
             //if($calc->vAddress==0){
             /*	if(isset($vmadd['country']) and $vmadd['country']!= 'US' and $vmadd['country']!= 'CA'){
             
             					self::$validatedAddresses = array($address);
             					return self::$validatedAddresses;
             				}*/
             $address->Coordinates = 1;
             $address->Taxability = TRUE;
             $textCase = TextCase::$Mixed;
             $coordinates = 1;
             if (!class_exists('ValidateResult')) {
                 require VMAVALARA_CLASS_PATH . DS . 'ValidateResult.class.php';
             }
             if (!class_exists('ValidateRequest')) {
                 require VMAVALARA_CLASS_PATH . DS . 'ValidateRequest.class.php';
             }
             if (!class_exists('ValidAddress')) {
                 require VMAVALARA_CLASS_PATH . DS . 'ValidAddress.class.php';
             }
             //TODO add customer code //shopper_number
             try {
                 $request = new ValidateRequest($address, $textCase ? $textCase : TextCase::$Default, $coordinates);
                 vmSetStartTime('avaValAd');
                 //avadebug('my request for validate address ',$request);
                 $result = $client->Validate($request);
                 vmTime('Avatax validate Address', 'avaValAd');
                 //avadebug('Validate ResultCode is: '. $result->getResultCode());;
                 if ($result->getResultCode() != SeverityLevel::$Success) {
                     foreach ($result->getMessages() as $msg) {
                         avadebug('fillValidateAvalaraAddress ' . $msg->getName() . ": " . $msg->getSummary() . "\n");
                     }
                 } else {
                     self::$validatedAddresses = $result->getvalidAddresses();
                     $session->set('vm_avatax_address_checked.' . $hash, TRUE, 'vm');
                 }
             } catch (SoapFault $exception) {
                 $msg = "Exception: fillValidateAvalaraAddress ";
                 if ($exception) {
                     $msg .= $exception->faultstring;
                 }
                 $msg .= "\n";
                 $msg .= $client->__getLastRequest() . "\n";
                 $msg .= $client->__getLastResponse() . "\n";
                 vmError($msg);
             }
         } else {
             self::$validatedAddresses[] = $address;
         }
         //then for BT and/or $cart->STsameAsBT
     }
     if (empty(self::$validatedAddresses)) {
         self::$validatedAddresses = FALSE;
     }
     return self::$validatedAddresses;
 }
コード例 #6
0
 function initPostVariables($payment_type)
 {
     $address = isset($this->order['details']['ST']) ? $this->order['details']['ST'] : $this->order['details']['BT'];
     $post_variables = array();
     $post_variables['cmd'] = '_ext-enter';
     $post_variables['redirect_cmd'] = $payment_type;
     $post_variables['paymentaction'] = strtolower($this->_method->payment_action);
     $post_variables['upload'] = '1';
     $post_variables['business'] = $this->merchant_email;
     //Email address or account ID of the payment recipient (i.e., the merchant).
     $post_variables['receiver_email'] = $this->merchant_email;
     //Primary email address of the payment recipient (i.e., the merchant
     $post_variables['order_number'] = $this->order['details']['BT']->order_number;
     $post_variables['invoice'] = $this->order['details']['BT']->order_number;
     $post_variables['custom'] = $this->context;
     $post_variables['currency_code'] = $this->currency_code_3;
     if ($payment_type == '_xclick') {
         $post_variables['address_override'] = $this->_method->address_override;
         // 0 ??   Paypal does not allow your country of residence to ship to the country you wish to
     }
     $post_variables['first_name'] = $address->first_name;
     $post_variables['last_name'] = $address->last_name;
     $post_variables['address1'] = $address->address_1;
     $post_variables['address2'] = isset($address->address_2) ? $address->address_2 : '';
     $post_variables['zip'] = $address->zip;
     $post_variables['city'] = $address->city;
     $post_variables['state'] = isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id, 'state_2_code') : '';
     $post_variables['country'] = ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code');
     $post_variables['email'] = $this->order['details']['BT']->email;
     $post_variables['night_phone_b'] = $address->phone_1;
     $post_variables['return'] = JURI::root() . 'index.php?option=com_virtuemart&view=vmplg&task=pluginresponsereceived&on=' . $this->order['details']['BT']->order_number . '&pm=' . $this->order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . vRequest::getInt('Itemid') . '&lang=' . vRequest::getCmd('lang', '');
     //Keep this line, needed when testing
     //$post_variables['return'] 		= JRoute::_(JURI::root().'index.php?option=com_virtuemart&view=vmplg&task=notify&tmpl=component'),
     $post_variables['notify_url'] = JURI::root() . 'index.php?option=com_virtuemart&view=vmplg&task=notify&tmpl=component' . '&lang=' . vRequest::getCmd('lang', '');
     $post_variables['cancel_return'] = JURI::root() . 'index.php?option=com_virtuemart&view=vmplg&task=pluginUserPaymentCancel&on=' . $this->order['details']['BT']->order_number . '&pm=' . $this->order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . vRequest::getInt('Itemid') . '&lang=' . vRequest::getCmd('lang', '');
     //$post_variables['undefined_quantity'] = "0";
     //$post_variables['test_ipn'] = $this->_method->debug;
     $post_variables['rm'] = '2';
     // the buyer’s browser is redirected to the return URL by using the POST method, and all payment variables are included
     // todo: check when in subdirectories
     // todo add vendor image
     //$post_variables['image_url'] 			= JURI::root() . $vendor->images[0]->file_url;
     $post_variables['bn'] = self::BNCODE;
     $post_variables['no_shipping'] = $this->_method->no_shipping;
     $post_variables['no_note'] = "1";
     if (empty($this->_method->headerimg) or $this->_method->headerimg == -1) {
         $post_variables['image_url'] = $this->getLogoImage();
     } else {
         $post_variables['cpp_header_image'] = JURI::base() . 'images/stories/virtuemart/payment/' . $this->_method->headerimg;
     }
     /*
     * The HTML hex code for your principal identifying color.
     * Valid only for Buy Now and Add to Cart buttons and the Cart Upload command.
     * Not used with Subscribe, Donate, or Buy Gift Certificate buttons.
     */
     if ($this->_method->bordercolor) {
         $post_variables['cpp_cart_border_color'] = str_replace('#', '', strtoupper($this->_method->bordercolor));
     }
     // TODO Check that paramterer
     /*
      * cpp_payflow_color The background color for the checkout page below the header.
      * Deprecated for Buy Now and Add to Cart buttons and the Cart Upload command
      *
      */
     //	$post_variables['cpp_payflow_color'] = 'ff0033';
     return $post_variables;
 }
コード例 #7
0
 function addShipTo(&$post_variables)
 {
     $addressST = isset($this->order['details']['ST']) ? $this->order['details']['ST'] : $this->order['details']['BT'];
     //Ship To
     $shiptoname = $this->getShipToName(isset($addressST->first_name) ? $addressST->first_name : '', isset($addressST->last_name) ? $addressST->last_name : '', 50);
     $post_variables['SHIPTONAME'] = $shiptoname;
     $post_variables['SHIPTOSTREET'] = isset($addressST->address_1) ? $this->truncate($addressST->address_1, 60) : '';
     $post_variables['SHIPTOCITY'] = isset($addressST->city) ? $this->truncate($addressST->city, 40) : '';
     $post_variables['SHIPTOZIP'] = isset($addressST->zip) ? $this->truncate($addressST->zip, 40) : '';
     $post_variables['SHIPTOSTATE'] = isset($addressST->virtuemart_state_id) ? ShopFunctions::getStateByID($addressST->virtuemart_state_id, 'state_2_code') : '';
     $post_variables['SHIPTOCOUNTRYCODE'] = ShopFunctions::getCountryByID($addressST->virtuemart_country_id, 'country_2_code');
 }
コード例 #8
0
 function retornaHtmlPagamento($order, $method, $redir)
 {
     $lang = JFactory::getLanguage();
     $filename = 'com_virtuemart';
     $lang->load($filename, JPATH_ADMINISTRATOR);
     $vendorId = 0;
     if (isset($order["details"]["ST"])) {
         $endereco = "ST";
     } else {
         $endereco = "BT";
     }
     $dbValues = array();
     $dbValues['payment_name'] = $this->renderPluginName($method);
     $html = '<table>' . "\n";
     $html .= $this->getHtmlRow('STANDARD_PAYMENT_INFO', $dbValues['payment_name']);
     if (!empty($payment_info)) {
         $lang =& JFactory::getLanguage();
         if ($lang->hasKey($method->payment_info)) {
             $payment_info = JTExt::_($method->payment_info);
         } else {
             $payment_info = $method->payment_info;
         }
         $html .= $this->getHtmlRow('STANDARD_PAYMENTINFO', $payment_info);
     }
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->virtuemart_vendor_id);
     $html .= $this->getHtmlRow('STANDARD_ORDER_NUMBER', $order['details']['BT']->order_number);
     $html .= $this->getHtmlRow('STANDARD_AMOUNT', $currency->priceDisplay($order['details']['BT']->order_total));
     $html .= '</table>' . "\n";
     //buscar forma de envio
     /*
     $db = &JFactory::getDBO();
     $q = 'SELECT `shipment_element` FROM `#__virtuemart_shipmentmethods` WHERE `virtuemart_shipmentmethod_id`="' . $order["details"][$endereco]->virtuemart_shipmentmethod_id . '" ';
     $db->setQuery($q);
     $envio = $db->loadResult();
     
     if (stripos($envio, "sedex") === false && stripos($envio, "pac") === false) {
         $tipo_frete = $method->tipo_frete ? 'SD' : 'EN'; // Encomenda Pac ou Sedex
     } elseif (stripos($envio, "sedex") !== false) {
         $tipo_frete = "SD";
     } else {
         $tipo_frete = "EN";
     }
     */
     // configuração dos campos
     $campo_complemento = $method->campo_complemento;
     $campo_numero = $method->campo_numero;
     $html .= '<form id="frm_pagseguro" action="https://pagseguro.uol.com.br/v2/checkout/payment.html" method="post" >    ';
     $html .= '  <input type="hidden" name="receiverEmail" value="' . $method->email_cobranca . '"  />
                 <input type="hidden" name="currency" value="BRL"  />
                 <input type="hidden" name="tipo" value="CP"  />
                 <input type="hidden" name="encoding" value="utf-8"  />';
     if (isset($order["details"][$endereco]) and isset($order["details"][$endereco]->{$campo_complemento})) {
         $complemento = $order["details"][$endereco]->{$campo_complemento};
     } else {
         $complemento = '';
     }
     if (isset($order["details"][$endereco]) and isset($order["details"][$endereco]->{$campo_numero})) {
         $numero = $order["details"][$endereco]->{$campo_numero};
     } else {
         $numero = '';
     }
     $html .= '<input name="reference" type="hidden" value="' . ($order["details"][$endereco]->order_number != '' ? $order["details"][$endereco]->order_number : $order["details"]["BT"]->order_number) . '">';
     $html .= '<input type="hidden" name="senderName" value="' . ($order["details"][$endereco]->first_name != '' ? $order["details"][$endereco]->first_name : $order["details"]["BT"]->first_name) . ' ' . ($order["details"][$endereco]->last_name != '' ? $order["details"][$endereco]->last_name : $order["details"]["BT"]->last_name) . '"  />
     <input type="hidden" name="shippingType" value="' . $method->tipo_frete . '"  />
     <input type="hidden" name="shippingAddressPostalCode" value="' . ($order["details"][$endereco]->zip != '' ? $order["details"][$endereco]->zip : $order["details"]["BT"]->zip) . '"  />
     <input type="hidden" name="shippingAddressStreet" value="' . ($order["details"][$endereco]->address_1 != '' ? $order["details"][$endereco]->address_1 : $order["details"]["BT"]->address_1) . ' ' . ($order["details"][$endereco]->address_2 != '' ? $order["details"][$endereco]->address_2 : $order["details"]["BT"]->address_2) . '"  />
     <input type="hidden" name="shippingAddressNumber" value="' . $numero . '"  />
     <input type="hidden" name="shippingAddressComplement" value="' . $complemento . '"  />
     <input type="hidden" name="shippingAddressCity" value="' . ($order["details"][$endereco]->city != '' ? $order["details"][$endereco]->city : $order["details"]["BT"]->city) . '"  />';
     $cod_estado = !empty($order["details"][$endereco]->virtuemart_state_id) ? $order["details"][$endereco]->virtuemart_state_id : $order["details"]["BT"]->virtuemart_state_id;
     $estado = ShopFunctions::getStateByID($cod_estado, "state_2_code");
     $html .= '
     <input type="hidden" name="shippingAddressState" value="' . $estado . '"  />
     <input type="hidden" name="shippingAddressCountry" value="BRA"  />
     <input type="hidden" name="senderAreaCode" value=""  />
     <input type="hidden" name="senderPhone" value="' . ($order["details"][$endereco]->phone_1 != '' ? $order["details"][$endereco]->phone_1 : $order["details"]["BT"]->phone_1) . '"  />
     <input type="hidden" name="senderEmail" value="' . ($order["details"][$endereco]->email != '' ? $order["details"][$endereco]->email : $order["details"]["BT"]->email) . '"  />';
     // total do frete
     // configurado para passar o frete do total da compra
     if (!empty($order["details"]["BT"]->order_shipment)) {
         $html .= '<input type="hidden" name="itemShippingCost1" value="' . number_format(round($order["details"][$endereco]->order_shipment != '' ? $order["details"][$endereco]->order_shipment : $order["details"]["BT"]->order_shipment, 2), 2, '.', '') . '">';
     } else {
         $html .= '<input type="hidden" name="itemShippingCost1" value="0">';
     }
     // desconto do pedido
     /*
     $order_discount = (float)$order["details"]["BT"]->order_discount;
     if (empty($order_discount) && (!empty($order["details"]["BT"]->coupon_discount))) {
         $order_discount = (float)$order["details"]["BT"]->coupon_discount;
     }
     
     $order_discount = (-1)*abs($order_discount);
     if (!empty($order_discount)) {
        $html .= '<input type="hidden" name="extraAmount" value="'.number_format($order_discount,2,'.','').'" />'; 
     }
     */
     // Cupom de Desconto
     $desconto_pedido = $order["details"]['BT']->coupon_discount;
     //$desconto_pedido*= -1;
     $html .= '<input type="hidden" name="extras" value="' . number_format($desconto_pedido, 2, ",", "") . '" />';
     $order_subtotal = $order['details']['BT']->order_subtotal;
     if (!class_exists('VirtueMartModelCustomfields')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'customfields.php';
     }
     if (!class_exists('VirtueMartModelProduct')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'product.php';
     }
     $i = 0;
     $product_model = VmModel::getModel('product');
     foreach ($order['items'] as $p) {
         $i++;
         $valor_produto = $p->product_final_price;
         // desconto do pedido
         $valor_item = $valor_produto;
         $pr = $product_model->getProduct($p->virtuemart_product_id);
         $product_attribute = strip_tags(VirtueMartModelCustomfields::CustomsFieldOrderDisplay($p, 'FE'));
         $html .= '<input type="hidden" name="itemId' . $i . '" value="' . $p->virtuemart_order_item_id . '">
             <input type="hidden" name="itemDescription' . $i . '" value="' . $p->order_item_name . '">
             <input type="hidden" name="itemQuantity' . $i . '" value="' . $p->product_quantity . '">
             <input type="hidden" name="itemAmount' . $i . '" value="' . number_format(round($p->product_final_price, 2), 2, '.', '') . '">
             <input type="hidden" name="itemWeight' . $i . '" value="1">';
         /*  <input type="hidden" name="itemWeight' . $i . '" value="' .round( ShopFunctions::convertWeigthUnit($pr->product_weight, $pr->product_weight_uom, "GR"),2) . '"> */
     }
     $url = JURI::root();
     $url_lib = $url . DS . 'plugins' . DS . 'vmpayment' . DS . 'pagseguro_virtuemartbrasil' . DS;
     $url_imagem_pagamento = $url_lib . 'imagens' . DS . 'pagseguro.gif';
     // segundos para redirecionar para o Pagseguro
     if ($redir) {
         // segundos para redirecionar para o Pagseguro
         $segundos = $method->segundos_redirecionar;
         $html .= '<br/><br/>Você ser&aacute; direcionado para a tela de pagamento em ' . $segundos . ' segundo(s), ou então clique logo abaixo:<br />';
         $html .= '<script>setTimeout(\'document.getElementById("frm_pagseguro").submit();\',' . $segundos . '000);</script>';
     }
     $html .= '<div align="center"><br /><input type="image" value="Clique aqui para efetuar o pagamento" src="' . $url_imagem_pagamento . '" /></div>';
     $html .= '</form>';
     return $html;
 }
コード例 #9
0
ファイル: payzen.php プロジェクト: xenten/swift-kanban
	/**
	 * Prepare data and redirect to PayZen payment platform
	 *
	 * @param string $order_number
	 * @param object $orderData
	 * @param string $return_context the session id
	 * @param string $html the form to display
	 * @param bool   $new_status false if it should not be changed, otherwise new staus
	 * @return NULL
	 */
	function plgVmConfirmedOrder ($cart, $order) {

		if (!($method = $this->getVmPluginMethod ($order['details']['BT']->virtuemart_paymentmethod_id))) {
			return NULL; // Another method was selected, do nothing
		}
		if (!$this->selectedThisElement ($method->payment_element)) {
			return FALSE;
		}

		$this->_debug = $method->debug; // enable debug
		$session = JFactory::getSession ();
		$return_context = $session->getId ();

		$this->logInfo ('plgVmOnConfirmedOrderGetPaymentForm -- order number: ' . $order['details']['BT']->order_number, 'message');

		if (!class_exists ('VadsApi')) {
			require(JPATH_VMPAYMENTPLUGIN . DS . 'payzen' . DS . 'payzen_api.php');
		}

		$api = new VadsApi('UTF-8');

		// set config parameters
		$paramNames = array(
			'platform_url', 'key_test', 'key_prod', 'capture_delay', 'ctx_mode', 'site_id',
			'validation_mode', 'redirect_enabled', 'redirect_success_timeout', 'redirect_success_message',
			'redirect_error_timeout', 'redirect_error_message', 'return_mode'
		);
		foreach ($paramNames as $name) {
			$api->set ($name, $method->$name);
		}

		// Set urls
		$url_return = JROUTE::_ (JURI::root () . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived');
		$uri = JURI::getInstance ($url_return);
		//$uri->setVar('pelement', $this->payment_element);
		$uri->setVar ('pm', $order['details']['BT']->virtuemart_paymentmethod_id);
		$uri->setVar ('Itemid', JRequest::getInt ('Itemid'));
		$api->set ('url_return', $uri->toString ());

		$url_success = JROUTE::_ (JURI::root () . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived');
		$uri = JURI::getInstance ($url_success);
		//$uri->setVar('pelement', $this->payment_element);
		$uri->setVar ('Itemid', JRequest::getInt ('Itemid'));
		$uri->setVar ('pm', $order['details']['BT']->virtuemart_paymentmethod_id);
		$api->set ('url_success', $uri->toString ());

		$url_cancel = JROUTE::_ (JURI::root () . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel');
		$uri = JURI::getInstance ($url_cancel);
		$uri->setVar ('on', $order['details']['BT']->order_number);
		$uri->setVar ('pm', $order['details']['BT']->virtuemart_paymentmethod_id);
		$uri->setVar ('Itemid', JRequest::getInt ('Itemid'));
		$api->set ('url_cancel', $uri->toString ());

		// Set the language code
		$lang = JFactory::getLanguage ();
		$lang->load ('plg_vmpayment_' . $this->_name, JPATH_ADMINISTRATOR);

		$tag = substr ($lang->get ('tag'), 0, 2);
		$language = in_array ($tag, $api->getSupportedLanguages ()) ? $tag : ($method->language ? $method->language : 'fr');
		$api->set ('language', $language);

		// Set currency
		if (!class_exists ('VirtueMartModelCurrency')) {
			require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php');
		}
		$currencyModel = new VirtueMartModelCurrency();
		$currencyObj = $currencyModel->getCurrency ($order['details']['BT']->order_currency);

		$currency = $api->findCurrencyByNumCode ($currencyObj->currency_numeric_code);
		if ($currency == NULL) {
			$this->logInfo ('plgVmOnConfirmedOrderGetPaymentForm -- Could not find currency numeric code for currency : ' . $currencyObj->currency_numeric_code, 'error');
			vmInfo (JText::_ ('VMPAYMENT_' . $this->_name . '_CURRENCY_NOT_SUPPORTED'));
			return NULL;
		}
		$api->set ('currency', $currency->num);

		// payment_cards may be one value or array
		$cards = $method->payment_cards;
		$cards = !is_array ($cards) ? $cards : (in_array ("", $cards) ? "" : implode (";", $cards));
		$api->set ('payment_cards', $cards);

		// available_languages may be one value or array
		$available_languages = $method->available_languages;
		$available_languages = !is_array ($available_languages) ? $available_languages : (in_array ("", $available_languages) ? "" : implode (";", $available_languages));
		$api->set ('available_languages', $available_languages);

		$api->set ('contrib', 'VirtueMart2.0.0_1.2');

		// Set customer info
		// $usr = JFactory::getUser();
		$usrBT = $order['details']['BT'];
		$usrST = ((isset($order['details']['ST'])) ? $order['details']['ST'] : $order['details']['BT']);

		$api->set ('cust_email', $usrBT->email);
		// $api->set('cust_id', '');
		$api->set ('cust_title', @$usrBT->title);
		$api->set ('cust_first_name', $usrBT->first_name);
		$api->set ('cust_last_name', $usrBT->last_name);
		$api->set ('cust_address', $usrBT->address_1 . ' ' . $usrBT->address_2);
		$api->set ('cust_zip', $usrBT->zip);
		$api->set ('cust_city', $usrBT->city);
		$api->set ('cust_state', @ShopFunctions::getStateByID ($usrBT->virtuemart_state_id));
		$api->set ('cust_country', @ShopFunctions::getCountryByID ($usrBT->virtuemart_country_id, 'country_2_code'));
		$api->set ('cust_phone', $usrBT->phone_1);
		$api->set ('cust_cell_phone', $usrBT->phone_2);

		$api->set ('ship_to_first_name', $usrST->first_name);
		$api->set ('ship_to_last_name', $usrST->last_name);
		$api->set ('ship_to_city', $usrST->city);
		$api->set ('ship_to_street', $usrST->address_1);
		$api->set ('ship_to_street2', $usrST->address_2);
		$api->set ('ship_to_state', @ShopFunctions::getStateByID ($usrST->virtuemart_state_id));
		$api->set ('ship_to_country', @ShopFunctions::getCountryByID ($usrST->virtuemart_country_id, 'country_2_code'));
		$api->set ('ship_to_phone_num', $usrST->phone_1);
		$api->set ('ship_to_zip', $usrST->zip);

		// Set order_id
		$api->set ('order_id', $order['details']['BT']->order_number);

		// Set the amount to pay
		$api->set ('amount', round ($order['details']['BT']->order_total * 100));

		// Prepare data that should be stored in the database
		$dbValues['order_number'] = $order['details']['BT']->order_number;
		$dbValues['payment_name'] = $this->renderPluginName ($method, $order);
		$dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
		$dbValues[$this->_name . '_custom'] = $return_context;
		$this->storePSPluginInternalData ($dbValues);

		$this->logInfo ('plgVmOnConfirmedOrderGetPaymentForm -- payment data saved to table ' . $this->_tablename, 'message');

		// echo the redirect form
		$form = '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Redirection</title></head><body><div style="margin: auto; text-align: center;">';
		$form .= '<p>' . JText::_ ('VMPAYMENT_' . $this->_name . '_PLEASE_WAIT') . '</p>';
		$form .= '<p>' . JText::_ ('VMPAYMENT_' . $this->_name . '_CLICK_BUTTON_IF_NOT_REDIRECTED') . '</p>';
		$form .= '<form action="' . $api->platformUrl . '" method="POST" name="vm_' . $this->_name . '_form" >';
		$form .= '<input type="image" name="submit" src="' . JURI::base (TRUE) . '/images/stories/virtuemart/payment/' . $this->_name . '.jpg" alt="' . JText::_ ('VMPAYMENT_' . $this->_name . '_BTN_ALT') . '" title="' . JText::_ ('VMPAYMENT_PAYZEN_BTN_ALT') . '"/>';
		$form .= $api->getRequestFieldsHtml ();
		$form .= '</form></div>';
		$form .= '<script type="text/javascript">document.forms[0].submit();</script></body></html>';

		$this->logInfo ('plgVmOnConfirmedOrderGetPaymentForm -- user redirected to ' . $this->_name, 'message');

		echo $form;

		$cart->_confirmDone = FALSE;
		$cart->_dataValidated = FALSE;
		$cart->setCartIntoSession ();
		die(); // not save order, not send mail, do redirect
	}
コード例 #10
0
 function plgVmConfirmedOrder($cart, $order, $payment_method = '')
 {
     if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
     }
     // Another method was selected, do nothing
     if (!$this->selectedThisElement($method->payment_element)) {
         return FALSE;
     }
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $this->logInfo('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     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';
     }
     $usrBT = $order['details']['BT'];
     $address = isset($order['details']['ST']) ? $order['details']['ST'] : $order['details']['BT'];
     if (!class_exists('TableVendors')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'tables' . DS . 'vendors.php';
     }
     $vendorModel = VmModel::getModel('Vendor');
     $vendorModel->setId(1);
     $vendor = $vendorModel->getVendor();
     $vendorModel->addImages($vendor, 1);
     $this->getPaymentCurrency($method);
     $q = 'SELECT `currency_code_3` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $method->payment_currency . '" ';
     $db = JFactory::getDBO();
     $db->setQuery($q);
     $currency_code_3 = $db->loadResult();
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $method->payment_currency);
     $cartCurrency = CurrencyDisplay::getInstance($cart->pricesCurrency);
     if ($totalInPaymentCurrency['value'] <= 0) {
         vmInfo(JText::_('VMPAYMENT_MONEYBOOKERS_PAYMENT_AMOUNT_INCORRECT'));
         return FALSE;
     }
     $merchant_email = $method->pay_to_email;
     if (empty($merchant_email)) {
         vmInfo(JText::_('VMPAYMENT_MONEYBOOKERS_MERCHANT_EMAIL_NOT_SET'));
         return FALSE;
     }
     $lang = JFactory::getLanguage();
     $tag = substr($lang->get('tag'), 0, 2);
     $post_variables = array('pay_to_email' => $merchant_email, 'pay_from_email' => $address->email, 'payment_methods' => $payment_method, 'recipient_description' => $vendorModel->getVendorName(), 'transaction_id' => $order['details']['BT']->order_number, 'return_url' => JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid')), 'cancel_url' => JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . JRequest::getInt('Itemid')), 'status_url' => JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component'), 'platform' => '21477272', 'hide_login' => $method->hide_login, 'prepare_only' => 1, 'logo_url' => $method->logourl, 'language' => strtoupper($tag), "firstname" => $address->first_name, "lastname" => $address->last_name, "address" => $address->address_1, "address2" => isset($address->address_2) ? $address->address_2 : '', "phone_number" => $address->phone_1, "postal_code" => $address->zip, "city" => $address->city, "state" => isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id, 'state_2_code') : '', "country" => ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_3_code'), 'amount' => $totalInPaymentCurrency['value'], 'currency' => $currency_code_3, 'detail1_description' => JText::_('VMPAYMENT_MONEYBOOKERS_ORDER_NUMBER') . ': ', 'detail1_text' => $order['details']['BT']->order_number);
     // Prepare data that should be stored in the database
     $dbValues['user_session'] = $return_context;
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = $this->renderPluginName($method, $order);
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['cost_per_transaction'] = $method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $method->cost_percent_total;
     $dbValues['payment_currency'] = $method->payment_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['tax_id'] = $method->tax_id;
     $this->storePSPluginInternalData($dbValues);
     $content = http_build_query($post_variables);
     $url = $this->_getMoneybookersURL($method);
     $header = "POST /app/payment.pl HTTP/1.1\r\n";
     $header .= "Host: {$url}\r\n";
     $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
     $header .= "Content-Length: " . strlen($content) . "\r\n\r\n";
     $fps = fsockopen('ssl://' . $url, 443, $errno, $errstr, 10);
     // timeout applies only to connecting not for I/O
     $sid = '';
     if (!$fps || !stream_set_blocking($fps, 0)) {
         $this->sendEmailToVendorAndAdmins("Error with Moneybookers: ", JText::sprintf('VMPAYMENT_MONEYBOOKERS_ERROR_POSTING_IPN', $errstr, $errno));
         $this->logInfo('Process IPN ' . JText::sprintf('VMPAYMENT_MONEYBOOKERS_ERROR_POSTING_IPN', $errstr, $errno), 'message');
         vmInfo(JText::_('VMPAYMENT_MONEYBOOKERS_DISPLAY_GWERROR'));
         return NULL;
     } else {
         fwrite($fps, $header);
         fwrite($fps, $content);
         stream_set_timeout($fps, 10);
         $read = array($fps);
         $write = $except = NULL;
         $msg = $rbuff = '';
         if (stream_select($read, $write, $except, 10)) {
             $rbuff = fread($fps, 1024);
             $msg .= $rbuff;
         }
         $response = $this->_parse_response($msg);
         if (!count($response)) {
             $this->logInfo('Process IPN (empty or bad response) ' . $msg, 'message');
             vmInfo(JText::_('VMPAYMENT_MONEYBOOKERS_DISPLAY_GWERROR'));
             return NULL;
         }
         $sid = $response[0];
         $this->logInfo($response[0], 'message');
     }
     fclose($fps);
     $height = $method->hide_login ? 720 : 500;
     $html = '<html><head><title></title><script type="text/javascript">
             jQuery(document).ready(function () {
                 jQuery(\'#main h3\').css("display", "none");
             });
             </script></head><body>';
     $html .= '<iframe src="https://' . $this->_getMoneybookersURL($method) . '/app/payment.pl?sid=' . $sid . '" scrolling="yes" style="x-overflow: none;"
             frameborder="0" height="' . (string) $height . 'px" width="650px"></iframe>';
     $cart->_confirmDone = FALSE;
     $cart->_dataValidated = FALSE;
     $cart->setCartIntoSession();
     JRequest::setVar('html', $html);
 }
コード例 #11
0
 function plgVmConfirmedOrder($cart, $order)
 {
     if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return null;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return false;
     }
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $this->logInfo('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     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';
     }
     //$usr = JFactory::getUser();
     $new_status = '';
     $usrBT = $order['details']['BT'];
     $address = isset($order['details']['ST']) ? $order['details']['ST'] : $order['details']['BT'];
     if (!class_exists('TableVendors')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'table' . DS . 'vendors.php';
     }
     $vendorModel = VmModel::getModel('Vendor');
     $vendorModel->setId(1);
     $vendor = $vendorModel->getVendor();
     $vendorModel->addImages($vendor, 1);
     /*$this->getPaymentCurrency($method);
     		$q = 'SELECT `currency_code_3` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $method->payment_currency . '" ';
     		$db = JFactory::getDBO();
     		$db->setQuery($q);
     		$currency_code_3 = $db->loadResult();
     	
     		$paymentCurrency = CurrencyDisplay::getInstance($method->payment_currency);
     		$totalInPaymentCurrency = round($paymentCurrency->convertCurrencyTo($method->payment_currency, $order['details']['BT']->order_total, false), 2);
     		$cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     		if ($totalInPaymentCurrency <= 0) {
     		     vmInfo(JText::_('VMPAYMENT_PAYU_PAYMENT_AMOUNT_INCORRECT'));
     			    return false;
     		}*/
     $salt = $this->_getMerchantSalt($method);
     if (empty($salt)) {
         vmInfo(JText::_('VMPAYMENT_PAYU_MERCHANT_SALT_NOT_SET'));
         return false;
     }
     $merchentkey = $method->merchantkey;
     $mode = $method->mode;
     $return_url = JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&DR={DR}');
     $description = $method->description;
     $ship_address = $address->address_1;
     $txnid = $order['details']['BT']->order_number;
     $hashSequence = $merchentkey . "|" . $txnid . "|" . (int) $order['details']['BT']->order_total . "|" . JText::_('VMPAYMENT__ORDER_NUMBER') . ': ' . $order['details']['BT']->order_number . "|" . $order['details']['BT']->first_name . "|" . $order['details']['BT']->email . "|" . $udf1 . "|" . $udf2 . "|" . $udf3 . "|" . $udf4 . "|" . $udf5 . "||||||" . $salt;
     $secure_hash = strtolower(hash('sha512', $hashSequence));
     //echo "<pre>";print_r($method);echo "</pre>";
     if (isset($address->address_2)) {
         $ship_address .= ", " . $address->address_2;
     }
     $post_variables = array("key" => $merchentkey, "txnid" => $txnid, "reference_no" => $order['details']['BT']->order_number, "productinfo" => JText::_('VMPAYMENT__ORDER_NUMBER') . ': ' . $order['details']['BT']->order_number, "amount" => (int) $order['details']['BT']->order_total, "mode" => $mode, "firstname" => $order['details']['BT']->first_name, "lastname" => $order['details']['BT']->last_name, "address" => $order['details']['BT']->address_1 . " " . $order['details']['BT']->address_2, "city" => $order['details']['BT']->city, "state" => isset($order['details']['BT']->virtuemart_state_id) ? ShopFunctions::getStateByID($order['details']['BT']->virtuemart_state_id) : '', "country" => ShopFunctions::getCountryByID($order['details']['BT']->virtuemart_country_id, 'country_2_code'), "zipcode" => $order['details']['BT']->zip, "phone" => $order['details']['BT']->phone_1, "email" => $order['details']['BT']->email, "ship_name" => $address->first_name . " " . $address->last_name, "ship_address" => $ship_address, "ship_zipcode" => $address->zip, "ship_city" => $address->city, "ship_state" => isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id) : '', "ship_country" => ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'), "ship_phone" => $address->phone_1, "hash" => $secure_hash, "surl" => $return_url, "furl" => $return_url, "udf1" => "", "udf2" => "", "udf3" => "", "udf4" => "", "udf5" => "");
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = $this->renderPluginName($method, $order);
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['description'] = '$description';
     //$description;
     $dbValues['payu_custom'] = $return_context;
     $dbValues['billing_currency'] = $method->payment_currency;
     $dbValues['amount'] = (int) $totalInPaymentCurrency;
     $this->storePSPluginInternalData($dbValues);
     $url = $this->_getPAYUUrlHttps($method);
     // add spin image
     $html = '<html><head><title>Redirection</title></head><body><div style="margin: auto; text-align: center;">';
     $html .= '<form action="' . "https://" . $url . '" method="post" name="vm_payu_form" >';
     $html .= '<input type="submit"  value="' . JText::_('VMPAYMENT_PAYU_REDIRECT_MESSAGE') . '" />';
     foreach ($post_variables as $name => $value) {
         $html .= '<input type="hidden" style="" name="' . $name . '" value="' . htmlspecialchars($value) . '" />';
     }
     $html .= '</form></div>';
     $html .= ' <script type="text/javascript">';
     $html .= ' document.vm_payu_form.submit();';
     $html .= ' </script></body></html>';
     // 	2 = don't delete the cart, don't send email and don't redirect
     $cart->_confirmDone = false;
     $cart->_dataValidated = false;
     $cart->setCartIntoSession();
     JRequest::setVar('html', $html);
 }
コード例 #12
0
ファイル: avalara.php プロジェクト: romuland/khparts
 private function fillValidateAvalaraAddress($calc)
 {
     if (!isset(self::$validatedAddresses)) {
         $vmadd = $this->getShopperData();
         if (!empty($vmadd)) {
             $config = $this->newATConfig($calc);
             if (!class_exists('AddressServiceSoap')) {
                 require VMAVALARA_CLASS_PATH . DS . 'AddressServiceSoap.class.php';
             }
             $client = new AddressServiceSoap('Development', $config);
             if (!class_exists('Address')) {
                 require VMAVALARA_CLASS_PATH . DS . 'Address.class.php';
             }
             $address = new Address();
             if (isset($vmadd['address_1'])) {
                 $address->setLine1($vmadd['address_1']);
             }
             if (isset($vmadd['address_2'])) {
                 $address->setLine2($vmadd['address_2']);
             }
             if (isset($vmadd['city'])) {
                 $address->setCity($vmadd['city']);
             }
             if (isset($vmadd['virtuemart_country_id'])) {
                 $vmadd['country'] = ShopFunctions::getCountryByID($vmadd['virtuemart_country_id'], 'country_2_code');
                 if (isset($vmadd['country'])) {
                     $address->setCountry($vmadd['country']);
                 }
             }
             if (isset($vmadd['virtuemart_state_id'])) {
                 $vmadd['state'] = ShopFunctions::getStateByID($vmadd['virtuemart_state_id'], 'state_2_code');
                 if (isset($vmadd['state'])) {
                     $address->setRegion($vmadd['state']);
                 }
             }
             if (isset($vmadd['zip'])) {
                 $address->setPostalCode($vmadd['zip']);
             }
             if (!class_exists('SeverityLevel')) {
                 require VMAVALARA_CLASS_PATH . DS . 'SeverityLevel.class.php';
             }
             if (!class_exists('Message')) {
                 require VMAVALARA_CLASS_PATH . DS . 'Message.class.php';
             }
             //if($calc->vAddress==0){
             if (isset($vmadd['country']) and $vmadd['country'] != 'US' and $vmadd['country'] != 'CA') {
                 self::$validatedAddresses = array($address);
                 return self::$validatedAddresses;
             }
             $address->Coordinates = 1;
             $address->Taxability = TRUE;
             $textCase = TextCase::$Mixed;
             $coordinates = 1;
             if (!class_exists('ValidateResult')) {
                 require VMAVALARA_CLASS_PATH . DS . 'ValidateResult.class.php';
             }
             if (!class_exists('ValidateRequest')) {
                 require VMAVALARA_CLASS_PATH . DS . 'ValidateRequest.class.php';
             }
             if (!class_exists('ValidAddress')) {
                 require VMAVALARA_CLASS_PATH . DS . 'ValidAddress.class.php';
             }
             try {
                 $request = new ValidateRequest($address, $textCase ? $textCase : TextCase::$Default, $coordinates);
                 $result = $client->Validate($request);
                 //vmdebug('Validate ResultCode is: '. $result->getResultCode());;
                 if ($result->getResultCode() != SeverityLevel::$Success) {
                     foreach ($result->getMessages() as $msg) {
                         vmdebug('fillValidateAvalaraAddress ' . $msg->getName() . ": " . $msg->getSummary() . "\n");
                         //vmdebug('fillValidateAvalaraAddress ERROR',$address);
                     }
                 } else {
                     self::$validatedAddresses = $result->getvalidAddresses();
                     /*	$echo = "";
                     			foreach($result->getvalidAddresses() as $valid)
                     			{
                     				$echo .= "Line 1: ".$valid->getline1()."\n";
                     				$echo .=  "Line 2: ".$valid->getline2()."\n";
                     				$echo .=  "Line 3: ".$valid->getline3()."\n";
                     				$echo .=  "Line 4: ".$valid->getline4()."\n";
                     				$echo .=  "City: ".$valid->getcity()."\n";
                     				$echo .=  "Region: ".$valid->getregion()."\n";
                     				$echo .=  "Postal Code: ".$valid->getpostalCode()."\n";
                     				$echo .=  "Country: ".$valid->getcountry()."\n";
                     				$echo .=  "County: ".$valid->getcounty()."\n";
                     				$echo .=  "FIPS Code: ".$valid->getfipsCode()."\n";
                     				$echo .=  "PostNet: ".$valid->getpostNet()."\n";
                     				$echo .=  "Carrier Route: ".$valid->getcarrierRoute()."\n";
                     				$echo .=  "Address Type: ".$valid->getaddressType()."\n";
                     				if($coordinates == 1)
                     				{
                     					$echo .=  "Latitude: ".$valid->getlatitude()."\n";
                     					$echo .=  "Longitude: ".$valid->getlongitude()."\n";
                     				}
                     			}
                     			//vmdebug('Normalized Address:',$echo);*/
                 }
             } catch (SoapFault $exception) {
                 $msg = "Exception: ";
                 if ($exception) {
                     $msg .= $exception->faultstring;
                 }
                 $msg .= "\n";
                 $msg .= $client->__getLastRequest() . "\n";
                 $msg .= $client->__getLastResponse() . "\n";
                 vmError($msg);
             }
             if (empty(self::$validatedAddresses)) {
                 self::$validatedAddresses = FALSE;
             }
             //then for BT and/or $cart->STsameAsBT
         } else {
             self::$validatedAddresses = FALSE;
         }
         //vmdebug("Number of addresses fillValidateAvalaraAddress is ", self::$validatedAddresses);
     }
     return self::$validatedAddresses;
 }
コード例 #13
0
 public function getUPSresponse($cart, $method)
 {
     $vendorId = $this->vendor;
     $vendorModel = VmModel::getModel('vendor');
     $vendorFields = $vendorModel->getVendorAddressFields();
     $weight = 0;
     foreach ($cart->products as $product) {
         (double) ($product_weight = ShopFunctions::convertWeigthUnit($product->product_weight, $product->product_weight_uom, "LB"));
         $weight += $product_weight * $product->quantity;
     }
     if ($weight == 0) {
         JFactory::getApplication()->enqueueMessage("UPS Error: Product Weight not found", "error");
         $this->clear();
         $mainframe = JFactory::getApplication();
         $redirectMsg = "UPS Error: Product Weight not found";
         $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=user&task=editaddresscart&addrtype=BT'), $redirectMsg);
         return FALSE;
     }
     $accessNumber = trim($method->api);
     $username = trim($method->username);
     $password = trim($method->password);
     $upsConnect = new ups($accessNumber, $username, $password);
     $upsConnect->setTemplatePath(JPATH_ROOT . '/plugins/vmshipment/jibon_ups/ups/xml/');
     $upsConnect->setTestingMode($method->mood);
     // Change this to 0 for production
     $upsRate = new upsRate($upsConnect);
     $upsRate->request(array('Shop' => true));
     $upsRate->shipper(array('name' => $vendorFields['fields']['first_name']['value'] . " " . $vendorFields['fields']['last_name']['value'], 'phone' => $vendorFields['fields']['phone_1']['value'], 'shipperNumber' => '', 'address1' => $vendorFields['fields']['address_1']['value'], 'address2' => '', 'address3' => '', 'city' => $vendorFields['fields']['city']['value'], 'state' => $vendorFields['fields']['virtuemart_state_id']['state_2_code'], 'postalCode' => $vendorFields['fields']['zip']['value'], 'country' => $vendorFields['fields']['virtuemart_country_id']['country_2_code']));
     if (!is_array($cart->BT)) {
         JFactory::getApplication()->enqueueMessage("UPS Error: Please put valid shipping information !!", "error");
         return false;
     }
     if (is_array($cart->ST)) {
         $upsRate->shipTo(array('companyName' => $cart->ST['company'], 'attentionName' => $cart->ST['first_name'] . " " . $cart->ST['last_name'], 'phone' => $cart->ST['phone_1'], 'address1' => $cart->ST['address_1'], 'address2' => '', 'address3' => '', 'city' => $cart->ST['city'], 'state' => ShopFunctions::getStateByID($cart->ST['virtuemart_state_id'], "state_2_code"), 'postalCode' => $cart->ST['zip'], 'countryCode' => ShopFunctions::getCountryByID($cart->ST['virtuemart_country_id'], "country_2_code")));
     } else {
         $upsRate->shipTo(array('companyName' => $cart->BT['company'], 'attentionName' => $cart->BT['first_name'] . " " . $cart->BT['last_name'], 'phone' => $cart->BT['phone_1'], 'address1' => $cart->BT['address_1'], 'address2' => '', 'address3' => '', 'city' => $cart->BT['city'], 'state' => ShopFunctions::getStateByID($cart->BT['virtuemart_state_id'], "state_2_code"), 'postalCode' => $cart->BT['zip'], 'countryCode' => ShopFunctions::getCountryByID($cart->BT['virtuemart_country_id'], "country_2_code")));
     }
     $upsRate->package(array('description' => 'my description', 'weight' => $weight, 'code' => '02', 'length' => 0, 'width' => 0, 'height' => 0));
     $upsRate->shipment(array('description' => 'my description', 'serviceType' => '03'));
     //service type
     $upsRate->sendRateRequest();
     $this->UPSresponse = $upsRate->returnResponseArray();
     if (!empty($this->UPSresponse["RatingServiceSelectionResponse"]["Response"]["Error"]["ErrorCode"]) or empty($this->UPSresponse)) {
         $this->ups_rate = "";
         $this->ups_service_name = "";
         $this->ups_service_id = "";
         $this->status = 0;
         $this->loadPost($method->virtuemart_shipmentmethod_id);
         JFactory::getApplication()->enqueueMessage("UPS Error: " . $this->UPSresponse["RatingServiceSelectionResponse"]["Response"]["Error"]["ErrorDescription"]["VALUE"], "error");
     }
     $currency = CurrencyDisplay::getInstance();
     if ($this->UPSresponse['RatingServiceSelectionResponse']['RatedShipment']) {
         foreach ($this->UPSresponse['RatingServiceSelectionResponse']['RatedShipment'] as $rate) {
             if ($this->ups_service_id === $rate["Service"]["Code"]["VALUE"]) {
                 $this->ups_rate = $currency->convertCurrencyTo("USD", $rate["TotalCharges"]["MonetaryValue"]["VALUE"]);
                 $this->ups_service_name = $this->getServiceName($rate["Service"]["Code"]["VALUE"]);
                 $this->ups_service_id = $rate["Service"]["Code"]["VALUE"];
                 $this->save();
                 break;
             }
         }
     }
     return $this->UPSresponse;
 }
コード例 #14
0
 function plgVmConfirmedOrder($cart, $order)
 {
     if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return null;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($method->payment_element)) {
         return false;
     }
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $this->logInfo('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     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';
     }
     //$usr = JFactory::getUser();
     $new_status = '';
     $usrBT = $order['details']['BT'];
     $address = isset($order['details']['ST']) ? $order['details']['ST'] : $order['details']['BT'];
     if (!class_exists('TableVendors')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'table' . DS . 'vendors.php';
     }
     /*$vendorModel = VmModel::getModel('Vendor');
     		$vendorModel->setId(1);
     		$vendor = $vendorModel->getVendor();
     		$vendorModel->addImages($vendor, 1);*/
     $this->getPaymentCurrency($method);
     $q = 'SELECT `currency_code_3` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $method->payment_currency . '" ';
     $db = JFactory::getDBO();
     $db->setQuery($q);
     $currency_code_3 = $db->loadResult();
     $paymentCurrency = CurrencyDisplay::getInstance($method->payment_currency);
     $totalInPaymentCurrency = $paymentCurrency->convertCurrencyTo($method->payment_currency, $order['details']['BT']->order_total, false);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     if ($totalInPaymentCurrency <= 0) {
         vmInfo(JText::_('VMPAYMENT_PAYTM_PAYMENT_AMOUNT_INCORRECT'));
         return false;
     }
     $merchant_id = $method->merchant_id;
     if (empty($merchant_id)) {
         vmInfo(JText::_('VMPAYMENT_PAYTM_MERCHANT_ID_NOT_SET'));
         return false;
     }
     $secret_key = $method->secret_key;
     if (empty($secret_key)) {
         vmInfo(JText::_('VMPAYMENT_PAYTM_SECRET_KEY_NOT_SET'));
         return false;
     }
     $channel_id = $method->channel_id;
     if (empty($channel_id)) {
         vmInfo(JText::_('VMPAYMENT_PAYTM_CHANNEL_ID_NOT_SET'));
         return false;
     }
     $industry_type = $method->industry_type;
     if (empty($industry_type)) {
         vmInfo(JText::_('VMPAYMENT_PAYTM_INDUSTRY_TYPE_NOT_SET'));
         return false;
     }
     $website_name = $method->website_name;
     if (empty($website_name)) {
         vmInfo(JText::_('VMPAYMENT_PAYTM_WEBSITE_NAME_NOT_SET'));
         return false;
     }
     $mode = $method->mode;
     $callbackflag = $method->callbackflag;
     $log = $method->log;
     $return_url = JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&orderId=' . JRequest::getVar('orderId') . '&responseCode=' . JRequest::getVar('responseCode') . '&responseDescription=' . JRequest::getVar('responseDescription') . '&checksum=' . JRequest::getVar('checksum'));
     $product = $cart->products;
     //echo "<pre>";print_r($method);echo "</pre>";
     $description = $method->description;
     $order_id = $order['details']['BT']->order_number;
     $email = $order['details']['BT']->email;
     $firstname = $order['details']['BT']->first_name;
     $lastname = $order['details']['BT']->last_name;
     $address = $order['details']['BT']->address_1 . " " . $order['details']['BT']->address_2;
     $city = $order['details']['BT']->city;
     $state = isset($order['details']['BT']->virtuemart_state_id) ? ShopFunctions::getStateByID($order['details']['BT']->virtuemart_state_id) : '';
     $country = ShopFunctions::getCountryByID($order['details']['BT']->virtuemart_country_id, 'country_2_code');
     $zip = $order['details']['BT']->zip;
     $phone = $order['details']['BT']->phone_1;
     $amount = intval($totalInPaymentCurrency);
     //should be in paisa
     $ship_address = $address->address_1;
     if (isset($address->address_2)) {
         $ship_address .= " " . $address->address_2;
     }
     /*	$post_variables = Array(
     		    "merchantIdentifier" => $merchant_id, 
     		    "orderId" => $order_id,
     			"returnUrl" => $return_url,
     			"buyerEmail" => $email,
     			"buyerFirstName" => $firstname,
     			"buyerLastName" => $lastname,
     			"buyerAddress" => $address,
     			"buyerCity" => $city,
     			"buyerState" => $state,
     			"buyerCountry" => $country,
     			"buyerPincode" =>  $zip,
     			"buyerPhoneNumber" => $phone,
     			"txnType" => 1,
     			"zpPayOption" => 1,
     			"mode" => $mode,
     			"currency" => $currency_code_3,
     			"amount" => $amount,	
     			"merchantIpAddress" => "127.0.0.1",  	//Merchant Ip Address
     			"purpose" => 1,
     			"productDescription" => "Order Id ".$order_id,		//$product->virtuemart_product_name,//$description,
     			"shipToAddress" => $ship_address,	
     			"shipToCity" => $address->city,			
     			"shipToState" => isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id) : '',
     			"shipToCountry" => ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'),
     		    "shipToPincode" => $address->zip,
     		    "shipToPhoneNumber" => $address->phone_1,
     			"shipToFirstName" => $address->first_name,
     			"shipToLastName" => $address->last_name,
     			"txnDate" => date('Y-m-d'),
     						
     		); */
     $post_variables = array("MID" => $merchant_id, "ORDER_ID" => $order_id, "CUST_ID" => $firstname, "TXN_AMOUNT" => $amount, "CHANNEL_ID" => $channel_id, "INDUSTRY_TYPE_ID" => $industry_type, "WEBSITE" => $website_name);
     if ($callbackflag == '1') {
         $post_variables["CALLBACK_URL"] = JURI::base() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&pm=paytm';
     }
     function sanitizedURL($param)
     {
         $pattern[0] = "%,%";
         $pattern[1] = "%\\(%";
         $pattern[2] = "%\\)%";
         $pattern[3] = "%\\{%";
         $pattern[4] = "%\\}%";
         $pattern[5] = "%<%";
         $pattern[6] = "%>%";
         $pattern[7] = "%`%";
         $pattern[8] = "%!%";
         $pattern[9] = "%\\\$%";
         $pattern[10] = "%\\%%";
         $pattern[11] = "%\\^%";
         $pattern[12] = "%\\+%";
         $pattern[13] = "%\\|%";
         $pattern[14] = "%\\\\%";
         $pattern[15] = "%'%";
         $pattern[16] = "%\"%";
         $pattern[17] = "%;%";
         $pattern[18] = "%~%";
         $pattern[19] = "%\\[%";
         $pattern[20] = "%\\]%";
         $pattern[21] = "%\\*%";
         $sanitizedParam = preg_replace($pattern, "", $param);
         return $sanitizedParam;
     }
     function sanitizedParam($param)
     {
         $pattern[0] = "%,%";
         $pattern[1] = "%#%";
         $pattern[2] = "%\\(%";
         $pattern[3] = "%\\)%";
         $pattern[4] = "%\\{%";
         $pattern[5] = "%\\}%";
         $pattern[6] = "%<%";
         $pattern[7] = "%>%";
         $pattern[8] = "%`%";
         $pattern[9] = "%!%";
         $pattern[10] = "%\\\$%";
         $pattern[11] = "%\\%%";
         $pattern[12] = "%\\^%";
         $pattern[13] = "%=%";
         $pattern[14] = "%\\+%";
         $pattern[15] = "%\\|%";
         $pattern[16] = "%\\\\%";
         $pattern[17] = "%:%";
         $pattern[18] = "%'%";
         $pattern[19] = "%\"%";
         $pattern[20] = "%;%";
         $pattern[21] = "%~%";
         $pattern[22] = "%\\[%";
         $pattern[23] = "%\\]%";
         $pattern[24] = "%\\*%";
         $pattern[25] = "%&%";
         $sanitizedParam = preg_replace($pattern, "", $param);
         return $sanitizedParam;
     }
     $all = '';
     foreach ($post_variables as $name => $value) {
         if ($name != 'checksum') {
             $all .= "'";
             if ($name == 'returnUrl') {
                 $all .= sanitizedURL($value);
             } else {
                 $all .= sanitizedParam($value);
             }
             $all .= "'";
         }
     }
     function calculateChecksum($secret_key, $all)
     {
         $hash = hash_hmac('sha256', $all, $secret_key);
         $checksum = $hash;
         return $checksum;
     }
     if ($log == "on") {
         error_log("All Params : " . $all);
         error_log("Paytm Secret Key : " . $secret_key);
     }
     //$checksum = calculateChecksum($secret_key,$all);
     $checksum = getChecksumFromArray($post_variables, $secret_key);
     /*$post_variables = Array(
     		    "merchantIdentifier" => $merchant_id, 
     		    "orderId" => $order_id,
     			"returnUrl" => $return_url,
     			"buyerEmail" => sanitizedParam($email),
     			"buyerFirstName" => sanitizedParam($firstname),
     			"buyerLastName" => sanitizedParam($lastname),
     			"buyerAddress" => sanitizedParam($address),
     			"buyerCity" => $city,
     			"buyerState" => $state, 
     			"buyerCountry" => $country,
     			"buyerPincode" =>  $zip,
     			"buyerPhoneNumber" => $phone,
     			"txnType" => 1,
     			'zpPayOption' => 1,
     			"mode" => $mode,
     			"currency" => $currency_code_3,
     			"amount" => $amount,
     			"merchantIpAddress" => "127.0.0.1", 
     			"purpose" => 1,
     			"productDescription" => "Order Id ".$order_id, //$product->virtuemart_product_name,	//$description,
     		    "shipToAddress" => sanitizedParam($ship_address),	
     			"shipToCity" => $address->city,			
     			"shipToState" => isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id) : '',
     			"shipToCountry" => ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'),
     			"shipToPincode" => $address->zip,
     		    "shipToPhoneNumber" => $address->phone_1,
     			"shipToFirstName" => $address->first_name,
     			"shipToLastName" => $address->last_name,
     			"txnDate" => date('Y-m-d'),
     			"checksum" => $checksum,			
     		); */
     $post_variables = array("MID" => $merchant_id, "ORDER_ID" => $order_id, "WEBSITE" => $website_name, "INDUSTRY_TYPE_ID" => $industry_type, "CHANNEL_ID" => $channel_id, "TXN_AMOUNT" => $amount, "CUST_ID" => $firstname, "txnDate" => date('Y-m-d H:i:s'), "CHECKSUMHASH" => $checksum);
     if ($callbackflag == '1') {
         $post_variables["CALLBACK_URL"] = JURI::base() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&pm=paytm';
     }
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = $this->renderPluginName($method, $order);
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['description'] = $description;
     $dbValues['paytm_custom'] = $return_context;
     $dbValues['billing_currency'] = $method->payment_currency;
     $dbValues['amount'] = $amount;
     $this->storePSPluginInternalData($dbValues);
     if ($mode == 0) {
         $url = "pguat.paytm.com/oltp-web/processTransaction";
     } else {
         $url = "secure.paytm.in/oltp-web/processTransaction";
     }
     // add spin image
     $html = '<html><head><title>Redirection</title></head><body><div style="margin: auto; text-align: center;">';
     $html .= '<form action="' . "https://" . $url . '" method="post" name="vm_paytm_form" >';
     $html .= '<input type="submit"  value="' . JText::_('VMPAYMENT_PAYTM_REDIRECT_MESSAGE') . '" />';
     foreach ($post_variables as $name => $value) {
         $html .= '<input type="hidden" style="" name="' . $name . '" value="' . $value . '" />';
     }
     $html .= '</form></div>';
     $html .= ' <script type="text/javascript">';
     $html .= ' document.vm_paytm_form.submit();';
     $html .= ' </script></body></html>';
     // 	2 = don't delete the cart, don't send email and don't redirect
     $cart->_confirmDone = false;
     $cart->_dataValidated = false;
     $cart->setCartIntoSession();
     JRequest::setVar('html', $html);
 }
コード例 #15
0
    /**
     * Xml Consulta inicial
     **/
    function getXmlConsulta($method, $order)
    {
        // configuração de campos extras
        $campo_bairro = $method->campo_bairro;
        $campo_numero = $method->campo_numero;
        $campo_complemento = $method->campo_complemento;
        $campo_logradouro = $method->campo_logradouro;
        $order_total = round($order['details']["BT"]->order_total, 2);
        $order_number = $order['details']["BT"]->order_number;
        $customer_name = $order["details"]["BT"]->first_name . ' ' . $order["details"]["BT"]->last_name;
        $order_email = $order["details"]["BT"]->email;
        $customer_number = $order["details"]["BT"]->virtuemart_user_id;
        $customer_address = $order["details"]["BT"]->{$campo_logradouro};
        $customer_address_number = $order["details"]["BT"]->{$campo_numero};
        $customer_address_complemento = $order["details"]["BT"]->{$campo_complemento};
        $customer_bairro = $order["details"]["BT"]->{$campo_bairro};
        $customer_city = $order["details"]["BT"]->city;
        $customer_state = ShopFunctions::getStateByID($order["details"]["BT"]->virtuemart_state_id, "state_2_code");
        $customer_phone = $order["details"]["BT"]->phone_1;
        $replacements = array(" ", "-", "(", ")");
        $customer_phone = str_replace($replacements, "", $customer_phone);
        $customer_phone = '(' . substr($customer_phone, 0, 2) . ')' . substr($customer_phone, 2, 4) . '-' . substr($customer_phone, 6, 4);
        $customer_zip = $order["details"]["BT"]->zip;
        $replacements = array(" ", ".", ",", "-", ";");
        $customer_zip = str_replace($replacements, "", $customer_zip);
        $customer_zip = substr($customer_zip, 0, 5) . '-' . substr($customer_zip, 5, 3);
        $this->xml_consulta = '<EnviarInstrucao>
      <InstrucaoUnica TipoValidacao="Transparente">
          <Razao>' . $method->mensagem_pagamento . ' - ' . $order_number . '</Razao>
          <Valores>
           <Valor moeda="BRL">' . $order_total . '</Valor>
       </Valores>
       <IdProprio>' . $order_number . '</IdProprio>
       <Pagador>
           <Nome>' . $customer_name . '</Nome>
           <Email>' . $order_email . '</Email>
           <IdPagador>' . $customer_number . '</IdPagador>
           <EnderecoCobranca>
            <Logradouro>' . $customer_address . '</Logradouro>
            <Numero>' . $customer_address_number . '</Numero>
            <Complemento>' . $customer_address_complemento . '</Complemento>
            <Bairro>' . $customer_bairro . '</Bairro>
            <Cidade>' . $customer_city . '</Cidade>
            <Estado>' . $customer_state . '</Estado>
            <Pais>BRA</Pais>
            <CEP>' . $customer_zip . '</CEP>
            <TelefoneFixo>' . $customer_phone . '</TelefoneFixo>
        </EnderecoCobranca>
    </Pagador>
    <Parcelamentos>
      ' . $this->montaParcelamentos($method) . '
  </Parcelamentos>
</InstrucaoUnica>
</EnviarInstrucao>';
        return $this->xml_consulta;
    }