public function processCallback(\XLite\Model\Payment\Transaction $transaction)
 {
     parent::processCallback($transaction);
     $request = \XLite\Core\Request::getInstance();
     $json = file_get_contents('php://input');
     //\XLite\Logger::logCustom('pmt', var_export($json,1), '');
     $temp = json_decode($json, true);
     if ($this->getSetting('test')) {
         $this->public_key = $this->getSetting('testPublicKey');
         $this->secret_key = $this->getSetting('testSecretKey');
     } else {
         $this->public_key = $this->getSetting('realPublicKey');
         $this->secret_key = $this->getSetting('realSecretKey');
     }
     $signature_check = sha1($this->secret_key . $temp['account_id'] . $temp['api_version'] . $temp['event'] . $temp['data']['id']);
     $signature_check_sha512 = hash('sha512', $this->secret_key . $temp['account_id'] . $temp['api_version'] . $temp['event'] . $temp['data']['id']);
     if ($signature_check != $temp['signature'] && $signature_check_sha512 != $temp['signature']) {
         //hack detected
         $status = $transaction::STATUS_FAILED;
         $this->setDetail('verification', 'Verification failed', 'Verification');
         $this->transaction->setNote('Verification failed');
     } else {
         $status = $transaction::STATUS_SUCCESS;
         $this->setDetail('result', 'Accept', 'Result');
     }
     $this->transaction->setStatus($status);
 }
Exemple #2
0
 /**
  * Update profile
  * FIXME
  *
  * @return void
  */
 protected function updateProfile()
 {
     if ($this->isCreateProfile()) {
         $error = user_validate_name(\XLite\Core\Request::getInstance()->username);
         if ($error) {
             // Username validation error
             $this->valid = false;
             \XLite\Core\Event::invalidElement('username', $error);
         } elseif (user_load_by_name(\XLite\Core\Request::getInstance()->username)) {
             // Username is already exists
             $this->valid = false;
             $label = static::t('This user name is used for an existing account. Enter another user name or sign in', array('URL' => $this->getLoginURL()));
             \XLite\Core\Event::invalidElement('username', $label);
         } elseif (\XLite\Core\Request::getInstance()->email && user_load_multiple(array(), array('mail' => \XLite\Core\Request::getInstance()->email))) {
             // E-mail is already exists in Drupal DB
             $this->valid = false;
             $label = static::t('This email address is used for an existing account. Enter another user name or sign in', array('URL' => $this->getLoginURL()));
             \XLite\Core\Event::invalidElement('email', $label);
         }
     }
     parent::updateProfile();
     if ($this->isCreateProfile() && $this->valid) {
         // Save username is session (temporary, wait place order procedure)
         \XLite\Core\Session::getInstance()->order_username = \XLite\Core\Request::getInstance()->create_profile ? \XLite\Core\Request::getInstance()->username : false;
     }
 }
Exemple #3
0
 /**
  * Process return
  *
  * @param \XLite\Model\Payment\Transaction $transaction Return-owner transaction
  *
  * @return void
  */
 public function processReturn(\XLite\Model\Payment\Transaction $transaction)
 {
     parent::processReturn($transaction);
     $request = \XLite\Core\Request::getInstance();
     if ($request->isPost() && isset($request->trans_result)) {
         $status = 'APPROVED' == $request->trans_result ? $transaction::STATUS_SUCCESS : $transaction::STATUS_FAILED;
         $this->saveDataFromRequest();
         // Amount checking
         if (isset($request->amount) && !$this->checkTotal($request->amount)) {
             $status = $transaction::STATUS_FAILED;
         }
         if (isset($request->decline_reason)) {
             $this->transaction->setNote($request->decline_reason);
         }
         // MD5 hash checking
         if ($status == $transaction::STATUS_SUCCESS && isset($request->md5_hash)) {
             $order = $this->getOrder();
             $amount = $order->getCurrency()->roundValue($this->transaction->getValue());
             $hash = md5(strval($this->getSetting('hash')) . $this->getSetting('login') . $request->transID . number_format($amount, 2) . ('Y' == $this->getSetting('include_response') ? $request->trans_result : ''));
             if ($hash != $request->md5_hash) {
                 $status = $transaction::STATUS_FAILED;
                 $this->setDetail('hash_checking', 'failed', 'MD5 hash checking');
             }
         }
         $this->transaction->setStatus($status);
     }
 }
