示例#1
0
 /**
  * Handles the request.
  * Parses the request variables if necessary. Attempts to call the specified action function
  *
  * @return void
  */
 public function handleRequest()
 {
     if (\XLite\Core\Session::getInstance()->xpc_order_create_profile && $this->getOrder() && $this->getOrder()->getOrderId() && (!\XLite\Core\Session::getInstance()->last_order_id || !$this->getCart()->getOrderId())) {
         $this->getCart()->setOrderId($this->getOrder()->getOrderId());
         \XLite\Core\Session::getInstance()->last_order_id = $this->getOrder()->getOrderId();
         parent::handleRequest();
         $this->getCart()->setOrderId(null);
         \XLite\Core\Session::getInstance()->last_order_id = null;
         \XLite\Core\Session::getInstance()->xpc_order_create_profile = null;
         // Cleanup fake carts from session
         \XLite\Module\CDev\XPaymentsConnector\Core\ZeroAuth::cleanupFakeCarts($this->getProfile());
     } else {
         parent::handleRequest();
     }
 }
示例#2
0
 /**
  * Is zero-auth (card setup) allowed
  *
  * @return bool
  */
 public function allowZeroAuth()
 {
     return \XLite\Module\CDev\XPaymentsConnector\Core\ZeroAuth::getInstance()->allowZeroAuth();
 }
 /**
  * Get default options
  *
  * @return array
  */
 protected function getDefaultOptions()
 {
     $result = array(\XLite\Module\CDev\XPaymentsConnector\Core\ZeroAuth::DISABLED => \XLite\Core\Translation::lbl('Do not use card setup'));
     $result += \XLite\Module\CDev\XPaymentsConnector\Core\ZeroAuth::getInstance()->getCanSaveCardsMethods(true);
     return $result;
 }
示例#4
0
 /**
  * Get iframe URL
  *
  * @return string
  */
 public function getIframeUrl()
 {
     return \XLite\Module\CDev\XPaymentsConnector\Core\ZeroAuth::getInstance()->getIframeUrl($this->getCustomerProfile(), \XLite::getAdminScript());
 }
示例#5
0
 /**
  * Check cart callback 
  *
  * @return void
  */
 protected function doActionCheckCart()
 {
     \XLite\Module\CDev\XPaymentsConnector\Core\ZeroAuth::getInstance()->doActionCheckCart();
 }
示例#6
0
文件: Xpc.php 项目: kirkbauer2/kirkxc
 /**
  * Update payment methods: save cards, currency, etc 
  *
  * @return void
  */
 protected function doActionUpdatePaymentMethods()
 {
     $methods = $this->getPaymentMethods();
     $request = \XLite\Core\Request::getInstance()->data;
     $config = \XLite\Core\Config::getInstance()->CDev->XPaymentsConnector;
     $saveCardsMethodSubmitted = false;
     foreach ($methods as $method) {
         $pmData = \XLite\Core\Request::getInstance()->data[$method->getMethodId()];
         if (isset($pmData['save_cards']) && 'Y' == $pmData['save_cards'] && 'Y' == $method->getSetting('canSaveCards')) {
             $method->setSetting('saveCards', 'Y');
             if (!empty($pmData['enabled']) && !$saveCardsMethodSubmitted) {
                 // The second condition is not necesary.
                 // But in this case noone will ask,
                 // why the last method is set for zero auth instead of first
                 $saveCardsMethodSubmitted = $method;
             }
         } else {
             $method->setSetting('saveCards', 'N');
         }
         if (isset($pmData['currency']) && $pmData['currency']) {
             $method->setSetting('currency', $pmData['currency']);
         }
         if (isset($pmData['enabled']) && $pmData['enabled']) {
             $method->setEnabled(true);
         } else {
             $method->setEnabled(false);
         }
     }
     $saveCardsMethodInStore = $this->getPaymentMethods('SavedCard');
     if (!$saveCardsMethodInStore && $saveCardsMethodSubmitted) {
         // Add Saved credit card payment method if at least one of X-Payments payment methods saves cards
         $pm = new \XLite\Model\Payment\Method();
         \XLite\Core\Database::getEM()->persist($pm);
         $pm->setClass('Module\\CDev\\XPaymentsConnector\\Model\\Payment\\Processor\\SavedCard');
         $pm->setServiceName('SavedCard');
         $pm->setName('Use a saved credit card');
         $pm->setType(\XLite\Model\Payment\Method::TYPE_CC_GATEWAY);
         $pm->setAdded(true);
         $pm->setEnabled(true);
     } elseif ($saveCardsMethodInStore && !$saveCardsMethodSubmitted) {
         // Remove Seved credit card payment method if all X-Payments payment methods do not save cards
         foreach ($saveCardsMethodInStore as $pm) {
             \XLite\Core\Database::getEM()->remove($pm);
         }
     }
     // Configure the Zero Auth if it's not done yet
     if ($saveCardsMethodSubmitted && !\XLite\Module\CDev\XPaymentsConnector\Core\ZeroAuth::getInstance()->allowZeroAuth() && !\XLite\Module\CDev\XPaymentsConnector\Core\ZeroAuth::DISABLED == $config->xpc_zero_auth_method_id) {
         $settings = array('xpc_zero_auth_method_id' => $saveCardsMethodSubmitted->getMethodId());
         if (!$config->xpc_zero_auth_amount) {
             $settings['xpc_zero_auth_amount'] = '1.00';
         }
         if (!$config->xpc_zero_auth_description) {
             $settings['xpc_zero_auth_description'] = \XLite\Module\CDev\XPaymentsConnector\Core\ZeroAuth::getDefaultDescription();
         }
         foreach ($settings as $key => $value) {
             $setting = \XLite\Core\Database::getRepo('XLite\\Model\\Config')->findOneBy(array('name' => $key, 'category' => 'CDev\\XPaymentsConnector'));
             \XLite\Core\Database::getRepo('XLite\\Model\\Config')->update($setting, array('value' => $value));
         }
     }
     \XLite\Core\Database::getEM()->flush();
     \XLite\Core\Config::updateInstance();
 }