예제 #1
0
 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;
 }
예제 #2
0
파일: redirect.php 프로젝트: lenard112/cms
 function getPostVariables()
 {
     $BT = $this->order['details']['BT'];
     $ST = isset($this->order['details']['ST']) ? $this->order['details']['ST'] : $this->order['details']['BT'];
     // prepare postdata
     $post_variables = array();
     $post_variables['MERCHANT_ID'] = $this->_method->merchant_id;
     $post_variables['ACCOUNT'] = $this->_method->subaccount;
     $post_variables['ORDER_ID'] = $BT->order_number;
     $post_variables['AMOUNT'] = $this->getTotalInPaymentCurrency();
     $post_variables['CURRENCY'] = $this->getPaymentCurrency();
     $post_variables['LANG'] = $this->getPaymentLang();
     $post_variables['TIMESTAMP'] = $this->getTimestamp();
     $post_variables['DCC_ENABLE'] = $this->_method->dcc;
     $post_variables['COMMENT1'] = $this->setComment1();
     //$post_variables['COMMENT2'] = $this->setComment2();
     $post_variables['MERCHANT_RESPONSE_URL'] = JURI::root() . 'index.php?option=com_virtuemart&format=raw&view=pluginresponse&task=pluginnotification&notificationTask=handleRedirect&tmpl=component';
     $post_variables['AUTO_SETTLE_FLAG'] = $this->getSettlement();
     if ($BT->virtuemart_user_id != 0) {
         //$post_variables['VAR_REF'] = $BT->order_number;
         $post_variables['CARD_STORAGE_ENABLE'] = $this->_method->realvault;
         if ($this->_method->realvault) {
             $payerRef = $this->getSavedPayerRef();
             if (!$payerRef) {
                 $post_variables['PAYER_EXIST'] = 0;
                 $post_variables['PMT_REF'] = '';
                 $post_variables['PAYER_REF'] = $this->getNewPayerRef();
             } else {
                 $post_variables['PAYER_REF'] = $payerRef;
                 $post_variables['PAYER_EXIST'] = 1;
                 $saved_cc_selected = $this->customerData->getVar('saved_cc_selected');
                 // -1: use another card, empty no CC are stored
                 if ($saved_cc_selected == -1 or empty($saved_cc_selected)) {
                     $post_variables['PMT_REF'] = '';
                 } else {
                     $post_variables['PMT_REF'] = $this->getPmtRef();
                 }
             }
             $post_variables['OFFER_SAVE_CARD'] = $this->_method->offer_save_card;
         } else {
             $post_variables['OFFER_SAVE_CARD'] = 0;
         }
     } else {
         $post_variables['OFFER_SAVE_CARD'] = 0;
         $post_variables['CARD_STORAGE_ENABLE'] = 0;
     }
     if ($this->_method->card_payment_button) {
         $post_variables['CARD_PAYMENT_BUTTON'] = $this->getCardPaymentButton($this->_method->card_payment_button);
     }
     if ($this->_method->realvault and $BT->virtuemart_user_id != 0) {
         $post_variables['SHA1HASH'] = $this->getSha1Hash($this->_method->shared_secret, $post_variables['TIMESTAMP'], $post_variables['MERCHANT_ID'], $post_variables['ORDER_ID'], $post_variables['AMOUNT'], $post_variables['CURRENCY'], $post_variables['PAYER_REF'], $post_variables['PMT_REF']);
     } else {
         $post_variables['SHA1HASH'] = $this->getSha1Hash($this->_method->shared_secret, $post_variables['TIMESTAMP'], $post_variables['MERCHANT_ID'], $post_variables['ORDER_ID'], $post_variables['AMOUNT'], $post_variables['CURRENCY']);
     }
     // use_tss? if uk
     if ($this->_method->tss) {
         $post_variables['RETURN_TSS'] = 1;
         // Transaction Suitability Score
         // <digits from postcode>|<digits from address>
         $post_variables['BILLING_CODE'] = $this->getCode($BT);
         $post_variables['BILLING_CO'] = ShopFunctions::getCountryByID($BT->virtuemart_country_id, 'country_2_code');
         $post_variables['SHIPPING_CODE'] = $this->getCode($ST);
         $post_variables['SHIPPING_CO'] = ShopFunctions::getCountryByID($ST->virtuemart_country_id, 'country_2_code');
     }
     $post_variables['gateway_url'] = $this->_getRealexUrl();
     return $post_variables;
 }