Exemple #4
0
 /**
  * Do action update
  *
  * @return void
  */
 protected function doActionUpdate()
 {
     if (\XLite\Core\Request::getInstance()->delete) {
         \XLite\Core\Database::getRepo('XLite\\Model\\Category')->removeProductFilterCache();
     }
     parent::doActionUpdate();
 }
Exemple #5
0
 /**
  * Check field validity
  *
  * @return boolean
  */
 protected function checkFieldValidity()
 {
     $result = parent::checkFieldValidity();
     if ($result && $this->getValue()) {
         $length = strlen($this->getValue());
         // Check size
         if (static::MIN_SIZE > $length) {
             // Too small
             $result = false;
             $this->errorMessage = static::t('The length of X field must be greater than Y', array('name' => $this->getLabel(), 'min' => static::MIN_SIZE));
         } elseif (static::MAX_SIZE < $length) {
             // Too big
             $result = false;
             $this->errorMessage = static::t('The length of X field must be less than Y', array('name' => $this->getLabel(), 'max' => static::MAX_SIZE));
         } else {
             // Check duplicate
             $modelId = \XLite\Core\Request::getInstance()->id;
             $model = $modelId ? \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\Coupons\\Model\\Coupon')->find($modelId) : null;
             $duplicates = \XLite\Core\Database::getRepo('XLite\\Module\\CDev\\Coupons\\Model\\Coupon')->findDuplicates($this->getValue(), $model);
             if ($duplicates) {
                 $result = false;
                 $this->errorMessage = static::t('X code is already used for other coupon, please specify a different code', array('code' => $this->getValue()));
             }
         }
     }
     return $result;
 }
Exemple #6
0
 /**
  * Set return URL
  *
  * @param string $url URL to set
  *
  * @return void
  */
 public function setReturnURL($url)
 {
     if (\XLite\Module\CDev\Paypal\Main::isExpressCheckoutEnabled() && \XLite\Module\CDev\Paypal\Main::isInContextCheckoutAvailable() && \XLite\Core\Request::getInstance()->cancelUrl) {
         $url = $this->getShopURL(\XLite\Core\Request::getInstance()->cancelUrl, \XLite\Core\Config::getInstance()->Security->customer_security);
     }
     parent::setReturnURL($url);
 }
Exemple #7
0
 /**
  * Get order
  *
  * @return \XLite\Model\Order
  */
 public function getOrder()
 {
     if (!isset($this->order)) {
         $this->order = \XLite\Core\Database::getRepo('XLite\\Model\\Order')->find(\XLite\Core\Request::getInstance()->order_id);
     }
     return $this->order;
 }
Exemple #8
0
 /**
  * init
  *
  * @return void
  */
 public function init()
 {
     parent::init();
     if (\XLite\Core\Request::getInstance()->id) {
         $this->tabs['featured_products'] = array('title' => 'Featured products', 'template' => 'modules/CDev/FeaturedProducts/featured_products.tpl');
     }
 }
