Beispiel #1
0
 /**
  * Modify request to allow start Express Checkout process
  * 
  * @return void
  */
 public function handleRequest()
 {
     if (isset(\XLite\Core\Request::getInstance()->action) && $this->isExpressCheckoutAction() && $this->getCart()->checkCart()) {
         \XLite\Core\Request::getInstance()->setRequestMethod('POST');
     }
     parent::handleRequest();
 }
Beispiel #2
0
 /**
  * Checkout. Recognize iframe and save that 
  *
  * @return void
  */
 public function handleRequest()
 {
     if ('checkout' == \XLite\Core\Request::getInstance()->action && !\XLite\Core\Request::getInstance()->xpc_iframe) {
         \XLite\Core\Session::getInstance()->cardSavedAtCheckout = \XLite\Core\Request::getInstance()->save_card;
     } elseif (\XLite\Core\Request::getInstance()->xpc_iframe && 'checkout' == \XLite\Core\Request::getInstance()->action) {
         // Enable iframe
         $this->getIframe()->enable();
         // If checkout is not ready finalize the iframe
         if (!$this->isCheckoutReady() || !$this->checkCheckoutAction()) {
             $this->getIframe()->setError('');
             $this->getIframe()->setType(\XLite\Module\CDev\XPaymentsConnector\Core\Iframe::IFRAME_DO_NOTHING);
             $this->getIframe()->finalize();
         }
         // It's not initialized yet
         $this->initialCartFingerprint = $this->getCart()->getEventFingerprint();
         // Update cart and just in case check the items.
         // Copy-pasted from \XLite\Controller\Customer::doActionCheckout()
         $itemsBeforeUpdate = $this->getCart()->getItemsFingerprint();
         $this->updateCart();
         $itemsAfterUpdate = $this->getCart()->getItemsFingerprint();
         if ($this->get('absence_of_product') || $this->getCart()->isEmpty() || $itemsAfterUpdate != $itemsBeforeUpdate) {
             // Cart is changed
             $this->set('absence_of_product', true);
             $this->setReturnUrl($this->buildURL('cart'));
             $this->getIframe()->setError('Cart changed...');
             $this->getIframe()->setType(\XLite\Module\CDev\XPaymentsConnector\Core\Iframe::IFRAME_ALERT);
             $this->getIframe()->finalize();
         }
         $transaction = $this->getCart()->getFirstOpenPaymentTransaction();
         $class = 'Module\\CDev\\XPaymentsConnector\\Model\\Payment\\Processor\\XPayments';
         if (!$transaction || !$transaction->getPaymentMethod() || $class != $transaction->getPaymentMethod()->getClass()) {
             // Action Checkout with "xpc_iframe" parameter was called.
             // But open transaction was not found, or a different processor is used
             // So exit.
             print 'DEBUG. No transaction...';
             die(0);
         }
     }
     parent::handleRequest();
 }