예제 #3
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;
     }
     $this->setInConfirmOrder($cart);
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $this->_debug = $method->debug;
     $this->logInfo('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     vmdebug('SOFORT plgVmConfirmedOrder');
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     if (!class_exists('TableVendors')) {
         require VMPATH_ADMIN . DS . 'tables' . DS . 'vendors.php';
     }
     $currency_code_3 = self::PAYMENT_CURRENCY_CODE_3;
     //
     $currency_id = shopFunctions::getCurrencyIDByName($currency_code_3);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $currency_id);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     $address = isset($order['details']['ST']) ? $order['details']['ST'] : $order['details']['BT'];
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     if ($totalInPaymentCurrency <= 0) {
         vmInfo(vmText::sprintf('VMPAYMENT_SOFORT_AMOUNT_INCORRECT', $order['details']['BT']->order_total, $totalInPaymentCurrency['value'], $currency_code_3));
         return FALSE;
     }
     // 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['cost_per_transaction'] = $method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $method->cost_percent_total;
     $dbValues['payment_currency'] = $currency_id;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['tax_id'] = $method->tax_id;
     $dbValues['sofort_custom'] = $return_context;
     $this->storePSPluginInternalData($dbValues);
     if (!class_exists('SofortLib')) {
         require VMPATH_ROOT . DS . 'plugins' . DS . 'vmpayment' . DS . 'sofort' . DS . 'sofort' . DS . 'library' . DS . 'sofortLib.php';
     }
     if (!class_exists('SofortLib_iDealClassic')) {
         require VMPATH_ROOT . DS . 'plugins' . DS . 'vmpayment' . DS . 'sofort' . DS . 'sofort' . DS . 'library' . DS . 'sofortLib_ideal_classic.php';
     }
     $sofort_ideal = new SofortLib_iDealClassic($method->configuration_key, $method->project_password);
     $sofort_ideal->setVersion(self::RELEASE);
     $sofort_ideal->setAmount($totalInPaymentCurrency['value'], $currency_code_3);
     $sofort_ideal->setSenderCountryId(ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'));
     $sofort_ideal->setReason($order['details']['BT']->order_number);
     $sofort_ideal->addUserVariable($order['details']['BT']->virtuemart_paymentmethod_id);
     //$sofort_ideal->setSuccessUrl(self::getSuccessUrl($order)); //user_variable_3
     //$sofort_ideal->setAbortUrl(self::getCancelUrl($order)); //user_variable_4
     //$sofort_ideal->setNotificationUrl(self::getNotificationUrl( $order['details']['BT']->order_number)); //user_variable_5
     $sofort_ideal->setSenderCountryId(ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'));
     //sender_country_id
     $sofort_ideal->setSenderBankCode(self::_getSelectedBankCode($order['details']['BT']->virtuemart_paymentmethod_id));
     $url = $sofort_ideal->getPaymentUrl();
     //$this->storePSPluginInternalData($dbValues);
     $mainframe = JFactory::getApplication();
     $mainframe->redirect($url);
 }
예제 #4
0
 /**
  * @static
  * @param $from
  * @param $from_email
  * @return array
  */
 static function getKlarnaFieldsFromVmShopperFields($from, $from_email)
 {
     $klarnaFields = array();
     switch ($from['title']) {
         case vmText::_('COM_VIRTUEMART_SHOPPER_TITLE_MR'):
             $klarnaFields['gender'] = KlarnaFlags::MALE;
             break;
         case vmText::_('COM_VIRTUEMART_SHOPPER_TITLE_MISS'):
         case vmText::_('COM_VIRTUEMART_SHOPPER_TITLE_MRS'):
             $klarnaFields['gender'] = KlarnaFlags::FEMALE;
             break;
         default:
             $klarnaFields['gender'] = NULL;
             break;
     }
     $country_code_3 = ShopFunctions::getCountryByID($from['virtuemart_country_id'], 'country_3_code');
     $klarnaFields['email'] = $from_email;
     $klarnaFields['country'] = @ShopFunctions::getCountryByID(@$from['virtuemart_country_id'], 'country_3_code');
     $klarnaFields['socialNumber'] = @$from['socialNumber'];
     $klarnaFields['houseNr'] = @$from['house_no'];
     $klarnaFields['houseExt'] = @$from['address_2'];
     $klarnaFields['first_name'] = @$from['first_name'];
     if ($country_code_3 == 'NLD') {
         $klarnaFields['last_name'] = @$from['middle_name'] . " " . @$from['last_name'];
     } else {
         $klarnaFields['last_name'] = @$from['last_name'];
     }
     $klarnaFields['reference'] = $from['first_name'] . ' ' . $from['last_name'];
     $klarnaFields['company_name'] = @$from['company_name'];
     $klarnaFields['phone'] = @$from['phone_1'];
     $klarnaFields['street'] = @$from['address_1'];
     $klarnaFields['city'] = @$from['city'];
     $klarnaFields['country'] = $country_code_3;
     $klarnaFields['state'] = @$from['state'];
     $klarnaFields['zip'] = @$from['zip'];
     $klarnaFields['birthday'] = @$from['birthday'];
     if (isset($from['birthday']) and !empty($from['birthday'])) {
         $date = explode("-", $from['birthday']);
         if (is_array($date)) {
             $klarnaFields['birth_year'] = $date['0'];
             $klarnaFields['birth_month'] = $date['1'];
             $klarnaFields['birth_day'] = $date['2'];
         }
     }
     return $klarnaFields;
 }
예제 #5
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) : '');
 }