Exemple #9
0
 /**
  * doExpressCheckoutReturn 
  * 
  * @return void
  */
 protected function doActionExpressCheckoutReturn()
 {
     $request = \XLite\Core\Request::getInstance();
     $cart = $this->getCart();
     \XLite\Module\CDev\Paypal\Main::addLog('doExpressCheckoutReturn()', $request->getData());
     if (isset($request->cancel)) {
         \XLite\Core\Session::getInstance()->ec_token = null;
         \XLite\Core\Session::getInstance()->ec_date = null;
         \XLite\Core\Session::getInstance()->ec_payer_id = null;
         \XLite\Core\Session::getInstance()->ec_type = null;
         $cart->unsetPaymentMethod();
         \XLite\Core\TopMessage::getInstance()->addWarning('Express Checkout process stopped.');
     } elseif (!isset($request->token) || $request->token != \XLite\Core\Session::getInstance()->ec_token) {
         \XLite\Core\TopMessage::getInstance()->addError('Wrong token of Express Checkout.');
     } elseif (!isset($request->PayerID)) {
         \XLite\Core\TopMessage::getInstance()->addError('PayerID value was not returned by PayPal.');
     } else {
         // Express Checkout shortcut flow processing
         \XLite\Core\Session::getInstance()->ec_type = \XLite\Module\CDev\Paypal\Model\Payment\Processor\ExpressCheckout::EC_TYPE_SHORTCUT;
         \XLite\Core\Session::getInstance()->ec_payer_id = $request->PayerID;
         $paymentMethod = $this->getExpressCheckoutPaymentMethod();
         $buyerData = $paymentMethod->getProcessor()->doGetExpressCheckoutDetails($paymentMethod, $request->token);
         if (empty($buyerData)) {
             \XLite\Core\TopMessage::getInstance()->addError('Your address data was not received from PayPal.');
         } else {
             // Fill the cart with data received from Paypal
             $this->requestData = $this->prepareBuyerData($buyerData);
             $this->updateProfile();
             $this->requestData['billingAddress'] = $this->requestData['shippingAddress'];
             $this->requestData['same_address'] = true;
             $this->updateShippingAddress();
             $this->updateBillingAddress();
         }
     }
 }
Exemple #10
0
 /**
  * Process return
  *
  * @param \XLite\Model\Payment\Transaction $transaction Return-owner transaction
  *
  * @return void
  */
 public function processReturn(\XLite\Model\Payment\Transaction $transaction)
 {
     parent::processReturn($transaction);
     $request = \XLite\Core\Request::getInstance();
     $status = 1 == $request->x_response_code ? $transaction::STATUS_SUCCESS : $transaction::STATUS_FAILED;
     if (isset($request->x_response_reason_text)) {
         $this->setDetail('response', $request->x_response_reason_text, 'Response');
         $this->transaction->setNote($request->x_response_reason_text);
     } elseif (isset($this->err[$request->x_response_reason_code])) {
         $this->setDetail('response', $this->err[$request->x_response_reason_code], 'Response');
         $this->transaction->setNote($this->err[$request->x_response_reason_code]);
     }
     if ($request->x_auth_code) {
         $this->setDetail('authCode', $request->x_auth_code, 'Auth code');
     }
     if ($request->x_trans_id) {
         $this->setDetail('transId', $request->x_trans_id, 'Transaction ID');
     }
     if ($request->x_response_subcode) {
         $this->setDetail('responseSubcode', $request->x_response_subcode, 'Response subcode');
     }
     if (isset($request->x_avs_code) && isset($this->avserr[$request->x_avs_code])) {
         $this->setDetail('avs', $this->avserr[$request->x_avs_code], 'AVS status');
     }
     if (isset($request->x_CVV2_Resp_Code) && isset($this->cvverr[$request->x_CVV2_Resp_Code])) {
         $this->setDetail('cvv', $this->cvverr[$request->x_CVV2_Resp_Code], 'CVV status');
     }
     if (!$this->checkTotal($request->x_amount)) {
         $status = $transaction::STATUS_FAILED;
     }
     $this->transaction->setStatus($status);
 }
Exemple #11
0
 /**
  * getDefaultParams
  *
  * @return array
  */
 protected function getDefaultParams()
 {
     $result = parent::getDefaultParams();
     $result['target'] = \XLite\Core\Request::getInstance()->target;
     $result['action'] = 'modify';
     return $result;
 }
