本文整理汇总了PHP中ShopFunctions::getCountryByID方法的典型用法代码示例。如果您正苦于以下问题:PHP ShopFunctions::getCountryByID方法的具体用法?PHP ShopFunctions::getCountryByID怎么用?PHP ShopFunctions::getCountryByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShopFunctions
的用法示例。
在下文中一共展示了ShopFunctions::getCountryByID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fillValidateAvalaraAddress
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');
//.........这里部分代码省略.........
示例2: getPostVariables
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¬ificationTask=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: plgVmConfirmedOrder
/**
* @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: getKlarnaFieldsFromVmShopperFields
/**
* @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: _setShippingInformation
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: plgVmConfirmedOrder
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");
//.........这里部分代码省略.........
示例7: plgVmConfirmedOrder
//.........这里部分代码省略.........
$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: plgVmConfirmedOrder
//.........这里部分代码省略.........
$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;
示例9: plgVmConfirmedOrder
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: plgVmConfirmedOrder
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: fillValidateAvalaraAddress
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) {
//.........这里部分代码省略.........
示例12: getUPSresponse
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: setNewPayer
/**
* @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: initPostVariables
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: plgVmConfirmedOrder
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>';
//.........这里部分代码省略.........