예제 #6
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 VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . 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 VMPATH_ADMIN . 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(vmText::_('VMPAYMENT_TODOPAGO_PAYMENT_AMOUNT_INCORRECT'));
         return FALSE;
     }
     $lang = JFactory::getLanguage();
     $tag = substr($lang->get('tag'), 0, 2);
     $post_variables = array();
     require_once 'cs/TPConnector.php';
     $tpconnector = new TPConnector();
     $connector_data = $tpconnector->createTPConnector($method);
     $this->logInfo("tpconnector" . json_encode($connector_data), "message");
     $connector = $connector_data['connector'];
     $security_code = $connector_data['security'];
     $merchant = $connector_data['merchant'];
     $return_url = 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=' . vRequest::getInt('Itemid') . '&lang=' . vRequest::getCmd('lang', '');
     $cancel_url = 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=' . vRequest::getInt('Itemid') . '&lang=' . vRequest::getCmd('lang', '');
     $status_url = JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component&lang=' . vRequest::getCmd('lang', '');
     $optionsSAR_comercio = array('Security' => $security_code, 'EncodingMethod' => 'XML', 'Merchant' => $merchant, 'PUSHNOTIFYENDPOINT' => $return_url = JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id, 'URL_OK' => $return_url, 'URL_ERROR' => $cancel_url);
     $customFieldsModel = VmModel::getModel('Customfields');
     $optionsSAR_operacion = $this->getCommonFields($cart, $customFieldsModel, $this->tp_states);
     $currency_model = VmModel::getModel('currency');
     $currency = $currency_model->getCurrency($order['details']['BT']->user_currency_id);
     $countryIso = ShopFunctions::getCountryByID($order['details']['BT']->virtuemart_country_id, 'country_2_code');
     $countryName = ShopFunctions::getCountryByID($order['details']['BT']->virtuemart_country_id);
     $extra_fields = array();
     require 'cs/FactoryTodopago.php';
     $extra_fields = FactoryTodopago::get_extractor($method->tp_vertical_type, $cart, $customFieldsModel);
     $optionsSAR_operacion = array_merge($optionsSAR_operacion, $extra_fields);
     $optionsSAR_operacion['MERCHANT'] = $merchant;
     $optionsSAR_operacion['CURRENCYCODE'] = "032";
     $optionsSAR_operacion['CSPTCURRENCY'] = "ARS";
     $optionsSAR_operacion['OPERATIONID'] = $order['details']['BT']->order_number;
     $optionsSAR_operacion['CSBTCOUNTRY'] = $countryIso;
     $optionsSAR_operacion['CSMDD9'] = JFactory::getUser()->password;
     $optionsSAR_operacion['CSSTSTATE'] = $this->tp_states;
     $optionsSAR_operacion['CSSTCOUNTRY'] = $countryIso;
     $optionsSAR_operacion['CSMDD12'] = $method->tp_dead_line;
     $optionsSAR_operacion['CSMDD13'] = $this->_sanitize_string($cart->cartData['shipmentName']);
     $this->logInfo("TP - SARcomercio - " . json_encode($optionsSAR_comercio), "message");
     $this->logInfo("TP - SARoperacion - " . json_encode($optionsSAR_operacion), "message");
     $rta = $connector->sendAuthorizeRequest($optionsSAR_comercio, $optionsSAR_operacion);
     $this->logInfo("TP - SAR rta - " . json_encode($rta), "message");
     if ($rta["StatusCode"] == 702) {
         $this->logInfo("TP - SARoperacion - reintento SAR" . json_encode($optionsSAR_operacion), "message");
         $rta = $connector->sendAuthorizeRequest($optionsSAR_comercio, $optionsSAR_operacion);
     }
     setcookie('RequestKey', $rta["RequestKey"], time() + 86400 * 30, "/");
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $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;
     $dbValues['security_code'] = $method->security_code;
     $this->storePSPluginInternalData($dbValues);
     $cart->_confirmDone = TRUE;
     $cart->_dataValidated = TRUE;
     $cart->setCartIntoSession();
     if ($rta['StatusCode'] != -1) {
         echo "<script>alert('Su pago no puede ser procesado. Intente nuevamente más tarde')</script>";
         $this->logInfo("TP - Redirect to: " . $rta['URL_Request'], "message");
         echo "<script>window.location.href = '" . JURI::root() . "index.php/cart/'</script>";
     } else {
         $this->logInfo("TP - Redirect to: " . $rta['URL_Request'], "message");
         //echo "<script>window.location.href = '".$rta['URL_Request']."'</script>";
         header('Location: ' . $rta['URL_Request']);
     }
 }