Exemple #12
0
 /**
  * Action of license key registration
  *
  * @return void
  */
 protected function doActionRegisterKey()
 {
     $key = \XLite\Core\Request::getInstance()->key;
     $addonsInfo = \XLite\Core\Marketplace::getInstance()->checkAddonKey($key);
     if ($addonsInfo && $addonsInfo[$key]) {
         $addonsInfo = $addonsInfo[$key];
         $repo = \XLite\Core\Database::getRepo('\\XLite\\Model\\ModuleKey');
         foreach ($addonsInfo as $info) {
             $module = \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->findOneBy(array('author' => $info['author'], 'name' => $info['name']));
             if ($module) {
                 $entity = $repo->findKey($info['author'], $info['name']);
                 if ($entity) {
                     $entity->setKeyValue($key);
                     $repo->update($entity);
                 } else {
                     $entity = $repo->insert($info + array('keyValue' => $key));
                 }
                 \XLite\Core\Database::getEM()->flush();
                 // Clear cache for proper installation
                 \XLite\Core\Marketplace::getInstance()->clearActionCache(\XLite\Core\Marketplace::ACTION_GET_ADDONS_LIST);
                 $this->showInfo(__FUNCTION__, 'License key has been successfully verified for "{{name}}" module by "{{author}}" author', array('name' => $module->getModuleName(), 'author' => $module->getAuthorName()));
             } else {
                 $this->showError(__FUNCTION__, 'Key is validated, but the module [' . implode(',', $info) . '] was not found');
             }
         }
     } else {
         $error = \XLite\Core\Marketplace::getInstance()->getError();
         if ($error) {
             $this->showError(__FUNCTION__, 'Response from marketplace: ' . $error);
         } else {
             $this->showError(__FUNCTION__, 'Response from marketplace is not received');
         }
     }
     $this->setReturnURL($this->buildURL('addons_list_marketplace'));
 }
Exemple #13
0
 /**
  * Update model
  *
  * @return void
  */
 protected function doActionUpdate()
 {
     $this->getModelForm()->performAction('modify');
     if (!\XLite\Core\Request::getInstance()->id) {
         $this->setReturnURL($this->buildURL('page', '', array('id' => $this->getModelForm()->getModelObject()->getId())));
     }
 }
Exemple #14
0
 /**
  * Handle request 
  *
  * @return void
  */
 public function handleRequest()
 {
     if (\XLite\Core\Request::getInstance()->action != 'add' && \XLite\Module\CDev\XPaymentsConnector\Core\Settings::getInstance()->checkUpdateAllowedModules()) {
         \XLite\Module\CDev\XPaymentsConnector\Core\Settings::getInstance()->importAllowedModules();
     }
     parent::handleRequest();
 }
Exemple #15
0
 /**
  * Update payment method
  *
  * @return void
  */
 protected function doActionUpdate()
 {
     $settings = \XLite\Core\Request::getInstance()->settings;
     $method = $this->getPaymentMethod();
     if (!$method) {
         \XLite\Core\TopMessage::addError('An attempt to update settings of unknown payment method');
     } else {
         if (is_array($settings)) {
             foreach ($settings as $name => $value) {
                 $method->setSetting($name, trim($value));
             }
         }
         $properties = \XLite\Core\Request::getInstance()->properties;
         if (is_array($properties) && !empty($properties)) {
             $method->map($properties);
         }
         \XLite\Core\Database::getRepo('\\XLite\\Model\\Payment\\Method')->update($method);
         // If "just added" method is configured and can be enabled then we enable it
         if (\XLite\Core\Request::getInstance()->just_added && $method->isConfigured() && $method->canEnable()) {
             $method->setEnabled(true);
             \XLite\Core\Database::getEM()->flush();
         }
         if ($method->isConfigured()) {
             \XLite\Core\TopMessage::addInfo('The settings of payment method successfully updated');
             $this->setReturnURL($this->buildURL('payment_settings'));
         } else {
             \XLite\Core\TopMessage::addWarning('Payment method has not been configured properly');
         }
     }
 }
