protected function _toHtml() { try { $form = new Varien_Data_Form(); $form->setAction($this->_getSageSession()->getAcsurl())->setId('sagepaydirectpro_3dsecure')->setName('sagepaydirectpro_3dsecure')->setMethod('POST')->setUseContainer(true); $params = array('_secure' => true, 'storeid' => Mage::app()->getStore()->getId()); $_shipSessData = Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->getShippingMethod(); if ($_shipSessData) { $params['shipmethod'] = $_shipSessData; } $postUrl = Mage::getModel('core/url')->addSessionParam()->getUrl('sgps/directPayment/callback3d', $params); $form->addField('PaReq', 'hidden', array('name' => 'PaReq', 'value' => $this->_getSageSession()->getPareq())); $form->addField('MD', 'hidden', array('name' => 'MD', 'value' => $this->_getSageSession()->getEmede())); #$form->addField('TermUrl', 'hidden', array('name'=>'TermUrl', 'value' => Mage::getUrl('sgps/directPayment/callback3d', array('_secure' => true)))); $form->addField('TermUrl', 'hidden', array('name' => 'TermUrl', 'value' => $postUrl)); $html = '<html><body>'; $html .= '<code>' . $this->__('Loading 3D secure form...') . '</code>'; $html .= $form->toHtml(); $html .= '<script type="text/javascript">document.getElementById("sagepaydirectpro_3dsecure").submit();</script>'; $html .= '</body></html>'; Sage_Log::log($html, null, 'SagePaySuite_REQUEST.log'); } catch (Exception $e) { Ebizmarts_SagePaySuite_Log::we($e); } return $html; }
/** * Return all customer cards list for onepagecheckout use. */ public function getTokenCardsHtmlAction() { $html = ''; $_code = $this->getRequest()->getPost('payment_method', 'sagepaydirectpro'); try { $html .= $this->getLayout()->createBlock('sagepaysuite/form_tokenList', 'token.cards.li')->setCanUseToken(true)->setPaymentMethodCode($_code)->toHtml(); } catch (Exception $e) { Ebizmarts_SagePaySuite_Log::we($e); } return $this->getResponse()->setBody(str_replace(array('<div id="tokencards-payment-' . $_code . '">', '</div>'), array(), $html)); }
public function registerTokenAction() { $resultData = array(); try { $resultData = $this->getDirectModel()->registerTransaction($this->getRequest()->getPost(), true); } catch (Exception $e) { Ebizmarts_SagePaySuite_Log::we($e); $resultData['success'] = 'false'; $resultData['response_status'] = 'ERROR'; $resultData['response_status_detail'] = $e->getMessage(); } return $this->getResponse()->setBody(Zend_Json::encode($resultData)); }
public function fraudCheckAction() { if ($this->getRequest()->isPost()) { #Mass action $orderIds = $this->getRequest()->getPost('order_ids', array()); foreach ($orderIds as $orderId) { $_order = Mage::getModel('sales/order')->load($orderId); $rs = $this->getFraud()->getTransactionDetails($_order->getVendorTxCode()); if ($rs[0] != '<') { $this->_getSession()->addError($this->__('An error ocurred: %s %s', $_order->getVendorTxCode(), $rs)); continue; } $xml = new Varien_Simplexml_Element($rs); if ((string) $xml->errorcode != '0000') { $this->_getSession()->addError((string) $xml->error . ' ' . $_order->getVendorTxCode()); } else { try { $this->getFraud()->updateThirdMan($orderId, $xml); $this->_getSession()->addSuccess($this->__('Updated: Order Id #%s', $_order->getIncrementId())); } catch (Exception $e) { Ebizmarts_SagePaySuite_Log::we($e); $this->_getSession()->addError($_order->getVendorTxCode() . ' ' . $e->getMessage); } } } } else { $orderId = $this->getRequest()->getParam('order_id'); $_order = Mage::getModel('sales/order')->load($orderId); $rs = $this->getFraud()->getTransactionDetails($_order->getVendorTxCode()); if ($rs[0] != '<') { $this->_getSession()->addError($this->__('An error ocurred: %s', $rs)); $this->_redirectReferer(); return; } else { $xml = new Varien_Simplexml_Element($rs); if ((string) $xml->errorcode != '0000') { $this->_getSession()->addError((string) $xml->error . ' ' . $_order->getVendorTxCode()); } else { try { $this->getFraud()->updateThirdMan($orderId, $xml); $this->_getSession()->addSuccess($this->__('Updated: Order Id #%s', $_order->getIncrementId())); } catch (Exception $e) { Ebizmarts_SagePaySuite_Log::we($e); $this->_getSession()->addError($_order->getVendorTxCode() . ' ' . $e->getMessage()); } } } } $this->_redirectReferer(); return; }
public function fraudCheckAction() { if ($this->getRequest()->isPost()) { #Mass action $orderIds = $this->getRequest()->getPost('order_ids', array()); foreach ($orderIds as $orderId) { $_order = Mage::getModel('sales/order')->load($orderId); Mage::register('reporting_store_id', $_order->getStoreId()); $rs = $this->getFraud()->getTransactionDetails($_order->getSagepayInfo()->getVendorTxCode()); if ($rs->getError()) { Mage::unregister('reporting_store_id'); $this->_getSession()->addError($this->__('An error ocurred: %s %s', $_order->getVendorTxCode(), $rs)); continue; } if ($rs->getError()) { $this->_getSession()->addError((string) $xml->error . ' ' . $_order->getVendorTxCode()); } else { try { $this->getPersistentFraud()->updateThirdMan($orderId, $rs); $this->_getSession()->addSuccess($this->__('Updated: Order Id #%s', $_order->getIncrementId())); } catch (Exception $e) { Ebizmarts_SagePaySuite_Log::we($e); $this->_getSession()->addError($_order->getVendorTxCode() . ' ' . $e->getMessage); } } Mage::unregister('reporting_store_id'); } } else { $orderId = $this->getRequest()->getParam('order_id'); $_order = Mage::getModel('sales/order')->load($orderId); Mage::register('reporting_store_id', $_order->getStoreId()); $rs = $this->getFraud()->getTransactionDetails($_order->getSagepayInfo()->getVendorTxCode()); if ($rs->getError()) { $this->_getSession()->addError($this->__('An error ocurred: %s', htmlentities($rs->getError()))); $this->_redirectReferer(); return; } else { try { $this->getPersistentFraud()->updateThirdMan($orderId, $rs); $this->_getSession()->addSuccess($this->__('Updated: Order Id #%s', $_order->getIncrementId())); } catch (Exception $e) { Ebizmarts_SagePaySuite_Log::we($e); $this->_getSession()->addError($_order->getVendorTxCode() . ' ' . htmlentities($e->getMessage())); } } } $this->_redirectReferer(); return; }
public function getIpAddress() { try { /*$xml = file_get_contents('http://ip-address.domaintools.com/myip.xml'); $xml = new Varien_Simplexml_Element($xml); $ip = (string)$xml->ip_address;*/ $ip = explode('.', file_get_contents('https://ebizmarts.com/magento/ipcheck.php')); $ip = array_map(array($this, 'pad'), $ip); return implode('.', $ip); } catch (Exception $e) { Ebizmarts_SagePaySuite_Log::we($e); return ''; } }
/** * Retrieve feed data as XML element * * @return SimpleXMLElement */ public function getFeedData() { $curl = new Varien_Http_Adapter_Curl(); $curl->setConfig(array('timeout' => 60)); $curl->write(Zend_Http_Client::GET, $this->getFeedUrl(), '1.0'); $data = $curl->read(); if ($data === false) { return false; } $data = preg_split('/^\\r?$/m', $data, 2); $data = trim($data[1]); $curl->close(); try { $xml = new SimpleXMLElement($data); } catch (Exception $e) { Ebizmarts_SagePaySuite_Log::we($e); return false; } return $xml; }
protected function _getUpdates() { $feedData = array(); try { $node = $this->getFeedData(); if (!$node) { return false; } foreach ($node->children() as $item) { $feedData[] = array('severity' => (string) $item->severity, 'date_added' => (string) $item->date_added, 'title' => (string) $item->title, 'description' => (string) $item->description, 'url' => (string) $item->url); } if ($feedData) { Mage::getModel('adminnotification/inbox')->parse($feedData); } Mage::app()->saveCache(time(), 'sagepaysuite_updates_feed_lastcheck'); return true; } catch (Exception $e) { Ebizmarts_SagePaySuite_Log::we($e); return false; } }
/** * Post transaction to SagePay - PayPal */ public function goAction() { try { $this->_initCheckout(); $customer = Mage::getSingleton('customer/session')->getCustomer(); if (!$this->_quote->getCustomerId() && $customer && $customer->getId()) { $this->_checkout->setCustomer($customer); } $rs = $this->_checkout->start(); if (is_string($rs)) { $this->_redirectUrl($rs); return; } } catch (Exception $e) { $this->_getCheckoutSession()->addError($e->getMessage()); Ebizmarts_SagePaySuite_Log::we($e); } $this->_redirect('checkout/cart', array('_secure' => true)); return; }
public static function logException(Exception $e) { Ebizmarts_SagePaySuite_Log::we($e); }