예제 #7
0
	/**
	 * 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
	}
예제 #8
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->_debug = $method->HEIDELPAY_DEBUG;
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     $address = isset($order['details']['BT']) ? $order['details']['BT'] : $order['details']['ST'];
     if (!class_exists('TableVendors')) {
         require VMPATH_ADMIN . DS . 'table' . DS . 'vendors.php';
     }
     $vendorModel = VmModel::getModel('Vendor');
     $vendorModel->setId(1);
     $vendor = $vendorModel->getVendor();
     $vendorModel->addImages($vendor, 1);
     $this->getPaymentCurrency($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);
     // prepare the post var values:
     $languageTag = $this->getLang();
     $params = array();
     /*
      * Default configuration for hco
      */
     $params['FRONTEND.MODE'] = "DEFAULT";
     $params['FRONTEND.ENABLED'] = "true";
     $params['FRONTEND.POPUP'] = "false";
     $params['FRONTEND.REDIRECT_TIME'] = "0";
     $params['REQUEST.VERSION'] = "1.0";
     $params['FRONTEND.NEXTTARGET'] = "top.location.href";
     $params['PRESENTATION.AMOUNT'] = $totalInPaymentCurrency;
     $params['PRESENTATION.CURRENCY'] = $currency_code_3;
     $params['FRONTEND.LANGUAGE'] = $languageTag;
     $params['CRITERION.LANG'] = $params['FRONTEND.LANGUAGE'];
     $params['IDENTIFICATION.TRANSACTIONID'] = $order['details']['BT']->order_number;
     /*
      * Set payment methode to PA for online transfer, invoice and prepayment
      */
     $PaymentTypePA = array('OT', 'PP', 'IV');
     if (in_array(substr($method->HEIDELPAY_PAYMENT_TYPE, 0, 2), $PaymentTypePA)) {
         $method->HEIDELPAY_PAYMENT_METHOD = "PA";
     } else {
         $method->HEIDELPAY_PAYMENT_METHOD = $method->HEIDELPAY_PAYMENT_METHOD;
     }
     $params['PAYMENT.CODE'] = substr($method->HEIDELPAY_PAYMENT_TYPE, 0, 2) . "." . $method->HEIDELPAY_PAYMENT_METHOD;
     $params['TRANSACTION.CHANNEL'] = $method->HEIDELPAY_CHANNEL_ID;
     /*
      * Special case for paypal without hco iframe
      */
     if ($method->HEIDELPAY_PAYMENT_TYPE == "VAPAYPAL") {
         $params['PAYMENT.CODE'] = "VA.DB";
         $params['ACCOUNT.BRAND'] = "PAYPAL";
         $params['FRONTEND.PM.DEFAULT_DISABLE_ALL'] = "true";
         $params['FRONTEND.PM.0.ENABLED'] = "true";
         $params['FRONTEND.PM.0.METHOD'] = "VA";
         $params['FRONTEND.PM.0.SUBTYPES'] = "PAYPAL";
     }
     /*
      * Special case for MangirKart without hco iframe
      */
     if ($method->HEIDELPAY_PAYMENT_TYPE == "PCMANGIR") {
         $params['PAYMENT.CODE'] = "PC.PA";
         $params['ACCOUNT.BRAND'] = "MANGIRKART";
     }
     /*
      * case for GiroPay
      */
     if ($method->HEIDELPAY_PAYMENT_TYPE == "OTGIR") {
         $params['FRONTEND.SEPA'] = 'YES';
         $params['FRONTEND.SEPASWITCH'] = 'NO';
     }
     /*
      * Special case for BarPay without hco iframe
      */
     if ($method->HEIDELPAY_PAYMENT_TYPE == "PPBARPAY") {
         $params['PAYMENT.CODE'] = "PP.PA";
         $params['ACCOUNT.BRAND'] = "BARPAY";
     }
     /*
      * Special case for BillSAFE
      */
     if ($method->HEIDELPAY_PAYMENT_TYPE == "IVBILLSAFE") {
         $toCheck = array('last_name', 'first_name', 'middle_name', 'phone_1', 'phone_2', 'fax', 'address_1', 'address_2', 'city', 'virtuemart_state_id', 'virtuemart_country_id', 'zip');
         $bsError = false;
         foreach ($toCheck as $val) {
             if (isset($order['details']['ST']->{$val})) {
                 if ($order['details']['ST']->{$val} != $order['details']['BT']->{$val}) {
                     $bsError = true;
                     $errorVal = $val;
                     break;
                 }
             }
         }
         if ($bsError) {
             $msg = vmText::_('VMPAYMENT_HEIDELPAY_TECHNICAL_ERROR') . "<br />" . vmText::_('VMPAYMENT_HEIDELPAY_BILLSAFE_ERROR') . "<br />";
             $app = JFactory::getApplication();
             $app->redirect('index.php?option=com_virtuemart&view=cart', $msg);
         }
         $params['PAYMENT.CODE'] = "IV.PA";
         $params['ACCOUNT.BRAND'] = "BILLSAFE";
         $params = array_merge($params, $this->getBasketDetails());
     }
     /*
      *  User account information
      */
     $params['ACCOUNT.HOLDER'] = $address->first_name . " " . $address->last_name;
     $params['NAME.GIVEN'] = $address->first_name;
     $params['NAME.FAMILY'] = $address->last_name;
     if (!empty($address->company)) {
         $params['NAME.COMPANY'] = $address->company;
     }
     $params['ADDRESS.STREET'] = $address->address_1;
     isset($address->address_2) ? $params['ADDRESS.STREET'] .= " " . $address->address_2 : '';
     $params['ADDRESS.ZIP'] = $address->zip;
     $params['ADDRESS.CITY'] = $address->city;
     $params['ADDRESS.COUNTRY'] = ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code');
     $params['CONTACT.EMAIL'] = $order['details']['BT']->email;
     $params['CONTACT.IP'] = $_SERVER['REMOTE_ADDR'];
     /*
      * Add debug informations for merchiant support
      */
     $params['SHOP.TYPE'] = 'VirtueMart ' . VmConfig::getInstalledVersion();
     $params['SHOPMODULE.VERSION'] = $this->version;
     $params['CRITERION.PAYMENT_NAME'] = vmText::_('VMPAYMENT_HEIDELPAY_' . $method->HEIDELPAY_PAYMENT_TYPE);
     $params['CRITERION.PAYMENT_NAME'] = strip_tags($params['CRITERION.PAYMENT_NAME']);
     /*
      * Create hash to secure the response
      */
     $params['CRITERION.SECRET'] = $this->createSecretHash($order['details']['BT']->order_number, $method->HEIDELPAY_SECRET);
     /*
      * Set transaction mode
      */
     if ($method->HEIDELPAY_TRANSACTION_MODE == 2) {
         $params['TRANSACTION.MODE'] = "LIVE";
     } elseif ($method->HEIDELPAY_TRANSACTION_MODE == 0) {
         $params['TRANSACTION.MODE'] = "INTEGRATOR_TEST";
     } else {
         $params['TRANSACTION.MODE'] = "CONNECTOR_TEST";
     }
     /*
      * Add response and css path
      */
     $params['FRONTEND.RESPONSE_URL'] = JROUTE::_(JURI::root(), $xhtml = true, $ssl = 0) . 'plugins/vmpayment/heidelpay/heidelpay/heidelpay_response.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . urlencode($order['details']['BT']->order_number) . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id;
     $cssFile = "heidelpay_default.css";
     if (!empty($method->HEIDELPAY_STYLE)) {
         $cssFile = $method->HEIDELPAY_STYLE;
     }
     $params['FRONTEND.CSS_PATH'] = JROUTE::_(JURI::root(), $xhtml = true, $ssl = 0) . 'plugins/vmpayment/heidelpay/heidelpay/' . $cssFile;
     $requestUrl = $method->HEIDELPAY_PAYMENT_URL;
     $params['SECURITY.SENDER'] = $method->HEIDELPAY_SECURITY_SENDER;
     $params['USER.LOGIN'] = $method->HEIDELPAY_USER_LOGIN;
     $params['USER.PWD'] = $method->HEIDELPAY_USER_PW;
     if (substr($method->HEIDELPAY_PAYMENT_TYPE, 0, 2) == 'DD') {
         $sepaform = array();
         $sepaform = $this->switchDirectDebitFrom($method->HEIDELPAY_SEPA_FORM);
         $params = array_merge($sepaform, $params);
     }
     /*
      * send request to payment server
      */
     $response = $this->doRequest($requestUrl, $params, $method->HEIDELPAY_DEBUG);
     if ($params['TRANSACTION.MODE'] != "LIVE") {
         vmInfo('VMPAYMENT_HEIDELPAY_PAYMENT_TESTMODE');
     }
     /*
      * On success show iframe or show error information for your customer
      */
     $returnValue = 0;
     if ($response['PROCESSING_RESULT'] == "ACK" || $response['POST_VALIDATION'] == "ACK") {
         $returnValue = 2;
         $html = $this->renderByLayout('displaypayment', array('response' => $response['FRONTEND_REDIRECT_URL']));
     } else {
         $html = vmText::_('VMPAYMENT_HEIDELPAY_TECHNICAL_ERROR') . " <br /> - " . addslashes($response['PROCESSING_RETURN']) . "<br />" . vmText::_('VMPAYMENT_HEIDELPAY_CONTACT_SHOPOWNER');
     }
     /*
      * Show debug information
      */
     if ($method->HEIDELPAY_DEBUG == 1) {
         vmDebug('HEIDELPAY plgVmConfirmedOrder', $params);
     }
     return $this->processConfirmedOrderPaymentResponse($returnValue, $cart, $order, $html, '', '');
 }
 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);
 }