Exemple #16
0
 /**
  * Returns shipping method
  *
  * @return \XLite\Model\Shipping\Method
  */
 protected function getMethod()
 {
     if (null === $this->method) {
         $this->method = \XLite\Core\Database::getRepo('XLite\\Model\\Shipping\\Method')->find(\XLite\Core\Request::getInstance()->methodId);
     }
     return $this->method;
 }
Exemple #17
0
 /**
  * Preprocessor for no-action ren
  *
  * @return void
  */
 protected function doNoAction()
 {
     parent::doNoAction();
     if (!\XLite\Core\Request::getInstance()->isAJAX()) {
         \XLite\Core\Session::getInstance()->continueShoppingURL = $this->getURL();
     }
 }
Exemple #18
0
 public function processReturn(\XLite\Model\Payment\Transaction $transaction)
 {
     parent::processReturn($transaction);
     $result = \XLite\Core\Request::getInstance()->status;
     $status = 'Paid' == $result ? $transaction::STATUS_PENDING : $transaction::STATUS_FAILED;
     $this->transaction->setStatus($status);
 }
Exemple #19
0
 /**
  * Define actions
  *
  * @return array
  */
 protected function defineActions()
 {
     $list = parent::defineActions();
     $list['import_language'] = array('class' => '\\XLite\\View\\Button\\FileSelector', \XLite\View\Button\AButton::PARAM_LABEL => static::t('Import language from CSV file'), \XLite\View\Button\FileSelector::PARAM_OBJECT => 'language', \XLite\View\Button\FileSelector::PARAM_FILE_OBJECT => 'file');
     $list['add_label'] = array('class' => '\\XLite\\View\\LanguagesModify\\Button\\AddNewLabel', \XLite\View\Button\AButton::PARAM_LABEL => static::t('Add new label'), \XLite\View\LanguagesModify\Button\AddNewLabel::PARAM_LANGUAGE => \XLite\Core\Request::getInstance()->code);
     return $list;
 }
Exemple #20
0
 /**
  * Return list of the form default parameters
  *
  * @return array
  */
 protected function getDefaultParams()
 {
     $list = parent::getDefaultParams();
     $list['atype'] = \XLite\Core\Request::getInstance()->atype;
     $list['addressId'] = $this->getCurrentAddressId();
     return $list;
 }
Exemple #21
0
 /**
  * handleRequest
  *
  * @return void
  */
 public function handleRequest()
 {
     if ($this->getModuleID() && 'CDev\\AmazonS3Images' == $this->getModule()->getActualName() && \XLite\Core\Request::getInstance()->isGet() && !\XLite\Core\TopMessage::getInstance()->getPreviousMessages()) {
         $this->checkAmazonS3Settings();
     }
     parent::handleRequest();
 }
Exemple #22
0
 /**
  * Validate return from Canada Post merchant registration process
  *
  * @return void
  */
 protected function capostValidateMerchant()
 {
     $token = \XLite\Core\Request::getInstance()->{'token-id'};
     $status = \XLite\Core\Request::getInstance()->{'registration-status'};
     if (\XLite\Module\XC\CanadaPost\Core\Service\Platforms::REG_STATUS_SUCCESS === $status) {
         // Registration is complete
         // Send request to Canada Post server to retrieve merchant details
         $data = \XLite\Module\XC\CanadaPost\Core\Service\Platforms::getInstance()->callGetMerchantRegistrationInfoByToken($token);
         if (isset($data->merchantInfo)) {
             // Update Canada Post settings
             $this->updateCapostMerchantSettings($data->merchantInfo);
             // Disable wizard
             $this->disableCapostWizard();
             \XLite\Core\TopMessage::getInstance()->addInfo('Registration process has been completed successfully.');
         } else {
             foreach ($data->errors as $err) {
                 \XLite\Core\TopMessage::getInstance()->addError('ERROR: [' . $err->code . '] ' . $err->description);
             }
         }
     } else {
         // An error occurred
         if (\XLite\Module\XC\CanadaPost\Core\Service\Platforms::REG_STATUS_CANCELLED === $status) {
             \XLite\Core\TopMessage::getInstance()->addError('Registration process has been canceled.');
         } else {
             \XLite\Core\TopMessage::getInstance()->addError('Failure to finish registration process.');
         }
     }
     // Remove token from the session
     \XLite\Core\Session::getInstance()->capost_token_id = null;
     \XLite\Core\Session::getInstance()->capost_token_ts = null;
     // Redirect back to the Canada Post settings page
     $this->setReturnURL($this->buildURL('capost'));
 }
Exemple #23
0
    /**
     * Preprocessor for no-action reaction
     *
     * @return void
     */
    protected function doNoAction()
    {
        parent::doNoAction();
        $content = \XLite\Core\Request::getInstance()->id ? \XLite\Core\Database::getRepo('XLite\\Model\\IframeContent')->find(\XLite\Core\Request::getInstance()->id) : null;
        if ($content) {
            $method = $content->getMethod();
            $url = $content->getUrl();
            $body = $this->assembleFormBody($content);
            $html = <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body onload="javascript: document.getElementById('payment_form').submit();">
  <form method="{$method}" id="payment_form" name="payment_form" action="{$url}">
    <fieldset style="display: none;">
{$body}
    </fieldset>
  </form>
</body>
</html>
HTML;
            print $html;
            exit;
        } else {
            $this->redirect(\XLite\Core\Converter::buildURL('checkout'));
        }
    }
Exemple #24
0
 /**
  * Send current cart details back to X-Payments.   
  *
  * @return void
  */
 protected function doActionCheckCart()
 {
     $refId = \XLite\Core\Request::getInstance()->refId;
     $transaction = $this->detectTransaction();
     $xml = '';
     if ($transaction) {
         $cart = $transaction->getOrder();
         $response = array('status' => 'cart-changed', 'ref_id' => $refId);
         $clientXpayments = \XLite\Module\CDev\XPaymentsConnector\Core\XPaymentsClient::getInstance();
         if (method_exists($transaction, 'isAntiFraudApplied') && method_exists($transaction, 'checkBlockOrder') && $transaction->isAntiFraudApplied() && $transaction->checkBlockOrder(true)) {
             // ANTIFRAUD RELATED CHANGES
             // This makes a error top messsage at checkout
             $transaction->setDataCell('status', 'AF Error #1: Cannot process this order. Contact administrator', null, 'C');
         } else {
             // Prepare cart
             $preparedCart = $clientXpayments->prepareCart($cart, $transaction->getPaymentMethod(), $refId);
             if ($cart && $preparedCart) {
                 $response['cart'] = $preparedCart;
             }
         }
         try {
             // Convert array to XML and encrypt it
             $xml = $clientXpayments->encryptRequest($response);
         } catch (\XLite\Module\CDev\XPaymentsConnector\Core\XpcResponseException $exception) {
             // Doesn't matter, but al least we can send something
             $xml = $exception->getMessage();
         }
         print $xml;
         die(0);
     }
 }