예제 #10
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->_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';
     }
     //$usr = & JFactory::getUser();
     $html = '';
     $usrBT = $order['details']['BT'];
     $address = isset($order['details']['ST']) ? $order['details']['ST'] : $order['details']['BT'];
     $vendorModel = new VirtueMartModelVendor();
     $vendorModel->setId(1);
     $vendor = $vendorModel->getVendor();
     $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);
     $totalInPaymentCurrency = round($order['details']['BT']->order_total, 2);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     $user_title = $address->title;
     $user_email = $address->email;
     $user_name = $address->first_name . ' ' . $address->last_name;
     $user_city = $address->city;
     $user_address = $address->address_1;
     $user_zip = $address->zip;
     $user_country = ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_3_code');
     $msg_1 = $user_name . " Kd-nr " . $usrBT->virtuemart_user_id;
     $msg_2 = "Bestellnr " . $order['details']['BT']->order_number;
     $cont = $method->payment_uid . "|" . $method->payment_pid . "|||||" . $totalInPaymentCurrency . "|" . $currency_code_3 . "|" . $msg_1 . "|" . $msg_2 . "|" . $order['details']['BT']->order_number . "|" . $order['details']['BT']->virtuemart_paymentmethod_id . "|VM v2.1||||" . $method->payment_pas;
     $hash = md5($cont);
     $html .= '<div style="text-align: left; margin-top: 25px; margin-bottom: 25px;">';
     $html .= 'Ihre Bestellung ist bei uns eingegangen und wird umgehend von uns bearbeitet.';
     $html .= '</div>';
     // Prepare data that should be stored in the database
     $dbValues = array();
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = $this->renderPluginName($method, $order);
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['payment_currency'] = $method->payment_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency;
     $this->storePSPluginInternalData($dbValues);
     $new_status = 'C';
     return $this->processConfirmedOrderPaymentResponse(1, $cart, $order, $html, $dbValues['payment_name'], $new_status);
 }
예제 #11
0
 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;
 }
예제 #12
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;
 }
예제 #13
0
    /**
     * @return bool|mixed
     */
    function setNewPayer($newPayerRef)
    {
        $timestamp = $this->getTimestamp();
        $xml_request = $this->setHeader($timestamp, self::REQUEST_TYPE_PAYER_NEW, false);
        $BT = $this->order['details']['BT'];
        $xml_request .= '<payer type="Business" ref="' . $newPayerRef . '">
				<firstname>' . $this->sanitize($BT->first_name) . '</firstname>
				<surname>' . $this->sanitize($BT->last_name) . '</surname>
				';
        if (!empty($BT->company)) {
            $xml_request .= '<company>' . $BT->company . '</company>
		';
        }
        $xml_request .= '<address>
				<line1>' . $BT->address_1 . '</line1>
				<line2 >' . $BT->address_2 . '</line2>
				<line3 />
				<city>' . $BT->city . '</city>
				<county>' . ShopFunctions::getCountryByID($BT->virtuemart_country_id, 'country_2_code') . '</county>
				<postcode>' . $this->stripnonnumeric($BT->zip, 5) . '</postcode>
				<country code="' . ShopFunctions::getCountryByID($BT->virtuemart_country_id, 'country_2_code') . '"> ' . ShopFunctions::getCountryByID($BT->virtuemart_country_id, 'country_name') . ' </country>
				</address>
				<phonenumbers>
				<home />
				<work>' . $BT->phone_1 . '</work>
				<fax />
				<mobile>' . $BT->phone_2 . '</mobile>
				</phonenumbers>
				<email>' . $BT->email . '</email>
				<comments>
				<comment id="1" />
				<comment id="2" />
				</comments>
				</payer>
				';
        $sha1 = $this->getSha1Hash($this->_method->shared_secret, $timestamp, $this->_method->merchant_id, $this->order['details']['BT']->order_number, '', '', $newPayerRef);
        $xml_request .= $this->setSha1($sha1);
        $xml_request .= '</request>';
        $response = $this->getXmlResponse($xml_request);
        return $response;
    }