Exemple #25
0
 /**
  * Get validator
  *
  * @return \XLite\Core\Validator\HashArray
  */
 protected function getValidator()
 {
     $validator = parent::getValidator();
     $validator->addPair('email', new \XLite\Core\Validator\String\Email(), \XLite\Core\Validator\Pair\APair::SOFT);
     $validator->addPair('create_profile', new \XLite\Core\Validator\String\Switcher(), \XLite\Core\Validator\Pair\APair::SOFT);
     $validator->addPair('same_address', new \XLite\Core\Validator\String\Switcher(), \XLite\Core\Validator\Pair\APair::SOFT);
     $onlyCalculate = (bool) \XLite\Core\Request::getInstance()->only_calculate;
     $mode = $onlyCalculate ? \XLite\Core\Validator\Pair\APair::SOFT : \XLite\Core\Validator\Pair\APair::STRICT;
     $nonEmpty = !$onlyCalculate;
     // Shipping address
     $shippingAddress = $validator->addPair('shippingAddress', new \XLite\Core\Validator\HashArray(), \XLite\Core\Validator\Pair\APair::SOFT);
     $shippingAddress->addPair('name', new \XLite\Core\Validator\String($nonEmpty), $mode);
     $shippingAddress->addPair('street', new \XLite\Core\Validator\String($nonEmpty), $mode);
     $shippingAddress->addPair('city', new \XLite\Core\Validator\String($nonEmpty), $mode);
     $shippingAddress->addPair('zipcode', new \XLite\Core\Validator\String(true));
     $shippingAddress->addPair('phone', new \XLite\Core\Validator\String(), $mode);
     $shippingAddress->addPair(new \XLite\Core\Validator\Pair\CountryState());
     $shippingAddress->addPair('save_as_new', new \XLite\Core\Validator\String\Switcher(), \XLite\Core\Validator\Pair\APair::SOFT);
     // Billing address
     if (!\XLite\Core\Request::getInstance()->same_address) {
         $billingAddress = $validator->addPair('billingAddress', new \XLite\Core\Validator\HashArray(), \XLite\Core\Validator\Pair\APair::SOFT);
         $billingAddress->addPair('name', new \XLite\Core\Validator\String(true));
         $billingAddress->addPair('street', new \XLite\Core\Validator\String(true));
         $billingAddress->addPair('city', new \XLite\Core\Validator\String(true));
         $billingAddress->addPair('zipcode', new \XLite\Core\Validator\String(true));
         $billingAddress->addPair('phone', new \XLite\Core\Validator\String());
         $billingAddress->addPair(new \XLite\Core\Validator\Pair\CountryState());
         $billingAddress->addPair('save_as_new', new \XLite\Core\Validator\String\Switcher(), \XLite\Core\Validator\Pair\APair::SOFT);
     }
     return $validator;
 }
Exemple #26
0
 /**
  * Preprocessor for no-action ren
  *
  * @return void
  */
 protected function doNoAction()
 {
     parent::doNoAction();
     if (!\XLite\Core\Request::getInstance()->isAJAX()) {
         \XLite\Core\Session::getInstance()->productListURL = $this->getURL();
     }
 }
Exemple #27
0
 /**
  * Populate model object properties by the passed data
  *
  * @param array $data Data to set
  *
  * @return void
  */
 protected function setModelProperties(array $data)
 {
     $data['useCustomOG'] = $this->getPostedData('useCustomOG');
     $nonFilteredData = \XLite\Core\Request::getInstance()->getNonFilteredData();
     $data['ogMeta'] = isset($nonFilteredData['postedData']['ogMeta']) ? $nonFilteredData['postedData']['ogMeta'] : '';
     parent::setModelProperties($data);
 }
Exemple #28
0
 /**
  * Check if widget is visible
  *
  * @return boolean
  */
 protected function isVisible()
 {
     if (\XLite\Core\Request::getInstance()->target == 'amazon_checkout') {
         return false;
     } else {
         return parent::isVisible();
     }
 }
Exemple #29
0
 /**
  * Return product variant
  *
  * @return \XLite\Module\XC\ProductVariants\Model\ProductVariant
  */
 public function getProductVariant()
 {
     if (is_null($this->productVariant)) {
         $repo = \XLite\Core\Database::getRepo('XLite\\Module\\XC\\ProductVariants\\Model\\ProductVariant');
         $this->productVariant = $repo->find((int) \XLite\Core\Request::getInstance()->id);
     }
     return $this->productVariant;
 }
Exemple #30
0
 /**
  * Argument convertion: <LC> --> <DRUPAL>
  *
  * @param string $path Drupal path
  * @param array  $args LC URL arguments OPTIONAL
  *
  * @return array
  */
 public static function getPortalDrupalArgs($path, array $args = array())
 {
     $id = empty($args['profile_id']) ? \XLite\Core\Request::getInstance()->profile_id : $args['profile_id'];
     unset($args['profile_id']);
     list($path, $args) = parent::getPortalDrupalArgs($path, $args);
     $path = preg_replace('/\\%/', static::getDrupalProfileId($id), $path, 1);
     return array($path, $args);
 }