예제 #14
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;
 }
예제 #15
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);
 }
예제 #16
0
	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');
	}
예제 #17
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');
 }
예제 #18
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
			 */
	}
예제 #19
0
 function plgVmConfirmedOrder($cart, $order)
 {
     if (!($this->_currentMethod = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return FALSE;
     }
     $interface = $this->_loadKlikandpayInterface($this);
     $interface->setOrder($order);
     $interface->setCart($cart);
     $this->getPaymentCurrency($this->_currentMethod);
     $interface->setTotal($order['details']['BT']->order_total);
     $this->logInfo('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     $subscribe_id = NULL;
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     $email_currency = $this->getEmailCurrency($this->_currentMethod);
     $name = $order['details']['BT']->first_name;
     if (isset($order['details']['BT']->middle_name) and $order['details']['BT']->middle_name) {
         $name .= $order['details']['BT']->middle_name;
     }
     $address = $order['details']['BT']->address_1;
     if (isset($order['details']['BT']->address_2) and $order['details']['BT']->address_2) {
         $name .= $order['details']['BT']->address_2;
     }
     $retourParams = $this->setRetourParams($order, $this->getContext());
     $post_variables = array("SOCIETE" => $order['details']['BT']->company, "NOM" => $order['details']['BT']->last_name, "PRENOM" => $name, "ADRESSE" => $address, "CODEPOSTAL" => $order['details']['BT']->zip, "VILLE" => $order['details']['BT']->city, "PAYS" => ShopFunctions::getCountryByID($order['details']['BT']->virtuemart_country_id, 'country_2_code'), "TEL" => !empty($order['details']['BT']->phone_1) ? $order['details']['BT']->phone_1 : $order['details']['BT']->phone_2, "EMAIL" => $order['details']['BT']->email, "L" => $interface->getLanguage(), "ID" => trim($this->_currentMethod->account), "MONTANT" => $interface->getTotal(), "DETAILS" => $interface->getOrderDetails($order), "RETOUR" => $retourParams, "RETOURVOK" => $retourParams, "RETOURVHS" => $retourParams, "MODULE" => 'VirtueMart', "MODULE_VERSION" => '3.0.14');
     $subscribe = array();
     $recurring = array();
     if ($this->_currentMethod->integration == "recurring") {
         $recurring = $interface->getRecurringPayments();
         unset($recurring['info']);
         $post_variables = array_merge($post_variables, $recurring);
         $dbValues['recurring'] = json_encode($recurring);
     } else {
         if ($this->_currentMethod->integration == "subscribe") {
             $subscribe_id = $interface->getSubscribeId($cart);
             if ($subscribe_id) {
                 $post_variables["ABONNEMENT"] = $subscribe_id;
                 unset($post_variables["MONTANT"]);
             }
         }
     }
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id;
     $dbValues['payment_name'] = $this->renderPluginName($this->_currentMethod);
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['klikandpay_custom'] = $this->getContext();
     $dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction;
     $dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total;
     $dbValues['payment_currency'] = $this->_currentMethod->payment_currency;
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $post_variables["MONTANT"];
     if (!empty($subscribe)) {
         $dbValues['subscribe'] = json_encode($subscribe);
     } else {
         $dbValues['subscribe'] = NULL;
     }
     $dbValues['tax_id'] = $this->_currentMethod->tax_id;
     $this->storePSPluginInternalData($dbValues);
     $html = $this->getConfirmedHtml($post_variables, $interface, $subscribe_id);
     // 	2 = don't delete the cart, don't send email and don't redirect
     $cart->_confirmDone = FALSE;
     $cart->_dataValidated = FALSE;
     $cart->setCartIntoSession();
     vRequest::setVar('display_title', false);
     vRequest::setVar('html', $html);
     return;
 }
예제 #20
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
     */
 }
예제 #21
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);
 }