diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..8ef92da --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,48 @@ +Open Software License ("OSL") v. 3.0 +==================================== + +This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Open Software License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + a) to reproduce the Original Work in copies, either alone or as part of a collective work; + + b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + c) to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; + + d) to perform the Original Work publicly; and + + e) to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright (c) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. diff --git a/composer.json b/composer.json index ae9555b..3992ad5 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name":"fontis/eway", "type":"magento-module", "license":"Open Software License (OSL 3.0)", - "description":"This extension uses the eWAY Australia payment gateway for credit card processing..", + "description":"This extension uses the eWAY Australia payment gateway for credit card processing.", "homepage":"http://www.fontis.com.au", "authors":[ { @@ -53,6 +53,11 @@ "type":"magelocale", "structure":"file", "path":"en_US/Fontis_EwayAu.csv" + }, + { + "type":"mageskin", + "structure":"dir", + "path":"adminhtml/default/default/fontis/ewayau" } ] } diff --git a/modman b/modman index 5eb408f..f02e364 100644 --- a/modman +++ b/modman @@ -2,10 +2,12 @@ # see https://github.com/colinmollenhour/modman/ for more info # Fontis eWAY Australia -src/app/code/community/Fontis/EwayAu app/code/community/Fontis/EwayAu -src/app/etc/modules/Fontis_EwayAu.xml app/etc/modules/Fontis_EwayAu.xml -src/app/design/adminhtml/default/default/template/fontis/ewayau app/design/adminhtml/default/default/template/fontis/ewayau -src/app/design/frontend/base/default/layout/fontis_ewayau.xml app/design/frontend/base/default/layout/fontis_ewayau.xml -src/app/design/frontend/base/default/template/fontis/ewayau app/design/frontend/base/default/template/fontis/ewayau -src/app/locale/en_AU/Fontis_EwayAu.csv app/locale/en_AU/Fontis_EwayAu.csv -src/app/locale/en_US/Fontis_EwayAu.csv app/locale/en_US/Fontis_EwayAu.csv +src/app/code/community/Fontis/EwayAu app/code/community/Fontis/EwayAu +src/app/etc/modules/Fontis_EwayAu.xml app/etc/modules/Fontis_EwayAu.xml +src/app/design/adminhtml/default/default/layout/fontis/ewayau.xml app/design/adminhtml/default/default/layout/fontis/ewayau.xml +src/app/design/adminhtml/default/default/template/fontis/ewayau app/design/adminhtml/default/default/template/fontis/ewayau +src/app/design/frontend/base/default/layout/fontis/ewayau.xml app/design/frontend/base/default/layout/fontis/ewayau.xml +src/app/design/frontend/base/default/template/fontis/ewayau app/design/frontend/base/default/template/fontis/ewayau +src/app/locale/en_AU/Fontis_EwayAu.csv app/locale/en_AU/Fontis_EwayAu.csv +src/app/locale/en_US/Fontis_EwayAu.csv app/locale/en_US/Fontis_EwayAu.csv +src/skin/adminhtml/default/default/fontis/ewayau skin/adminhtml/default/default/fontis/ewayau diff --git a/src/app/code/community/Fontis/EwayAu/Block/Cc/Form.php b/src/app/code/community/Fontis/EwayAu/Block/Cc/Form.php new file mode 100644 index 0000000..47a21f9 --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Block/Cc/Form.php @@ -0,0 +1,27 @@ +setTemplate('fontis/ewayau/cc/form.phtml'); + } +} diff --git a/src/app/code/community/Fontis/EwayAu/Block/Info.php b/src/app/code/community/Fontis/EwayAu/Block/Cc/Info.php similarity index 54% rename from src/app/code/community/Fontis/EwayAu/Block/Info.php rename to src/app/code/community/Fontis/EwayAu/Block/Cc/Info.php index 1a7c620..f159d95 100644 --- a/src/app/code/community/Fontis/EwayAu/Block/Info.php +++ b/src/app/code/community/Fontis/EwayAu/Block/Cc/Info.php @@ -5,30 +5,32 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Fontis_EwayAu_Block_Info extends Mage_Payment_Block_Info_Cc +class Fontis_EwayAu_Block_Cc_Info extends Mage_Payment_Block_Info_Cc { protected function _construct() { parent::_construct(); - $this->setTemplate('fontis/ewayau/info.phtml'); + $this->setTemplate('fontis/ewayau/cc/info.phtml'); } + /** + * @return string + */ public function toPdf() { - $this->setTemplate('fontis/ewayau/pdf/info.phtml'); + $this->setTemplate('fontis/ewayau/cc/pdf/info.phtml'); return $this->toHtml(); } - } diff --git a/src/app/code/community/Fontis/EwayAu/Block/Failure.php b/src/app/code/community/Fontis/EwayAu/Block/Failure.php new file mode 100644 index 0000000..6903a6d --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Block/Failure.php @@ -0,0 +1,39 @@ +getEwayErrorMessage(); + Mage::getSingleton('checkout/session')->unsEwayErrorMessage(); + return $msg; + } + + /** + * @return string + */ + public function getContinueShoppingUrl() + { + return Mage::helper('checkout')->getCartUrl(); + } +} diff --git a/src/app/code/community/Fontis/EwayAu/Block/Form.php b/src/app/code/community/Fontis/EwayAu/Block/Form.php index 30c6a42..d85e093 100644 --- a/src/app/code/community/Fontis/EwayAu/Block/Form.php +++ b/src/app/code/community/Fontis/EwayAu/Block/Form.php @@ -5,24 +5,28 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Fontis_EwayAu_Block_Form extends Mage_Payment_Block_Form_Cc +class Fontis_EwayAu_Block_Form extends Mage_Payment_Block_Form { + /** + * @var string + */ + protected $_formTemplate; + protected function _construct() { parent::_construct(); - $this->setTemplate('fontis/ewayau/form.phtml'); + $this->setTemplate('fontis/ewayau/' . $this->_formTemplate); } - } diff --git a/src/app/code/community/Fontis/EwayAu/Block/Redirect.php b/src/app/code/community/Fontis/EwayAu/Block/Redirect.php new file mode 100644 index 0000000..1840422 --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Block/Redirect.php @@ -0,0 +1,70 @@ +setAction($this->getRedirectUrl()) + ->setId($this->_formId) + ->setName($this->_formId) + ->setMethod('POST') + ->setUseContainer(true); + foreach ($this->getFormData() as $field => $value) { + $form->addField($field, 'hidden', array('name' => $field, 'value' => $value)); + } + + $html = ''; + $html.= $this->__('You will be redirected to %s in a few seconds.', $this->_redirectlabel); + $html.= $form->toHtml(); + $html.= ''; + $html.= ''; + + return $html; + } + + /** + * @return string + */ + abstract protected function getRedirectUrl(); + + /** + * @return array + */ + abstract protected function getFormData(); +} diff --git a/src/app/code/community/Fontis/EwayAu/Block/Secure/Failure.php b/src/app/code/community/Fontis/EwayAu/Block/Secure/Failure.php index 4ef9d1f..3c2e34e 100644 --- a/src/app/code/community/Fontis/EwayAu/Block/Secure/Failure.php +++ b/src/app/code/community/Fontis/EwayAu/Block/Secure/Failure.php @@ -5,26 +5,19 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Fontis_EwayAu_Block_Secure_Failure extends Mage_Core_Block_Template -{ - public function getErrorMessage () - { - return Mage::getSingleton('checkout/session')->getEwayErrorMessage(); - } - public function getContinueShoppingUrl() - { - return Mage::getUrl('checkout/cart'); - } +class Fontis_EwayAu_Block_Secure_Failure extends Fontis_EwayAu_Block_Failure +{ + // Concrete version of the abstract class. } diff --git a/src/app/code/community/Fontis/EwayAu/Block/Secure/Form.php b/src/app/code/community/Fontis/EwayAu/Block/Secure/Form.php index 88b4d73..4d2b0ce 100644 --- a/src/app/code/community/Fontis/EwayAu/Block/Secure/Form.php +++ b/src/app/code/community/Fontis/EwayAu/Block/Secure/Form.php @@ -5,23 +5,22 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ class Fontis_EwayAu_Block_Secure_Form extends Mage_Payment_Block_Form { - protected function _construct() - { - $this->setTemplate('fontis/ewayau/secure/form.phtml'); - parent::_construct(); - } + /** + * @var string + */ + protected $_formTemplate = 'secure/form.phtml'; } diff --git a/src/app/code/community/Fontis/EwayAu/Block/Secure/Redirect.php b/src/app/code/community/Fontis/EwayAu/Block/Secure/Redirect.php index bd4384d..71ad1c1 100644 --- a/src/app/code/community/Fontis/EwayAu/Block/Secure/Redirect.php +++ b/src/app/code/community/Fontis/EwayAu/Block/Secure/Redirect.php @@ -5,39 +5,51 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Fontis_EwayAu_Block_Secure_Redirect extends Mage_Core_Block_Abstract +class Fontis_EwayAu_Block_Secure_Redirect extends Fontis_EwayAu_Block_Redirect { - protected function _toHtml() + /** + * @var string + */ + protected $_formId = 'eway_secure_checkout'; + + /** + * @var string + */ + protected $_redirectlabel = 'eWAY 3D-Secure'; + + /** + * @return Fontis_EwayAu_Model_Secure + */ + protected function getMethodInstance() { - $secure = $this->getOrder()->getPayment()->getMethodInstance(); + return $this->getOrder()->getPayment()->getMethodInstance(); + } - $form = new Varien_Data_Form(); - $form->setAction($secure->getEwaySecureUrl()) - ->setId('ewayau_secure_checkout') - ->setName('ewayau_secure_checkout') - ->setMethod('POST') - ->setUseContainer(true); - foreach ($secure->getFormFields() as $field=>$value) { - $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value)); - } - $html = ''; - $html.= $this->__('You will be redirected to eWAY 3D-Secure in a few seconds.'); - $html.= $form->toHtml(); - $html.= ''; - $html.= ''; + /** + * @return string + */ + protected function getRedirectUrl() + { + return $this->getMethodInstance()->getEwaySecureUrl(); + } - return $html; + /** + * @return array + */ + protected function getFormData() + { + return $this->getMethodInstance()->getFormFields(); } } diff --git a/src/app/code/community/Fontis/EwayAu/Block/Shared/Failure.php b/src/app/code/community/Fontis/EwayAu/Block/Shared/Failure.php index e190421..3f3109d 100644 --- a/src/app/code/community/Fontis/EwayAu/Block/Shared/Failure.php +++ b/src/app/code/community/Fontis/EwayAu/Block/Shared/Failure.php @@ -5,29 +5,27 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Fontis_EwayAu_Block_Shared_Failure extends Mage_Core_Block_Template +class Fontis_EwayAu_Block_Shared_Failure extends Fontis_EwayAu_Block_Failure { - public function getErrorMessage () + /** + * @return string + */ + public function getErrorMessage() { - $msg = Mage::getSingleton('checkout/session')->getEwayErrorMessage(); + $msg = parent::getErrorMessage(); Mage::getSingleton('checkout/session')->unsEwayErrorMessage(); return $msg; } - - public function getContinueShoppingUrl() - { - return Mage::getUrl('checkout/cart'); - } } diff --git a/src/app/code/community/Fontis/EwayAu/Block/Shared/Form.php b/src/app/code/community/Fontis/EwayAu/Block/Shared/Form.php index 52b0d25..26616ea 100644 --- a/src/app/code/community/Fontis/EwayAu/Block/Shared/Form.php +++ b/src/app/code/community/Fontis/EwayAu/Block/Shared/Form.php @@ -5,23 +5,22 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ class Fontis_EwayAu_Block_Shared_Form extends Mage_Payment_Block_Form { - protected function _construct() - { - $this->setTemplate('fontis/ewayau/shared/form.phtml'); - parent::_construct(); - } + /** + * @var string + */ + protected $_formTemplate = 'shared/form.phtml'; } diff --git a/src/app/code/community/Fontis/EwayAu/Block/Shared/Redirect.php b/src/app/code/community/Fontis/EwayAu/Block/Shared/Redirect.php index f98573c..b1eaf9d 100644 --- a/src/app/code/community/Fontis/EwayAu/Block/Shared/Redirect.php +++ b/src/app/code/community/Fontis/EwayAu/Block/Shared/Redirect.php @@ -5,40 +5,51 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -class Fontis_EwayAu_Block_Shared_Redirect extends Mage_Core_Block_Abstract +class Fontis_EwayAu_Block_Shared_Redirect extends Fontis_EwayAu_Block_Redirect { - protected function _toHtml() - { - $shared = $this->getOrder()->getPayment()->getMethodInstance(); + /** + * @var string + */ + protected $_formId = 'ewayau_shared_checkout'; - $form = new Varien_Data_Form(); - $form->setAction($shared->getEwaySharedUrl()) - ->setId('ewayau_shared_checkout') - ->setName('ewayau_shared_checkout') - ->setMethod('POST') - ->setUseContainer(true); - foreach ($shared->getFormFields() as $field=>$value) { - $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value)); - } + /** + * @var string + */ + protected $_redirectlabel = 'eWAY'; - $html = ''; - $html.= $this->__('You will be redirected to eWAY in a few seconds.'); - $html.= $form->toHtml(); - $html.= ''; - $html.= ''; + /** + * @return Fontis_EwayAu_Model_Shared + */ + protected function getMethodInstance() + { + return $this->getOrder()->getPayment()->getMethodInstance(); + } - return $html; + /** + * @return string + */ + protected function getRedirectUrl() + { + return $this->getMethodInstance()->getEwaySharedUrl(); + } + + /** + * @return array + */ + protected function getFormData() + { + return $this->getMethodInstance()->getFormFields(); } } diff --git a/src/app/code/community/Fontis/EwayAu/Block/System/Config/Test/Login.php b/src/app/code/community/Fontis/EwayAu/Block/System/Config/Test/Login.php new file mode 100644 index 0000000..8e499f3 --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Block/System/Config/Test/Login.php @@ -0,0 +1,72 @@ +setTemplate('fontis/ewayau/test/login.phtml'); + + return $this; + } + + /** + * Generates the Html content for the test button + * + * This is called by core magento and needs to be here otherwise the button will not generate + * + * @param Varien_Data_Form_Element_Abstract $element The Magento form element (in this case the button) + * @return string The Html content + */ + protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) + { + return $this->_toHtml(); + } + + /** + * Returns the URL that will hit the controller that handles testing the eWay API + * + * @return string The URL of the test controller + */ + public function getTestUrl() + { + return Mage::getSingleton('adminhtml/url')->getUrl('*/system_config_test_login/test' . ucfirst($this->_method)); + } + + /** + * @return string + */ + public function getMethod() + { + return $this->_method; + } +} diff --git a/src/app/code/community/Fontis/EwayAu/Block/System/Config/Test/Login/Token.php b/src/app/code/community/Fontis/EwayAu/Block/System/Config/Test/Login/Token.php new file mode 100644 index 0000000..b89d713 --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Block/System/Config/Test/Login/Token.php @@ -0,0 +1,27 @@ +getCheckout()->getQuote()->hasItems()) { - $this->getResponse()->setHeader('HTTP/1.1','403 Session Expired'); + $this->getResponse()->setHeader('HTTP/1.1', '403 Session Expired'); exit; } } - /** - * Redirect Block - * need to be redeclared - */ - protected $_redirectBlockType; - /** * Get singleton of Checkout Session Model * @@ -46,7 +47,7 @@ public function getCheckout() } /** - * when customer select eWay payment method + * When customer selects eWay payment method */ public function redirectAction() { @@ -54,6 +55,7 @@ public function redirectAction() $session->setEwayQuoteId($session->getQuoteId()); $session->setEwayRealOrderId($session->getLastRealOrderId()); + /** @var $order Mage_Sales_Model_Order */ $order = Mage::getModel('sales/order'); $order->loadByIncrementId($session->getLastRealOrderId()); $order->addStatusToHistory($order->getStatus(), Mage::helper('ewayau')->__('Customer was redirected to eWAY.')); @@ -72,7 +74,7 @@ public function redirectAction() /** * eWay returns POST variables to this action */ - public function successAction() + public function successAction() { $status = $this->_checkReturnedPost(); @@ -82,9 +84,10 @@ public function successAction() $session->setQuoteId($session->getEwayQuoteId(true)); $session->getQuote()->setIsActive(false)->save(); + /** @var $order Mage_Sales_Model_Order */ $order = Mage::getModel('sales/order'); $order->load($this->getCheckout()->getLastOrderId()); - if($order->getId()) { + if ($order->getId()) { $order->sendNewOrderEmail(); } @@ -97,7 +100,6 @@ public function successAction() /** * Display failure page if error - * */ public function failureAction() { @@ -120,17 +122,20 @@ protected function _checkReturnedPost() { if (!$this->getRequest()->isPost()) { $this->norouteAction(); - return; + return false; } + $status = true; $response = $this->getRequest()->getPost(); + $checkout = $this->getCheckout(); - if ($this->getCheckout()->getEwayRealOrderId() != $response['ewayTrxnNumber'] || - $this->getCheckout()->getEwayRealOrderId() != Mage::helper('core')->decrypt($response['eWAYoption2'])) { + if ($checkout->getEwayRealOrderId() != $response['ewayTrxnNumber'] || + $checkout->getEwayRealOrderId() != Mage::helper('core')->decrypt($response['eWAYoption2'])) { $this->norouteAction(); - return; + return false; } + /** @var $order Mage_Sales_Model_Order */ $order = Mage::getModel('sales/order'); $order->loadByIncrementId($response['ewayTrxnNumber']); @@ -138,7 +143,6 @@ protected function _checkReturnedPost() $paymentInst->setResponse($response); if ($paymentInst->parseResponse()) { - if ($order->canInvoice()) { $invoice = $order->prepareInvoice(); $invoice->register()->capture(); @@ -157,12 +161,11 @@ protected function _checkReturnedPost() $order->cancel(); $order->addStatusToHistory($order->getStatus(), Mage::helper('ewayau')->__('Customer was rejected by eWAY')); $status = false; - $this->getCheckout()->setEwayErrorMessage($response['eWAYresponseText']); + $checkout->setEwayErrorMessage($response['eWAYresponseText']); } $order->save(); return $status; } - } diff --git a/src/app/code/community/Fontis/EwayAu/Helper/Data.php b/src/app/code/community/Fontis/EwayAu/Helper/Data.php index 662b5ce..6f0b333 100644 --- a/src/app/code/community/Fontis/EwayAu/Helper/Data.php +++ b/src/app/code/community/Fontis/EwayAu/Helper/Data.php @@ -5,19 +5,60 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ class Fontis_EwayAu_Helper_Data extends Mage_Core_Helper_Abstract { + const DEFAULT_TIMEOUT = 30; + const ERROR_MSG_DONOTHONOUR = '05,do not honour'; + + /** + * @param Mage_Sales_Model_Order_Address $billing + * @return string + */ + public function getOrderAddressString($billing) + { + $address = clone $billing; + $address->unsFirstname(); + $address->unsLastname(); + $address->unsPostcode(); + + // Strip blank lines from the address + $tmpAddress = preg_replace('/^\n+|^[\t\s]*\n+/m', '', trim($address->format('text'))); + return str_replace("\n", ' ', $tmpAddress); + } + + /** + * @param Fontis_EwayAu_Model_Sales_Object $salesObject + * @param int $limit Soft maximum limit on description length. + * @return string + */ + public function getInvoiceDescription($salesObject, $limit = 255) + { + /** @var $stringHelper Mage_Core_Helper_String */ + $stringHelper = Mage::helper('core/string'); + + $invoiceDesc = ''; + foreach ($salesObject->getAllItems() as $item) { + if ($item->getParentItem()) { + continue; + } + if ($stringHelper->strlen($invoiceDesc . $item->getName()) > $limit) { + break; + } + $invoiceDesc .= $item->getName() . ', '; + } + return $stringHelper->substr($invoiceDesc, 0, -2); + } } diff --git a/src/app/code/community/Fontis/EwayAu/Helper/Token.php b/src/app/code/community/Fontis/EwayAu/Helper/Token.php new file mode 100644 index 0000000..facddfd --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Helper/Token.php @@ -0,0 +1,114 @@ +isLogEnabled() === true) { + if ($data !== null) { + $message = Zend_Debug::dump($data, $message, false); + } + Mage::log($message, null, self::LOG_FILE); + } + } + + /** + * @return string + */ + public function getCustomerId() + { + return Mage::getSingleton("checkout/session")->getData(self::CUSTOMER_ID_FIELD); + } + + /** + * @param string $customerId + */ + public function setCustomerId($customerId) + { + return Mage::getSingleton("checkout/session")->setData(self::CUSTOMER_ID_FIELD, $customerId); + } + + /** + * @return Mage_Checkout_Model_Session + */ + public function clearCustomerId() + { + return Mage::getSingleton("checkout/session")->unsetData(self::CUSTOMER_ID_FIELD); + } + + /** + * Verify if the partially eWAY returned credit card number matches inputted value. + * + * @param string $new + * @param string $stored + * @return bool + */ + public function hasCreditCardNumberChanged($new, $stored) + { + if (strstr($stored, 'XXXXXX')) { + $numbersToValidate = explode('XXXXXX', $stored); + + $newFirstSix = substr($new, 0, 6); + $newLastFour = substr($new, -4); + + if ($numbersToValidate[0] == $newFirstSix && $numbersToValidate[1] == $newLastFour) { + return false; + } + } + + return true; + } + + /** + * @param int $month + * @param int $year + * @return bool + */ + public function hasCreditCardExpired($month, $year) + { + /** @var $dateModel Mage_Core_Model_Date */ + $dateModel = Mage::getModel('core/date'); + $currentDate = (int) $dateModel->gmtTimestamp(); + $cardExpiry = (int) $dateModel->gmtTimestamp(mktime(0, 0, 0, $month, $year)); + + if ($currentDate > $cardExpiry) { + return true; + } + + return false; + } +} diff --git a/src/app/code/community/Fontis/EwayAu/Model/Direct.php b/src/app/code/community/Fontis/EwayAu/Model/Direct.php index a0cd30a..ecc5017 100644 --- a/src/app/code/community/Fontis/EwayAu/Model/Direct.php +++ b/src/app/code/community/Fontis/EwayAu/Model/Direct.php @@ -5,66 +5,151 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * - * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien + * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ + +/** + * @method Fontis_EwayAu_Model_Direct setError(array $errorDetails) + * @method array getError() + */ class Fontis_EwayAu_Model_Direct extends Mage_Payment_Model_Method_Cc { - protected $_code = 'ewayau_direct'; + const GATEWAY_URL_MAIN = 'https://www.eway.com.au/gateway/xmlpayment.asp'; + const GATEWAY_URL_CVN = 'https://www.eway.com.au/gateway_cvn/xmlpayment.asp'; + const GATEWAY_URL_TEST = 'https://www.eway.com.au/gateway/xmltest/testpage.asp'; + + const REFUND_URL_MAIN = 'https://www.eway.com.au/gateway/xmlpaymentrefund.asp'; + const REFUND_URL_TEST = 'https://www.eway.com.au/gateway/xmltest/refund_test.asp'; + + const PREAUTH_PAYMENT_URL_MAIN = 'https://www.eway.com.au/gateway/xmlauth.asp'; + const PREAUTH_PAYMENT_URL_CVN = 'https://www.eway.com.au/gateway_cvn/xmlauth.asp'; + const PREAUTH_PAYMENT_URL_MAIN_TEST = 'https://www.eway.com.au/gateway/xmltest/authtestpage.asp'; + const PREAUTH_PAYMENT_URL_CVN_TEST = 'https://www.eway.com.au/gateway_cvn/authtestpage.asp'; + + const PREAUTH_COMPLETE_URL_MAIN = 'https://www.eway.com.au/gateway/xmlauthcomplete.asp'; + const PREAUTH_COMPLETE_URL_TEST = 'https://www.eway.com.au/gateway/xmltest/authcompletetestpage.asp'; + + const PREAUTH_VOID_URL_MAIN = 'https://www.eway.com.au/gateway/xmlauthvoid.asp'; + const PREAUTH_VOID_URL_TEST = 'https://www.eway.com.au/gateway/xmltest/authvoidtestpage.asp'; + + protected $_code = 'ewayau_direct'; protected $_isGateway = true; - protected $_canAuthorize = false; + protected $_canAuthorize = true; protected $_canCapture = true; protected $_canCapturePartial = false; protected $_canRefund = true; protected $_canRefundInvoicePartial = true; - protected $_canVoid = false; + protected $_canVoid = true; protected $_canUseInternal = true; protected $_canUseCheckout = true; protected $_canUseForMultishipping = true; protected $_canSaveCc = false; - protected $_formBlockType = 'ewayau/form'; - protected $_infoBlockType = 'ewayau/info'; + protected $_formBlockType = 'ewayau/cc_form'; + protected $_infoBlockType = 'ewayau/cc_info'; /** - * Get flag to use CCV or not - * - * @return string + * @var Fontis_EwayAu_Helper_Data + */ + protected $_ewayHelper = null; + + /** + * @return Fontis_EwayAu_Helper_Data */ - public function getUseccv() + protected function getEwayHelper() { - return $this->getConfigData('useccv'); + if ($this->_ewayHelper === null) { + $this->_ewayHelper = Mage::helper('ewayau'); + } + return $this->_ewayHelper; } /** - * Get api url of eWAY Direct payment + * Get API URL of eWAY Direct payment * * @return string */ public function getApiGatewayUrl() { - if($this->getConfigData('test_gateway')) { - return 'https://www.eway.com.au/gateway/xmltest/testpage.asp'; + if ($this->getConfigData('test_gateway')) { + return self::GATEWAY_URL_TEST; + } else { + if ($this->hasVerification()) { + return self::GATEWAY_URL_CVN; + } else { + return self::GATEWAY_URL_MAIN; + } + } + } + + /** + * @return string + */ + public function getApiRefundUrl() + { + if ($this->getConfigData('test_gateway')) { + return self::REFUND_URL_TEST; + } else { + return self::REFUND_URL_MAIN; + } + } + + /** + * @return string + */ + public function getApiPreAuthPaymentUrl() + { + if ($this->getConfigData('test_gateway')) { + if ($this->hasVerification()) { + return self::PREAUTH_PAYMENT_URL_CVN_TEST; + } else { + return self::PREAUTH_PAYMENT_URL_MAIN_TEST; + } } else { - if($this->getUseccv()) { - return 'https://www.eway.com.au/gateway_cvn/xmlpayment.asp'; + if ($this->hasVerification()) { + return self::PREAUTH_PAYMENT_URL_CVN; } else { - return 'https://www.eway.com.au/gateway/xmlpayment.asp'; + return self::PREAUTH_PAYMENT_URL_MAIN; } } } + /** + * @return string + */ + public function getApiPreAuthCompleteUrl() + { + if ($this->getConfigData('test_gateway')) { + return self::PREAUTH_COMPLETE_URL_TEST; + } else { + return self::PREAUTH_COMPLETE_URL_MAIN; + } + } + + /** + * @return string + */ + public function getApiPreAuthVoidUrl() + { + if ($this->getConfigData('test_gateway')) { + return self::PREAUTH_VOID_URL_TEST; + } else { + return self::PREAUTH_VOID_URL_MAIN; + } + } + /** * Get Customer Id * @@ -84,79 +169,191 @@ public function getAcceptedCurrency() { return $this->getConfigData('currency'); } - + + /** + * @return string + */ public function getRefundPassword() { return $this->getConfigData('refund_password'); } + /** + * @return bool + */ + public function canCapture() + { + if ($this->_isPreauthorizeCapture($this->getInfoInstance())) { + return true; + } elseif ($this->getConfigPaymentAction() === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) { + return $this->_canCapture; + } else { + return false; + } + } + + /** + * @param Mage_Sales_Model_Order_Payment $payment + * @return bool + */ + protected function _isPreauthorizeCapture($payment) + { + $lastTransaction = $payment->getTransaction($payment->getLastTransId()); + if ($lastTransaction && $lastTransaction->getTxnType() == Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH) { + return true; + } + + return false; + } + + /** + * @return Fontis_EwayAu_Model_Direct + * @throws Mage_Core_Exception + */ public function validate() { parent::validate(); + $paymentInfo = $this->getInfoInstance(); if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) { - $currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode(); + $currencyCode = $paymentInfo->getOrder()->getBaseCurrencyCode(); } else { - $currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode(); + $currencyCode = $paymentInfo->getQuote()->getBaseCurrencyCode(); } - if ($currency_code != $this->getAcceptedCurrency()) { - Mage::throwException(Mage::helper('ewayau')->__('Selected currency code ('.$currency_code.') is not compatabile with eWAY')); + if ($currencyCode != $this->getAcceptedCurrency()) { + Mage::throwException($this->getEwayHelper()->__('Selected currency code (%s) is not compatible with eWAY', $currencyCode)); } return $this; } - public function capture(Varien_Object $payment, $amount) + /** + * @param Varien_Object $payment + * @param float $amount + * @return Fontis_EwayAu_Model_Direct + * @throws Mage_Core_Exception + */ + public function authorize(Varien_Object $payment, $amount) { - $this->setAmount($amount) - ->setPayment($payment); + if ($amount <= 0) { + Mage::throwException($this->getEwayHelper()->__('Invalid amount for authorization.')); + } - $result = $this->callDoDirectPayment($payment); + $this->setAmount($amount)->setPayment($payment); + + $result = $this->callDoAuthorisationPaymentRequest($payment, $amount); if ($result === false) { - $e = $this->getError(); - if (isset($e['message'])) { - $message = Mage::helper('ewayau')->__('There has been an error processing your payment. ') . $e['message']; + $this->processError($this->getError(), 'payment'); + } else { + if ($result['ewayTrxnStatus'] === 'True') { + $payment->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_APPROVED) + ->setTransactionId($result['ewayTrxnNumber']) + ->setLastTransId($result['ewayTrxnNumber']) + ->setIsTransactionClosed(0); } else { - $message = Mage::helper('ewayau')->__('There has been an error processing your payment. Please try later or contact us for help.'); + Mage::throwException($result['ewayTrxnError']); } - Mage::throwException($message); + } + return $this; + } + + /** + * @param Varien_Object $payment + * @param float $amount + * @return Fontis_EwayAu_Model_Direct + * @throws Mage_Core_Exception + */ + public function capture(Varien_Object $payment, $amount) + { + if ($amount <= 0) { + Mage::throwException($this->getEwayHelper()->__('Invalid amount for authorization.')); + } + + $this->setAmount($amount)->setPayment($payment); + + if ($this->_isPreauthorizeCapture($payment)) { + $result = $this->callDoCompleteAuthorisedPayment($payment, $amount); + } else { + $result = $this->callDoDirectPayment($payment, $amount); + } + + if ($result === false) { + $this->processError($this->getError(), 'payment'); } else { if ($result['ewayTrxnStatus'] === 'True') { - $payment->setStatus(self::STATUS_APPROVED)->setLastTransId($result['ewayTrxnNumber']); - } - else { + $payment->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_SUCCESS) + ->setLastTransId($result['ewayTrxnNumber']) + ->setTransactionId($result['ewayTrxnNumber']) + ->setIsTransactionClosed(1); + } else { Mage::throwException($result['ewayTrxnError']); } } return $this; } + /** + * @param Varien_Object $payment + * @return Fontis_EwayAu_Model_Direct + */ public function cancel(Varien_Object $payment) { - $payment->setStatus(self::STATUS_DECLINED); + $payment->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_DECLINED); return $this; } - public function refund(Varien_Object $payment, $amount) + /** + * @param Varien_Object $payment + * @return Fontis_EwayAu_Model_Direct + * @throws Mage_Core_Exception + */ + public function void(Varien_Object $payment) { + if (!$this->_isPreauthorizeCapture($payment)) { + Mage::throwException($this->_getHelper()->__('Void action is not available.')); + } + + $amount = $payment->getAmountAuthorized(); + $this->setAmount($amount)->setPayment($payment); - - $result = $this->callDoRefund(); - if($result === false) { - $e = $this->getError(); - if (isset($e['message'])) { - $message = Mage::helper('ewayau')->__('There has been an error processing your refund.') . ' ' . $e['message']; + $result = $this->callDoVoidAuthorisedPayment($payment, $amount); + + if ($result === false) { + $this->processError($this->getError(), 'refund'); + } else { + if ($result['ewayTrxnStatus'] === 'True' && $result['ewayReturnAmount'] == $this->getFormattedAmount($amount)) { + $payment + ->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_VOID) + ->setLastTransId($result['ewayTrxnNumber']) + ->setIsTransactionClosed(1); + ; } else { - $message = Mage::helper('ewayau')->__('There has been an error processing your refund. Please try later or contact us for help.'); + Mage::throwException($result['ewayTrxnError']); } - Mage::throwException($message); } - else { - if ($result['ewayTrxnStatus'] === 'True' && $result['ewayReturnAmount'] == ($amount * 100)) { - $payment->setStatus(self::STATUS_APPROVED)->setLastTransId($result['ewayTrxnNumber']); - } - else { + return $this; + } + + /** + * @param Varien_Object $payment + * @param float $amount + * @return Fontis_EwayAu_Model_Direct + * @throws Mage_Core_Exception + */ + public function refund(Varien_Object $payment, $amount) + { + $this->setAmount($amount)->setPayment($payment); + + $result = $this->callDoRefund($payment, $amount); + + if ($result === false) { + $this->processError($this->getError(), 'refund'); + } else { + if ($result['ewayTrxnStatus'] === 'True' && $result['ewayReturnAmount'] == $this->getFormattedAmount($amount)) { + $payment->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_APPROVED) + ->setLastTransId($result['ewayTrxnNumber']); + } else { Mage::throwException($result['ewayTrxnError']); } } @@ -164,160 +361,181 @@ public function refund(Varien_Object $payment, $amount) } /** - * prepare params to send to gateway - * - * @return bool | array + * @param array $error + * @param string $action payment, refund, etc + * @throws Mage_Core_Exception */ - public function callDoDirectPayment() + protected function processError($error, $action) { - $payment = $this->getPayment(); - $billing = $payment->getOrder()->getBillingAddress(); - - $invoiceDesc = ''; - $lengs = 0; - foreach ($payment->getOrder()->getAllItems() as $item) { - if ($item->getParentItem()) { - continue; - } - if (Mage::helper('core/string')->strlen($invoiceDesc.$item->getName()) > 10000) { - break; + if (isset($error['message'])) { + if (stristr($error['message'], Fontis_EwayAu_Helper_Data::ERROR_MSG_DONOTHONOUR)) { + $message = $this->getEwayHelper()->__("There has been an error processing your $action: Your credit card details are invalid."); + } else { + $message = $this->getEwayHelper()->__("There has been an error processing your $action. ") . $error['message']; } - $invoiceDesc .= $item->getName() . ', '; - } - $invoiceDesc = Mage::helper('core/string')->substr($invoiceDesc, 0, -2); - - $address = clone $billing; - $address->unsFirstname(); - $address->unsLastname(); - $address->unsPostcode(); - $formatedAddress = ''; - $tmpAddress = explode(' ', str_replace("\n", ' ', trim($address->format('text')))); - foreach ($tmpAddress as $part) { - if (strlen($part) > 0) $formatedAddress .= $part . ' '; + } else { + $message = $this->getEwayHelper()->__("There has been an error processing your $action. Please try later or contact us for help."); } - + Mage::throwException($message); + } + + /** + * Get the Simple XML objected used for pre-auth and capture payment transactions. + * + * @param Mage_Sales_Model_Order_Payment $payment + * @param float $amount + * @return SimpleXMLElement + */ + protected function getPaymentXmlObject($payment, $amount) + { + $order = $payment->getOrder(); + $billing = $order->getBillingAddress(); + $formattedAddress = $this->getEwayHelper()->getOrderAddressString($billing); + $invoiceDesc = $this->getEwayHelper()->getInvoiceDescription($order); + // Build the XML request $xml = new SimpleXMLElement(''); - - $xml->addChild('ewayCustomerID', $this->getCustomerId() ); - $xml->addChild('ewayTotalAmount', ($this->getAmount()*100) ); - $xml->addChild('ewayCardHoldersName', str_replace('&', '&', $payment->getCcOwner() ) ); - $xml->addChild('ewayCardNumber', $payment->getCcNumber() ); - $xml->addChild('ewayCardExpiryMonth', $payment->getCcExpMonth() ); - $xml->addChild('ewayCardExpiryYear', substr($payment->getCcExpYear(), 2, 2) ); + $xml->addChild('ewayCustomerID', $this->getCustomerId()); + $xml->addChild('ewayTotalAmount', $this->getFormattedAmount($amount)); + $xml->addChild('ewayCustomerFirstName', str_replace('&', '&', trim($billing->getFirstname()))); + $xml->addChild('ewayCustomerLastName', str_replace('&', '&', trim($billing->getLastname()))); + $xml->addChild('ewayCustomerEmail', str_replace('&', '&', trim($order->getCustomerEmail()))); + $xml->addChild('ewayCustomerAddress', str_replace('&', '&', trim($formattedAddress))); + $xml->addChild('ewayCustomerPostcode', str_replace('&', '&', trim($billing->getPostcode()))); + $xml->addChild('ewayCustomerInvoiceDescription', str_replace('&', '&', trim($invoiceDesc))); + $xml->addChild('ewayCustomerInvoiceRef', ''); + $xml->addChild('ewayCardHoldersName', str_replace('&', '&', $payment->getCcOwner())); + $xml->addChild('ewayCardNumber', $payment->getCcNumber()); + $xml->addChild('ewayCardExpiryMonth', $payment->getCcExpMonth()); + $xml->addChild('ewayCardExpiryYear', substr($payment->getCcExpYear(), 2, 2)); $xml->addChild('ewayTrxnNumber', ''); - $xml->addChild('ewayCustomerInvoiceDescription', str_replace('&', '&', trim($invoiceDesc) ) ); - $xml->addChild('ewayCustomerFirstName', str_replace('&', '&', trim( $billing->getFirstname() ) ) ); - $xml->addChild('ewayCustomerLastName', str_replace('&', '&', trim( $billing->getLastname() ) ) ); - $xml->addChild('ewayCustomerEmail', str_replace('&', '&', trim($payment->getOrder()->getCustomerEmail() ) ) ); - $xml->addChild('ewayCustomerAddress', str_replace('&', '&', trim($formatedAddress) ) ); - $xml->addChild('ewayCustomerPostcode', str_replace('&', '&', trim($billing->getPostcode()) ) ); - $xml->addChild('ewayCustomerInvoiceRef', $payment->getOrder()->getRealOrderId()); - - if ($this->getUseccv()) { - $xml->addChild('ewayCVN', $payment->getCcCid() ); - } - + $xml->addChild('ewayOption1', ''); $xml->addChild('ewayOption2', ''); $xml->addChild('ewayOption3', ''); - - //convert to string before sending to the gateway - $resultArr = $this->call( $xml->asXML() ); - - if ($resultArr === false) { - return false; + if ($this->hasVerification()) { + $xml->addChild('ewayCVN', $payment->getCcCid()); } - return $resultArr; - + return $xml; } - + /** - * prepare params to send to gateway - * - * @return bool | array + * @param Mage_Sales_Model_Order_Payment $payment + * @param float $amount + * @return array|false */ - public function callDoRefund() + protected function callDoDirectPayment($payment, $amount) { - $payment = $this->getPayment(); - $billing = $payment->getOrder()->getBillingAddress(); - - $xml = new SimpleXMLElement(''); + $xml = $this->getPaymentXmlObject($payment, $amount); + $url = $this->getApiGatewayUrl(); + + // Convert to string before sending to the gateway + return $this->call($xml->asXML(), $url); + } + /** + * @param Mage_Sales_Model_Order_Payment $payment + * @param float $amount + * @return array|false + */ + protected function callDoAuthorisationPaymentRequest($payment, $amount) + { + $xml = $this->getPaymentXmlObject($payment, $amount); + $url = $this->getApiPreAuthPaymentUrl(); + + // Convert to string before sending to the gateway + return $this->call($xml->asXML(), $url); + } + + /** + * @param Mage_Sales_Model_Order_Payment $payment + * @param float $amount + * @return array|false + */ + protected function callDoCompleteAuthorisedPayment($payment, $amount) + { + // Build the XML request + $xml = new SimpleXMLElement(''); $xml->addChild('ewayCustomerID', $this->getCustomerId()); - $xml->addChild('ewayTotalAmount', $this->getAmount()*100); + $xml->addChild('ewayTotalAmount', $this->getFormattedAmount($amount)); + $xml->addChild('ewayAuthTrxnNumber', $payment->getLastTransId()); $xml->addChild('ewayCardExpiryMonth', $payment->getCcExpMonth()); - $xml->addChild('ewayCardExpiryYear', substr($payment->getCcExpYear(), 2, 2)); - $xml->addChild('ewayOriginalTrxnNumber', $payment->getLastTransId()); - $xml->addChild('ewayRefundPassword', $this->getRefundPassword()); - + $xml->addChild('ewayCardExpiryYear', $payment->getCcExpYear()); + $xml->addChild('ewayOption1', ''); $xml->addChild('ewayOption2', ''); $xml->addChild('ewayOption3', ''); - - $http = new Varien_Http_Adapter_Curl(); - $config = array('timeout' => 30); - $url = 'https://www.eway.com.au/gateway/xmlpaymentrefund.asp'; + $url = $this->getApiPreAuthCompleteUrl(); - if ($this->getConfigData('test_gateway')) { - $url = 'https://www.eway.com.au/gateway/xmltest/refund_test.asp'; - } + // Convert to string before sending to the gateway + return $this->call($xml->asXML(), $url); + } - $http->setConfig($config); - $http->write(Zend_Http_Client::POST, $url, '1.1', array(), $xml->asXML()); - $response = $http->read(); + /** + * @param Mage_Sales_Model_Order_Payment $payment + * @param float $amount + * @return array|false + */ + protected function callDoVoidAuthorisedPayment($payment, $amount) + { + // Build the XML request + $xml = new SimpleXMLElement(''); + $xml->addChild('ewayCustomerID', $this->getCustomerId()); + $xml->addChild('ewayTotalAmount', $this->getFormattedAmount($amount)); + $xml->addChild('ewayAuthTrxnNumber', $this->getOriginalTransactionId($payment->getLastTransId())); - $response = preg_split('/^\r?$/m', $response, 2); - $response = trim($response[1]); + $xml->addChild('ewayOption1', ''); + $xml->addChild('ewayOption2', ''); + $xml->addChild('ewayOption3', ''); - if ($http->getErrno()) { - $http->close(); - $this->setError(array( - 'message' => $http->getError() - )); - return false; - } - $http->close(); + $url = $this->getApiPreAuthVoidUrl(); - if( ($resultArr = $this->parseXmlResponse($response)) === false ) { - $this->setError(array( - 'message' => 'Invalid response from gateway.' - )); - return false; - } + // Convert to string before sending to the gateway + return $this->call($xml->asXML(), $url); + } - if ($resultArr['ewayTrxnStatus'] == 'True') { - $this->unsError(); - return $resultArr; - } + /** + * @param Mage_Sales_Model_Order_Payment $payment + * @param float $amount + * @return array|false + */ + protected function callDoRefund($payment, $amount) + { + // Build the XML request + $xml = new SimpleXMLElement(''); + $xml->addChild('ewayCustomerID', $this->getCustomerId()); + $xml->addChild('ewayTotalAmount', $this->getFormattedAmount($amount)); + $xml->addChild('ewayCardExpiryMonth', $payment->getCcExpMonth()); + $xml->addChild('ewayCardExpiryYear', substr($payment->getCcExpYear(), 2, 2)); + $xml->addChild('ewayOriginalTrxnNumber', $this->getOriginalTransactionId($payment->getLastTransId())); + $xml->addChild('ewayRefundPassword', $this->getRefundPassword()); - if (isset($resultArr['ewayTrxnError'])) { - $this->setError(array( - 'message' => $resultArr['ewayTrxnError'] - )); - } + $xml->addChild('ewayOption1', ''); + $xml->addChild('ewayOption2', ''); - $this->setTransactionId($resultArr['ewayTrxnNumber']); + $url = $this->getApiRefundUrl(); - return $resultArr; + // Convert to string before sending to the gateway + return $this->call($xml->asXML(), $url); } /** - * Send params to gateway + * Send parameters to eWay gateway. * * @param string $xml - * @return bool | array + * @param string $url + * @return array|false */ - public function call($xml) + protected function call($xml, $url) { $http = new Varien_Http_Adapter_Curl(); - $config = array('timeout' => 30); + $config = array('timeout' => Fontis_EwayAu_Helper_Data::DEFAULT_TIMEOUT); $http->setConfig($config); - $http->write(Zend_Http_Client::POST, $this->getApiGatewayUrl(), '1.1', array(), $xml); + $http->write(Zend_Http_Client::POST, $url, Zend_Http_Client::HTTP_1, array(), $xml); $response = $http->read(); $response = preg_split('/^\r?$/m', $response, 2); @@ -326,15 +544,15 @@ public function call($xml) if ($http->getErrno()) { $http->close(); $this->setError(array( - 'message' => $http->getError() + 'message' => $http->getErrno() . ' - ' . $http->getError(), )); return false; } $http->close(); - if( ($parsedResArr = $this->parseXmlResponse($response)) === false ) { + if (($parsedResArr = $this->parseXmlResponse($response)) === false) { $this->setError(array( - 'message' => 'Invalid response from gateway.' + 'message' => 'Invalid response from gateway.', )); return false; } @@ -346,7 +564,7 @@ public function call($xml) if (isset($parsedResArr['ewayTrxnError'])) { $this->setError(array( - 'message' => $parsedResArr['ewayTrxnError'] + 'message' => $parsedResArr['ewayTrxnError'], )); } @@ -354,29 +572,55 @@ public function call($xml) } /** - * parse response of gateway + * @param float $amount + * @return float + */ + protected function getFormattedAmount($amount) + { + return $amount * 100; + } + + /** + * Get Transaction ID that can be used with eWAY API calls. + * Remove payment action appended by Magento to the end of transaction ID. + * + * @param string $transactionId + * @return string + */ + protected function getOriginalTransactionId($transactionId) + { + if (strstr($transactionId, '-')) { + $transactionData = explode('-', $transactionId); + return $transactionData[0]; + } + + return $transactionId; + } + + /** + * Parse response of gateway * * @param string $xmlResponse * @return array */ - public function parseXmlResponse($xmlResponse) + protected function parseXmlResponse($xmlResponse) { $xmlObj = simplexml_load_string($xmlResponse); - if($xmlObj === false) { + if ($xmlObj === false) { return false; } $newResArr = array(); foreach ($xmlObj as $key => $val) { - $newResArr[$key] = (string)$val; + $newResArr[$key] = (string) $val; } return $newResArr; } - + /** - * Check if invoice email can be sent, and send it + * Check if invoice email can be sent, and send it. * * @param Mage_Sales_Model_Order_Invoice $invoice * @param Mage_Sales_Model_Order_Payment $payment @@ -385,6 +629,7 @@ public function parseXmlResponse($xmlResponse) public function processInvoice($invoice, $payment) { parent::processInvoice($invoice, $payment); + try { $storeId = $invoice->getOrder()->getStoreId(); if (Mage::helper('sales')->canSendNewInvoiceEmail($storeId)) { @@ -392,8 +637,8 @@ public function processInvoice($invoice, $payment) $invoice->sendEmail(); } } catch (Exception $e) { - mage::logException($e); - } + Mage::logException($e); + } return $this; } } diff --git a/src/app/code/community/Fontis/EwayAu/Model/Sales/Object.php b/src/app/code/community/Fontis/EwayAu/Model/Sales/Object.php new file mode 100644 index 0000000..b8bdea0 --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Model/Sales/Object.php @@ -0,0 +1,44 @@ +_ewayHelper === null) { + $this->_ewayHelper = Mage::helper('ewayau'); + } + return $this->_ewayHelper; + } /** * Get order model @@ -45,16 +66,16 @@ class Fontis_EwayAu_Model_Shared extends Mage_Payment_Model_Method_Abstract */ public function getOrder() { - if (!$this->_order) { + if ($this->_order === null) { $paymentInfo = $this->getInfoInstance(); - $this->_order = Mage::getModel('sales/order') - ->loadByIncrementId($paymentInfo->getOrder()->getRealOrderId()); + $orderId = $paymentInfo->getOrder()->getRealOrderId(); + $this->_order = Mage::getModel('sales/order')->loadByIncrementId($orderId); } return $this->_order; } /** - * Get Customer Id + * Get Customer ID * * @return string */ @@ -73,73 +94,71 @@ public function getAcceptedCurrency() return $this->getConfigData('currency'); } + /** + * @return Fontis_EwayAu_Model_Shared + * @throws Mage_Core_Exception + */ public function validate() { parent::validate(); + $paymentInfo = $this->getInfoInstance(); if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) { - $currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode(); + $currencyCode = $paymentInfo->getOrder()->getBaseCurrencyCode(); } else { - $currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode(); + $currencyCode = $paymentInfo->getQuote()->getBaseCurrencyCode(); } - if ($currency_code != $this->getAcceptedCurrency()) { - Mage::throwException(Mage::helper('ewayau')->__('Selected currency code ('.$currency_code.') is not compatabile with eWAY')); + if ($currencyCode != $this->getAcceptedCurrency()) { + Mage::throwException($this->getEwayHelper()->__('Selected currency code (%s) is not compatible with eWAY', $currencyCode)); } return $this; } + /** + * @return string + */ public function getOrderPlaceRedirectUrl() { $url = Mage::getUrl('ewayau/' . $this->_paymentMethod . '/redirect'); - if(!$url) { - $url = 'https://www.eway.com.au/gateway/payment.asp'; + if (!$url) { + $url = self::DEFAULT_REDIRECT_URL; } return $url; } /** - * prepare params array to send it to gateway page via POST + * @return string + */ + public function getOrderReturnSuccessUrl() + { + return Mage::getUrl('ewayau/' . $this->_paymentMethod . '/success', array('_secure' => true)); + } + + /** + * Prepare parameters array to send it to gateway page via POST * * @return array */ public function getFormFields() { - $billing = $this->getOrder()->getBillingAddress(); - $fieldsArr = array(); - $invoiceDesc = ''; - $lengs = 0; - foreach ($this->getOrder()->getAllItems() as $item) { - if ($item->getParentItem()) { - continue; - } - if (Mage::helper('core/string')->strlen($invoiceDesc.$item->getName()) > 10000) { - break; - } - $invoiceDesc .= $item->getName() . ', '; - } - $invoiceDesc = Mage::helper('core/string')->substr($invoiceDesc, 0, -2); - - $address = clone $billing; - $address->unsFirstname(); - $address->unsLastname(); - $address->unsPostcode(); - $formatedAddress = ''; - $tmpAddress = explode(' ', str_replace("\n", ' ', trim($address->format('text')))); - foreach ($tmpAddress as $part) { - if (strlen($part) > 0) $formatedAddress .= $part . ' '; - } + $order = $this->getOrder(); + $billing = $order->getBillingAddress(); + $formattedAddress = $this->getEwayHelper()->getOrderAddressString($billing); + $invoiceDesc = $this->getEwayHelper()->getInvoiceDescription($order, 10000); + $paymentInfo = $this->getInfoInstance(); + $fieldsArr = array(); $fieldsArr['ewayCustomerID'] = $this->getCustomerId(); - $fieldsArr['ewayTotalAmount'] = ($this->getOrder()->getBaseGrandTotal()*100); + $fieldsArr['ewayTotalAmount'] = ($this->getOrder()->getBaseGrandTotal() * 100); $fieldsArr['ewayCustomerFirstName'] = $billing->getFirstname(); $fieldsArr['ewayCustomerLastName'] = $billing->getLastname(); $fieldsArr['ewayCustomerEmail'] = $this->getOrder()->getCustomerEmail(); - $fieldsArr['ewayCustomerAddress'] = trim($formatedAddress); + $fieldsArr['ewayCustomerAddress'] = trim($formattedAddress); $fieldsArr['ewayCustomerPostcode'] = $billing->getPostcode(); $fieldsArr['ewayCustomerInvoiceDescription'] = $invoiceDesc; $fieldsArr['ewaySiteTitle'] = Mage::app()->getStore()->getName(); $fieldsArr['ewayAutoRedirect'] = 1; - $fieldsArr['ewayURL'] = Mage::getUrl('ewayau/' . $this->_paymentMethod . '/success', array('_secure' => true)); + $fieldsArr['ewayURL'] = $this->getOrderReturnSuccessUrl(); $fieldsArr['ewayCustomerInvoiceRef'] = $paymentInfo->getOrder()->getRealOrderId(); $fieldsArr['ewayTrxnNumber'] = $paymentInfo->getOrder()->getRealOrderId(); $fieldsArr['ewayOption1'] = ''; @@ -172,6 +191,11 @@ public function getDebug() return $this->getConfigData('debug_flag'); } + /** + * @param Varien_Object $payment + * @param float $amount + * @return Fontis_EwayAu_Model_Shared + */ public function capture(Varien_Object $payment, $amount) { $payment->setStatus(self::STATUS_APPROVED) @@ -180,6 +204,10 @@ public function capture(Varien_Object $payment, $amount) return $this; } + /** + * @param Varien_Object $payment + * @return Fontis_EwayAu_Model_Shared + */ public function cancel(Varien_Object $payment) { $payment->setStatus(self::STATUS_DECLINED) @@ -189,7 +217,7 @@ public function cancel(Varien_Object $payment) } /** - * parse response POST array from gateway page and return payment status + * Parse response POST array from gateway page and return payment status * * @return bool */ diff --git a/src/app/code/community/Fontis/EwayAu/Model/Source/Cctype.php b/src/app/code/community/Fontis/EwayAu/Model/Source/Cctype.php index 96798f3..1279aba 100644 --- a/src/app/code/community/Fontis/EwayAu/Model/Source/Cctype.php +++ b/src/app/code/community/Fontis/EwayAu/Model/Source/Cctype.php @@ -5,22 +5,23 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. - * - * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ class Fontis_EwayAu_Model_Source_Cctype extends Mage_Payment_Model_Source_Cctype { + /** + * @return array + */ public function getAllowedTypes() { return array('VI', 'MC', 'AE', 'DICL', 'JCB'); diff --git a/src/app/code/community/Fontis/EwayAu/Model/Source/PaymentAction.php b/src/app/code/community/Fontis/EwayAu/Model/Source/PaymentAction.php new file mode 100644 index 0000000..e697d37 --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Model/Source/PaymentAction.php @@ -0,0 +1,38 @@ + Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE, + 'label' => $helper->__('Authorize Only') + ), + array( + 'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE, + 'label' => $helper->__('Authorize and Capture') + ), + ); + } +} diff --git a/src/app/code/community/Fontis/EwayAu/Model/Token.php b/src/app/code/community/Fontis/EwayAu/Model/Token.php new file mode 100644 index 0000000..ecc91f6 --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Model/Token.php @@ -0,0 +1,470 @@ + 'ewayau/token_response_createCustomer', + 'UpdateCustomerResponse' => 'ewayau/token_response_updateCustomer', + 'QueryCustomerByReferenceResult' => 'ewayau/token_response_queryCustomerByReference', + 'CreditCard' => 'varien/object', + 'ProcessPaymentResponse' => 'ewayau/token_response_processPayment', + 'CCPaymentResponse' => 'varien/object', + ); + + /** + * @var Fontis_EwayAu_Model_Token_Request + */ + protected $_request = null; + + /** + * @var Fontis_EwayAu_Model_Token_Request_Data + */ + protected $_requestData = null; + + /** + * @var Fontis_EwayAu_Helper_Token + */ + protected $_tokenHelper = null; + + public function __construct() + { + parent::__construct(); + $this->_soapClassMap = array_map(array(Mage::getConfig(), 'getModelClassName'), $this->_soapClassMap); + } + + /** + * @return Fontis_EwayAu_Helper_Token + */ + protected function getTokenHelper() + { + if ($this->_tokenHelper === null) { + $this->_tokenHelper = Mage::helper('ewayau/token'); + } + + return $this->_tokenHelper; + } + + /** + * @param bool $testGateway + * @return string + */ + public function getApiGatewayUrl($testGateway = null) + { + if ($testGateway !== null) { + if ($testGateway === true) { + return self::GATEWAY_URL_TEST; + } else { + return self::GATEWAY_URL_MAIN; + } + } elseif ($this->getConfigData('test_gateway', $this->getStoreId())) { + return self::GATEWAY_URL_TEST; + } else { + return self::GATEWAY_URL_MAIN; + } + } + + /** + * @return int + */ + public function getStoreId() + { + if (Mage::registry('payment_store')) { + return Mage::registry('payment_store'); + } + + $store = $this->getStore(); + $storeId = false; + if ($store && is_object($store) && $store->getId()) { + $storeId = $store->getId(); + Mage::register('payment_store', $storeId); + } + + if (!$storeId) { + $storeId = Mage::app()->getStore()->getId(); + } + + return $storeId; + } + + /** + * Get the eWAY Customer Id + * + * @return string + */ + public function getCustomerId() + { + return $this->getConfigData('customer_id', $this->getStoreId()); + } + + /** + * Get the eWAY Business Center username. + * + * @return string + */ + public function getUsername() + { + return $this->getConfigData('username', $this->getStoreId()); + } + + /** + * Get the eWAY Business Center password. + * + * @return string + */ + public function getPassword() + { + return $this->getConfigData('password', $this->getStoreId()); + } + + /** + * Get the currency that accepted by eWAY account + * + * @return string + */ + public function getAcceptedCurrency() + { + return $this->getConfigData('currency', $this->getStoreId()); + } + + /** + * Determine if this payment method can be shown as an option on checkout payment page. + * + * @return bool + */ + public function canUseCheckout() + { + return $this->getConfigData('show_in_checkout', $this->getStoreId()); + } + + /** + * @return Fontis_EwayAu_Model_Token + * @throws Mage_Core_Exception + */ + public function validate() + { + parent::validate(); + + $paymentInfo = $this->getInfoInstance(); + if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) { + $currencyCode = $paymentInfo->getOrder()->getBaseCurrencyCode(); + } else { + $currencyCode = $paymentInfo->getQuote()->getBaseCurrencyCode(); + } + if ($currencyCode != $this->getAcceptedCurrency()) { + Mage::throwException($this->getTokenHelper()->__('Selected currency code (%s) is not compatible with eWAY', $currencyCode)); + } + return $this; + } + + /** + * Assign data to info model instance + * + * @param array|Varien_Object $paymentData + * @return Fontis_EwayAu_Model_Token + */ + public function assignData($paymentData) + { + parent::assignData($paymentData); + + if (is_array($paymentData)) { + $paymentData = new Varien_Object($paymentData); + } + + $tokenHelper = $this->getTokenHelper(); + $customerId = $tokenHelper->getCustomerId(); + + // If customer credit card data has already been stored on eWAY recently skip. + if (!$customerId) { + // Determine if customer credit card data already exists on eWAY + try { + $query = $this->queryCustomerByReference(); + + // Check if customer data requires update + if ($query->isRequestSuccessful()) { + $updateResponse = $this->updateCustomer($paymentData, $query->getProcessedResponse()); + + if ($updateResponse === false) { + $tokenHelper->logMessage('Unable to update eWAY token customer.'); + Mage::throwException('An error occurred during the checkout process.'); + } + } else { + $createResponse = $this->createCustomer($paymentData); + + if (!$createResponse->isRequestSuccessful()) { + $tokenHelper->logMessage('Unable to create eWAY token customer.'); + Mage::throwException('An error occurred during the checkout process.'); + } + } + } catch (Exception $e) { + $tokenHelper->logMessage($e->getMessage()); + Mage::throwException($e->getMessage()); + } + } + + return $this; + } + + /** + * @param Varien_Object $payment + * @param float $amount + * @return Fontis_EwayAu_Model_Token + */ + public function capture(Varien_Object $paymentData, $amount) + { + $this->setAmount($amount)->setPayment($paymentData); + + $result = $this->processPayment($paymentData); + if ($result->isRequestSuccessful() === false) { + if ($errorMsg = $result->getEwayTrxnError()) { + if (stristr($errorMsg, Fontis_EwayAu_Helper_Data::ERROR_MSG_DONOTHONOUR)) { + $message = $this->getTokenHelper()->__('An error has occurred while processing your payment: Your credit card details are invalid.'); + } else { + $message = $this->getTokenHelper()->__('An error has occurred while processing your payment. ') . $errorMsg; + } + } else { + $message = $this->getTokenHelper()->__('An error has occurred while processing your payment. Please try later or contact us for help.'); + } + Mage::throwException($message); + } else { + $paymentData->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_APPROVED)->setLastTransId($result->getEwayTrxnNumber()); + // Clear set eWAY token customer ID on customer's session + $this->getTokenHelper()->clearCustomerId(); + } + + return $this; + } + + /** + * Cancel the current transaction payment being processed. + * + * @param Varien_Object $payment + * @return Fontis_EwayAu_Model_Token + */ + public function cancel(Varien_Object $payment) + { + $payment->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_DECLINED); + return $this; + } + + /** + * Get the request model. + * + * @return Fontis_EwayAu_Model_Token_Request + */ + public function getRequest() + { + if ($this->_request === null) { + $endpoint = $this->getApiGatewayUrl(); + $this->_request = Mage::getModel('ewayau/token_request', array( + 'wsdl' => $endpoint . '?WSDL', + 'endpoint' => $endpoint, + 'header' => array( + 'eWAYCustomerID' => $this->getCustomerId(), + 'Username' => $this->getUsername(), + 'Password' => $this->getPassword(), + ), + 'soap_options' => array( + 'exceptions' => false, + 'trace' => (bool) $this->getDebugFlag(), + 'soap_version' => SOAP_1_2, + 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, + 'classmap' => $this->_soapClassMap, + ), + )); + } + + return $this->_request; + } + + /** + * @param string $method + * @param Varien_Object $paymentData + * @return Fontis_EwayAu_Model_Token_Request_Data + */ + public function getRequestData($method, $paymentData = null) + { + if ($this->_requestData === null) { + if (empty($paymentData)) { + $paymentData = $this->getPayment(); + } + + /** @var $salesObject Fontis_EwayAu_Model_Sales_Object */ + $paymentInfo = $this->getInfoInstance(); + if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) { + $salesObject = $paymentInfo->getOrder(); + } else { + $salesObject = $paymentInfo->getQuote(); + } + + if (!$salesObject) { + Mage::throwException($this->getTokenHelper()->__('An error has occurred while processing your payment. Please try later or contact us for help.')); + } + + $tokenData = array( + 'payment_data' => $paymentData, + 'billing' => $salesObject->getBillingAddress(), + 'sales_object' => $salesObject, + 'amount' => $this->getAmount(), + 'method' => $method, + ); + + $this->_requestData = Mage::getModel('ewayau/token_request_data', $tokenData); + } + + $this->_requestData->setMethod($method); + if (!empty($paymentData)) { + $this->_requestData->setPaymentData($paymentData); + } + + return $this->_requestData; + } + + /** + * @param Varien_Object $paymentData + * @return Fontis_EwayAu_Model_Token_Response_CreateCustomer + */ + public function createCustomer($paymentData) + { + $soapMethod = Fontis_EwayAu_Model_Token_Request::CREATE_CUSTOMER; + $data = $this->getRequestData($soapMethod, $paymentData); + $response = $this->getRequest()->execute($soapMethod, $data->getCreateCustomerArray()); + if ($response instanceof Fontis_EwayAu_Model_Token_Response) { + $response->process(); + } + return $response; + } + + /** + * @return Fontis_EwayAu_Model_Token_Response_QueryCustomerByReference + */ + public function queryCustomerByReference() + { + $soapMethod = Fontis_EwayAu_Model_Token_Request::QUERY_CUSTOMER_BY_REFERENCE; + $data = $this->getRequestData($soapMethod); + $response = $this->getRequest()->execute($soapMethod, $data->getQueryCustomerByReferenceArray()); + if ($response instanceof Fontis_EwayAu_Model_Token_Response) { + $response->process(); + } else { + // If the customer doesn't exist, an instance of SoapFault will be returned instead. + // This is unhelpful, as determining whether or not a customer already exists should + // not result in an error, and also because we already have our own logic to determine + // whether or not a request was successful. + // To get around this, just return an empty instance of the appropriate object. This + // will default to the request being unsuccessful, which is what we want in this case. + $response = Mage::getModel('ewayau/token_response_queryCustomerByReference'); + } + return $response; + } + + /** + * @param Varien_Object $paymentData + * @return Fontis_EwayAu_Model_Token_Response_ProcessPayment + */ + public function processPayment($paymentData) + { + $soapMethod = Fontis_EwayAu_Model_Token_Request::PROCESS_PAYMENT; + $data = $this->getRequestData($soapMethod, $paymentData); + $response = $this->getRequest()->execute($soapMethod, $data->getProcessPaymentArray()); + if ($response instanceof Fontis_EwayAu_Model_Token_Response) { + $response->process(); + } + return $response; + } + + /** + * Update eWAY token customer record. + * + * @param Varien_Object $paymentData + * @param Varien_Object $storedData + * @return bool + */ + public function updateCustomer($paymentData, $storedData = null) + { + $soapMethod = Fontis_EwayAu_Model_Token_Request::UPDATE_CUSTOMER; + $data = $this->getRequestData($soapMethod, $paymentData); + + if (isset($storedData)) { + $newCustomerData = $data->getUpdateCustomerArray(); + $cardExpired = true; + + if (isset($newCustomerData['CCExpiryMonth']) && isset($newCustomerData['CCExpiryYear'])) { + $cardExpired = $this->getTokenHelper()->hasCreditCardExpired( + $newCustomerData['CCExpiryMonth'], + $newCustomerData['CCExpiryYear'] + ); + + unset($newCustomerData['CCExpiryMonth']); + unset($newCustomerData['CCExpiryYear']); + } + + if (!$cardExpired) { + $changeFound = false; + $usedFields = $data->getUsedCustomerFields(); + + foreach ($usedFields as $field) { + $storedDataField = $storedData->__get($field); + if (!isset($newCustomerData[$field]) && !empty($storedDataField)) { + $changeFound = true; + break; + } elseif ($field == 'CCNumber' && $this->getTokenHelper()->hasCreditCardNumberChanged($newCustomerData[$field], $storedDataField)) { + $changeFound = true; + break; + } elseif ($newCustomerData[$field] != $storedDataField) { + $changeFound = true; + break; + } + } + + if ($changeFound === false) { + return false; + } + } + } + + $response = $this->getRequest()->execute($soapMethod, $data->getUpdateCustomerArray()); + if ($response instanceof Fontis_EwayAu_Model_Token_Response) { + $response->process(); + } + return $response->isRequestSuccessful(); + } +} diff --git a/src/app/code/community/Fontis/EwayAu/Model/Token/Request.php b/src/app/code/community/Fontis/EwayAu/Model/Token/Request.php new file mode 100644 index 0000000..e84ff20 --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Model/Token/Request.php @@ -0,0 +1,198 @@ +validateHeader($options['header'])) { + $this->_header = $options['header']; + } + + if (isset($options['endpoint']) && is_string($options['endpoint'])) { + $this->_endpoint = $options['endpoint']; + } + + $soapOptions = array(); + if (isset($options['soap_options']) && is_array($options['soap_options'])) { + $soapOptions = $options['soap_options']; + } + + $this->_client = new SoapClient($options['wsdl'], $soapOptions); + } + + /** + * @return Fontis_EwayAu_Helper_Token + */ + protected function getTokenHelper() + { + if ($this->_tokenHelper === null) { + $this->_tokenHelper = Mage::helper('ewayau/token'); + } + + return $this->_tokenHelper; + } + + /** + * Perform eWAY token payments API request. + * + * @param string $soapMethod + * @param array $data + * @return Fontis_EwayAu_Model_Token_Response|SoapFault + * @throws Mage_Core_Exception + */ + public function execute($soapMethod, $data) + { + if (empty($data)) { + Mage::throwException('Invalid checkout information.'); + } + + $this->getTokenHelper()->logMessage('request', $data); + $this->getTokenHelper()->logMessage('header', $this->_header); + + $client = $this->getClient(); + + try { + $response = $client->__soapCall( + $soapMethod, + array($data), + array( + 'location' => $this->getEndpoint(), + ), + $this->getSoapHeader() + ); + } catch (Exception $e) { + $this->getTokenHelper()->logMessage($e->getMessage()); + Mage::throwException('There was an error when attempting to process your checkout request.'); + } + + return $response; + } + + /** + * Get eWAY token payment endpoint URL. + * + * @return bool|string + */ + public function getEndpoint() + { + return $this->_endpoint; + } + + /** + * Get the Client object. + * + * @return SoapClient + */ + public function getClient() + { + return $this->_client; + } + + /** + * Get the raw header array. + * + * @return array + */ + public function getHeader() + { + return $this->_header; + } + + /** + * Get the SOAP header used to perform a request on the eWAY token payments API. + * + * @return SoapHeader + */ + public function getSoapHeader() + { + $data = $this->getHeader(); + $namespace = self::SOAP_NAMESPACE; + + return new SoapHeader( + $namespace, + 'eWAYHeader', + new SoapVar($data, SOAP_ENC_OBJECT, 'eWAYHeader', $namespace) + ); + } + + /** + * Determine if the SOAP header data is valid. + * + * @param array $header + * @return bool + */ + public function validateHeader($header = array()) + { + if (empty($header)) { + $header = $this->getHeader(); + } + + if (!is_array($header)) { + Mage::throwException('Invalid request header format.'); + } + + if (!isset($header['eWAYCustomerID']) && !strlen($header['eWAYCustomerID']) <= 8) { + Mage::throwException('Invalid eWAY customer ID.'); + } + + if (!isset($header['Username']) && !strlen($header['Username']) <= 100) { + Mage::throwException('Invalid eWAY username.'); + } + + if (!isset($header['Password']) && !strlen($header['Password']) <= 50) { + Mage::throwException('Invalid eWAY password.'); + } + + return true; + } +} diff --git a/src/app/code/community/Fontis/EwayAu/Model/Token/Request/Data.php b/src/app/code/community/Fontis/EwayAu/Model/Token/Request/Data.php new file mode 100644 index 0000000..a7af479 --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Model/Token/Request/Data.php @@ -0,0 +1,337 @@ +_method = $data['method']; + + if (!isset($data['sales_object'])) { + Mage::throwException('Order information is invalid.'); + } + + $this->_salesObject = $data['sales_object']; + + if (!isset($data['payment_data']) && $this->isPaymentTransaction()) { + Mage::throwException('Payment data is invalid.'); + } elseif (isset($data['payment_data'])) { + $this->_paymentData = $data['payment_data']; + } + + if (!isset($data['billing'])) { + Mage::throwException('Billing information is invalid.'); + } + + $this->_billing = $data['billing']; + + if (isset($data['amount'])) { + $this->setAmount($data['amount']); + } + } + + /** + * @param string $method + */ + public function setMethod($method) + { + $this->_method = $method; + } + + /** + * @return string + */ + public function getMethod() + { + return $this->_method; + } + + /** + * @param Varien_Object $paymentData + */ + public function setPaymentData($paymentData) + { + $this->_paymentData = $paymentData; + } + + /** + * @return Varien_Object + */ + public function getPaymentData() + { + return $this->_paymentData; + } + + /** + * @return Fontis_EwayAu_Model_Sales_Object + */ + public function getSalesObject() + { + return $this->_salesObject; + } + + /** + * @param float $amount + * @return int + */ + public function setAmount($amount) + { + $this->_amount = (int) bcmul($amount, 100); + } + + /** + * @return int + */ + public function getAmount() + { + return $this->_amount; + } + + /** + * @return Mage_Customer_Model_Address_Abstract + */ + public function getBilling() + { + return $this->_billing; + } + + /** + * @return bool + */ + public function isPaymentTransaction() + { + $method = $this->getMethod(); + $paymentRequests = array( + Fontis_EwayAu_Model_Token_Request::PROCESS_PAYMENT, + ); + + if (in_array($method, $paymentRequests)) { + return true; + } + + return false; + } + + /** + * Returns the eWAY customer ID for the customer. + * + * @return int + */ + public function getCustomerId() + { + return Mage::helper('ewayau/token')->getCustomerId(); + } + + /** + * @return string[] + */ + public function getValidCustomerTitles() + { + return array('Mr.', 'Ms.', 'Mrs.', 'Miss', 'Dr.', 'Sir.', 'Prof.'); + } + + /** + * @param string $title + * @return bool + */ + public function validCustomerTitle($title) + { + if (in_array($title, $this->getValidCustomerTitles())) { + return true; + } else { + return false; + } + } + + /** + * Returns the quote/order ID, used as the merchant reference when passing data to eWAY. + * + * @return string + */ + public function getCustomerRef() + { + return $this->getSalesObject()->getId(); + } + + /** + * @return string + */ + public function getFormattedAddress() + { + $address = ''; + $billing = $this->getBilling(); + $addressLines = $billing->getStreet(); + + if (!empty($addressLines)) { + foreach ($addressLines as $line) { + $address .= trim(str_replace("\n", ' ', $line)) . ' '; + } + } + + return trim($address); + } + + /** + * @return array + */ + public function getUsedCustomerFields() + { + return array( + 'Title', 'FirstName', 'LastName', 'Email', 'Country', + 'CCNameOnCard', 'CCExpiryMonth', 'CCExpiryYear', 'CCNumber', + ); + } + + /** + * @return array + */ + public function createCustomerDataArray() + { + $requestData = array(); + $billing = $this->getBilling(); + $paymentData = $this->getPaymentData(); + + $title = $billing->getPrefix(); + + if (empty($title)) { + $title = self::DEFAULT_CUSTOMER_TITLE; + } elseif (!$this->validCustomerTitle($title)) { + if ($this->validCustomerTitle($title . '.')) { + $title = $title . '.'; + } else { + $title = self::DEFAULT_CUSTOMER_TITLE; + } + } + + $requestData['Title'] = $title; + $requestData['FirstName'] = $billing->getFirstname(); + $requestData['LastName'] = $billing->getLastname(); + $requestData['Email'] = ''; + $requestData['Address'] = ''; + $requestData['Suburb'] = ''; + $requestData['State'] = ''; + $requestData['PostCode'] = ''; + // eWAY expects the country code to be lowercase + $requestData['Country'] = strtolower($billing->getCountryId()); + // API call will not work if these fields are not specified. + $requestData['Company'] = ''; + $requestData['JobDesc'] = ''; + $requestData['Phone'] = ''; + $requestData['Mobile'] = ''; + $requestData['Fax'] = ''; + $requestData['Comments'] = ''; + $requestData['URL'] = ''; + $requestData['CustomerRef'] = $this->getCustomerRef(); + + $requestData['CCNumber'] = $paymentData->getCcNumber(); + $requestData['CCNameOnCard'] = $paymentData->getCcOwner(); + $requestData['CCExpiryMonth'] = $paymentData->getCcExpMonth(); + + $ccYear = $paymentData->getCcExpYear(); + if (strlen($ccYear) > 2) { + // Assume the four digits were entered for the year, and take the last two. + // eg. convert '2014' to '14' + $ccYear = substr($paymentData->getCcExpYear(), -2); + } + + $requestData['CCExpiryYear'] = $ccYear; + + return $requestData; + } + + /** + * @return array + */ + public function getCreateCustomerArray() + { + return $this->createCustomerDataArray(); + } + + /** + * @return array + */ + public function getUpdateCustomerArray() + { + $requestArray = $this->createCustomerDataArray(); + $requestArray[self::EWAY_CUSTOMER_ID_FIELD] = $this->getCustomerId(); + + return $requestArray; + } + + /** + * @return array + */ + public function getQueryCustomerByReferenceArray() + { + return array('CustomerReference' => $this->getCustomerRef()); + } + + /** + * @return array + */ + public function getProcessPaymentArray() + { + $customerId = $this->getCustomerId(); + + if (!$customerId) { + Mage::throwException('Unable to process payment.'); + } + + return array( + self::EWAY_CUSTOMER_ID_FIELD => $customerId, + 'amount' => $this->getAmount(), + 'invoiceReference' => $this->getSalesObject()->getIncrementId(), // Only present on the order object + 'invoiceDescription' => Mage::helper('ewayau')->getInvoiceDescription($this->getSalesObject()), + ); + } +} diff --git a/src/app/code/community/Fontis/EwayAu/Model/Token/Response.php b/src/app/code/community/Fontis/EwayAu/Model/Token/Response.php new file mode 100644 index 0000000..deccd98 --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Model/Token/Response.php @@ -0,0 +1,63 @@ +getTokenHelper()->logMessage(get_class($this), $this->getData()); + return $this->_isRequestSuccessful; + } + + /** + * @return Fontis_EwayAu_Helper_Token + */ + protected function getTokenHelper() + { + if ($this->_tokenHelper === null) { + $this->_tokenHelper = Mage::helper('ewayau/token'); + } + + return $this->_tokenHelper; + } + + /** + * @return bool + */ + public function isRequestSuccessful() + { + return $this->_isRequestSuccessful; + } +} diff --git a/src/app/code/community/Fontis/EwayAu/Model/Token/Response/CreateCustomer.php b/src/app/code/community/Fontis/EwayAu/Model/Token/Response/CreateCustomer.php new file mode 100644 index 0000000..850c551 --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Model/Token/Response/CreateCustomer.php @@ -0,0 +1,35 @@ +getCreateCustomerResult()) { + $this->_isRequestSuccessful = true; + $this->getTokenHelper()->setCustomerId($customerId); + } + + return parent::process(); + } +} diff --git a/src/app/code/community/Fontis/EwayAu/Model/Token/Response/ProcessPayment.php b/src/app/code/community/Fontis/EwayAu/Model/Token/Response/ProcessPayment.php new file mode 100644 index 0000000..70ab4ea --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Model/Token/Response/ProcessPayment.php @@ -0,0 +1,37 @@ +getEwayResponse()) { + if ($result->getEwayTrxnStatus() === "True") { + $this->_isRequestSuccessful = true; + } + $this->_data = $result->getData(); + } + + return parent::process(); + } +} diff --git a/src/app/code/community/Fontis/EwayAu/Model/Token/Response/QueryCustomerByReference.php b/src/app/code/community/Fontis/EwayAu/Model/Token/Response/QueryCustomerByReference.php new file mode 100644 index 0000000..9b308a5 --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Model/Token/Response/QueryCustomerByReference.php @@ -0,0 +1,37 @@ +getQueryCustomerByReferenceResult()) { + $customerId = $result->getManagedCustomerId(); + $this->_isRequestSuccessful = true; + $this->getTokenHelper()->setCustomerId($customerId); + $this->_data = $result->getData(); + } + + return parent::process(); + } +} diff --git a/src/app/code/community/Fontis/EwayAu/Model/Token/Response/UpdateCustomer.php b/src/app/code/community/Fontis/EwayAu/Model/Token/Response/UpdateCustomer.php new file mode 100644 index 0000000..6317eae --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/Model/Token/Response/UpdateCustomer.php @@ -0,0 +1,34 @@ +getUpdateCustomerResult()) { + $this->_isRequestSuccessful = true; + } + + return parent::process(); + } +} diff --git a/src/app/code/community/Fontis/EwayAu/controllers/SecureController.php b/src/app/code/community/Fontis/EwayAu/controllers/SecureController.php index f830375..3de30ee 100644 --- a/src/app/code/community/Fontis/EwayAu/controllers/SecureController.php +++ b/src/app/code/community/Fontis/EwayAu/controllers/SecureController.php @@ -5,24 +5,24 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * - * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien + * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ -/* - * eWAY 3D-Secure Checkout Controller - */ class Fontis_EwayAu_SecureController extends Fontis_EwayAu_Controller_Abstract { + /** + * @var string + */ protected $_redirectBlockType = 'ewayau/secure_redirect'; } diff --git a/src/app/code/community/Fontis/EwayAu/controllers/SharedController.php b/src/app/code/community/Fontis/EwayAu/controllers/SharedController.php index 89efdaa..4cee988 100644 --- a/src/app/code/community/Fontis/EwayAu/controllers/SharedController.php +++ b/src/app/code/community/Fontis/EwayAu/controllers/SharedController.php @@ -5,21 +5,24 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * - * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien + * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ class Fontis_EwayAu_SharedController extends Fontis_EwayAu_Controller_Abstract { + /** + * @var string + */ protected $_redirectBlockType = 'ewayau/shared_redirect'; } diff --git a/src/app/code/community/Fontis/EwayAu/controllers/System/Config/Test/LoginController.php b/src/app/code/community/Fontis/EwayAu/controllers/System/Config/Test/LoginController.php new file mode 100644 index 0000000..14cfc2a --- /dev/null +++ b/src/app/code/community/Fontis/EwayAu/controllers/System/Config/Test/LoginController.php @@ -0,0 +1,81 @@ +getRequest()->getPost(); + + $testGateway = $postData['test_gateway'] ? true : false; + $endpoint = Mage::getModel('ewayau/token')->getApiGatewayUrl($testGateway); + + $request = Mage::getModel('ewayau/token_request', array( + 'wsdl' => $endpoint . '?WSDL', + 'endpoint' => $endpoint, + 'header' => array( + 'eWAYCustomerID' => $postData['customer_id'], + 'Username' => $postData['username'], + 'Password' => $postData['password'], + ), + 'soap_options' => array( + 'exceptions' => false, + 'soap_version' => SOAP_1_2, + 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP + ) + )); + + // Test the API using QueryCustomer. If it fails to login (ie: incorrect credentials) it will return + // the string "Login failed" as part of the exception. In other cases it will either succeed (if customer ID + // 1 exists or return an exception that doesn't include "Login failed". + try { + $return = $request->execute('QueryCustomer', '1'); + echo $this->processTokenResponse($return); + } catch (Exception $e) { + echo $this->processTokenResponse($e); + } + } + + /** + * @param object $responseObject + * @return int + */ + protected function processTokenResponse($responseObject) + { + if ($responseObject instanceof Exception) { + if (strpos($responseObject->getMessage(), self::ERR_LOGIN_FAILED) === false) { + return 1; + } else { + return 0; + } + } else { + return 1; + } + } +} diff --git a/src/app/code/community/Fontis/EwayAu/etc/config.xml b/src/app/code/community/Fontis/EwayAu/etc/config.xml index 3f7a550..80957b7 100644 --- a/src/app/code/community/Fontis/EwayAu/etc/config.xml +++ b/src/app/code/community/Fontis/EwayAu/etc/config.xml @@ -6,22 +6,22 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ --> - 1.2.5 + 1.3.0 @@ -56,7 +56,9 @@ - Fontis_EwayAu_Block + + Fontis_EwayAu_Block + @@ -77,7 +79,7 @@ - /ewayau/shared + /ewayau @@ -100,12 +102,19 @@ - fontis_ewayau.xml + fontis/ewayau.xml + + + + fontis/ewayau.xml + + + @@ -146,6 +155,32 @@ processing 0 + + + + + AUD + authorize_capture + ewayau/token + eWAY Token + 0 + processing + AE,VI,MC,DICL,JCB + 0 + 0 + 0 + + + + + + + Fontis_EwayAu + + + + + diff --git a/src/app/code/community/Fontis/EwayAu/etc/system.xml b/src/app/code/community/Fontis/EwayAu/etc/system.xml index 7cdb458..67a44f4 100644 --- a/src/app/code/community/Fontis/EwayAu/etc/system.xml +++ b/src/app/code/community/Fontis/EwayAu/etc/system.xml @@ -6,15 +6,15 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ --> @@ -28,7 +28,7 @@ 201 1 1 - 0 + 1 @@ -37,7 +37,7 @@ 10 1 1 - 0 + 1 <label>Title</label> @@ -45,7 +45,7 @@ <sort_order>20</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> - <show_in_store>0</show_in_store> + <show_in_store>1</show_in_store> @@ -54,7 +54,7 @@ 30 1 1 - 0 + 1 @@ -63,7 +63,7 @@ 40 1 1 - 0 + 1 @@ -72,17 +72,26 @@ 50 1 1 - 0 + 1 select adminhtml/system_config_source_yesno - 71 + 60 1 1 - 0 + 1 + + + select + ewayau/source_paymentAction + 70 + 1 + 1 + 1 + select @@ -90,7 +99,7 @@ 80 1 1 - 0 + 1 @@ -99,7 +108,7 @@ 90 1 1 - 0 + 1 @@ -108,7 +117,7 @@ 100 1 1 - 0 + 1 @@ -122,7 +131,7 @@ multiselect - 111 + 120 adminhtml/system_config_source_country 1 1 @@ -131,10 +140,10 @@ text - 112 + 130 1 1 - 0 + 1 @@ -144,64 +153,64 @@ 202 1 1 - 0 + 1 select adminhtml/system_config_source_yesno - 1 + 10 1 1 - 0 + 1 <label>Title</label> <frontend_type>text</frontend_type> - <sort_order>2</sort_order> + <sort_order>20</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> - <show_in_store>0</show_in_store> + <show_in_store>1</show_in_store> text adminhtml/system_config_backend_encrypted - 3 + 30 1 1 - 0 + 1 select adminhtml/system_config_source_currency - 4 + 40 1 1 - 0 + 1 text - 5 + 50 1 1 - 0 + 1 select adminhtml/system_config_source_order_status_processing - 7 + 60 1 1 - 0 + 1 allowspecific - 8 + 70 adminhtml/system_config_source_payment_allspecificcountries 1 1 @@ -210,7 +219,7 @@ multiselect - 9 + 80 adminhtml/system_config_source_country 1 1 @@ -219,10 +228,10 @@ text - 10 + 100 1 1 - 0 + 1 @@ -232,64 +241,64 @@ 203 1 1 - 0 + 1 select adminhtml/system_config_source_yesno - 1 + 10 1 1 - 0 + 1 <label>Title</label> <frontend_type>text</frontend_type> - <sort_order>2</sort_order> + <sort_order>20</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> - <show_in_store>0</show_in_store> + <show_in_store>1</show_in_store> text adminhtml/system_config_backend_encrypted - 3 + 30 1 1 - 0 + 1 select adminhtml/system_config_source_currency - 4 + 40 1 1 - 0 + 1 text - 5 + 50 1 1 - 0 + 1 select adminhtml/system_config_source_order_status_processing - 7 + 60 1 1 - 0 + 1 allowspecific - 8 + 70 adminhtml/system_config_source_payment_allspecificcountries 1 1 @@ -298,7 +307,7 @@ multiselect - 9 + 80 adminhtml/system_config_source_country 1 1 @@ -307,13 +316,167 @@ text - 10 + 90 1 1 - 0 + 1 + + + text + 204 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + 1 + + + <label>Title</label> + <frontend_type>text</frontend_type> + <sort_order>20</sort_order> + <show_in_default>1</show_in_default> + <show_in_website>1</show_in_website> + <show_in_store>1</show_in_store> + + + + select + adminhtml/system_config_source_yesno + 30 + 1 + 1 + 1 + Display payment method as an option on the checkout page. + + + + text + adminhtml/system_config_backend_encrypted + 40 + 1 + 1 + 1 + + + + text + adminhtml/system_config_backend_encrypted + 50 + 1 + 1 + 1 + Your username which is used to login to MYeWAY Business Center. + + + + text + adminhtml/system_config_backend_encrypted + 60 + 1 + 1 + 1 + Your eWAY API Password. + + + ewayau/system_config_test_login_token + 61 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_currency + 70 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 80 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_yesno + 90 + 1 + 1 + 1 + + + + select + adminhtml/system_config_source_order_status_processing + 100 + 1 + 1 + 1 + + + + multiselect + ewayau/source_cctype + 110 + 1 + 1 + 1 + + + + + + allowspecific + 130 + adminhtml/system_config_source_payment_allspecificcountries + 1 + 1 + 1 + + + + multiselect + 140 + adminhtml/system_config_source_country + 1 + 1 + 1 + + + + text + 150 + 1 + 1 + 1 + + + diff --git a/src/app/code/community/Fontis/EwayAu/sql/eway_setup/mysql4-install-0.1.0.php b/src/app/code/community/Fontis/EwayAu/sql/eway_setup/mysql4-install-0.1.0.php index e8715bd..77f1699 100644 --- a/src/app/code/community/Fontis/EwayAu/sql/eway_setup/mysql4-install-0.1.0.php +++ b/src/app/code/community/Fontis/EwayAu/sql/eway_setup/mysql4-install-0.1.0.php @@ -5,17 +5,17 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * - * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien + * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/src/app/design/adminhtml/default/default/layout/fontis/ewayau.xml b/src/app/design/adminhtml/default/default/layout/fontis/ewayau.xml new file mode 100644 index 0000000..179068e --- /dev/null +++ b/src/app/design/adminhtml/default/default/layout/fontis/ewayau.xml @@ -0,0 +1,28 @@ + + + + + + fontis/ewayau/css/styles.css + + + diff --git a/src/app/design/adminhtml/default/default/template/fontis/ewayau/cc/form.phtml b/src/app/design/adminhtml/default/default/template/fontis/ewayau/cc/form.phtml new file mode 100644 index 0000000..bd521ee --- /dev/null +++ b/src/app/design/adminhtml/default/default/template/fontis/ewayau/cc/form.phtml @@ -0,0 +1,88 @@ + + +getMethodCode(); +/** @var $paymentHelper Mage_Payment_Helper_Data */ +$paymentHelper = Mage::helper('payment'); +?> + + + + diff --git a/src/app/design/adminhtml/default/default/template/fontis/ewayau/cc/info.phtml b/src/app/design/adminhtml/default/default/template/fontis/ewayau/cc/info.phtml new file mode 100644 index 0000000..278d5d3 --- /dev/null +++ b/src/app/design/adminhtml/default/default/template/fontis/ewayau/cc/info.phtml @@ -0,0 +1,30 @@ + +getInfo(); + +echo $paymentHelper->__('Name on the Card: %s', $this->escapeHtml($info->getCcOwner())) . '
'; +echo $paymentHelper->__('Credit Card Type: %s', $this->escapeHtml($this->getCcTypeName())) . '
'; +echo $paymentHelper->__('Credit Card Number: xxxx-%s', $this->escapeHtml($info->getCcLast4())) . '
'; +echo $paymentHelper->__('Expiration Date: %s/%s', $this->escapeHtml($this->getCcExpMonth()), $this->escapeHtml($info->getCcExpYear())); +?> diff --git a/src/app/design/adminhtml/default/default/template/fontis/ewayau/cc/pdf/info.phtml b/src/app/design/adminhtml/default/default/template/fontis/ewayau/cc/pdf/info.phtml new file mode 100644 index 0000000..70880ee --- /dev/null +++ b/src/app/design/adminhtml/default/default/template/fontis/ewayau/cc/pdf/info.phtml @@ -0,0 +1,33 @@ + +getInfo(); +?> + +__('Name on the Card: %s', $this->escapeHtml($info->getCcOwner())); ?> + {{pdf_row_separator}} +__('Credit Card Type: %s', $this->escapeHtml($this->getCcTypeName())); ?> + {{pdf_row_separator}} +__('Credit Card Number: xxxx-%s', $this->escapeHtml($info->getCcLast4())); ?> + {{pdf_row_separator}} +__('Expiration Date: %s/%s', $this->escapeHtml($this->getCcExpMonth()), $this->escapeHtml($info->getCcExpYear())); ?> diff --git a/src/app/design/adminhtml/default/default/template/fontis/ewayau/form.phtml b/src/app/design/adminhtml/default/default/template/fontis/ewayau/form.phtml deleted file mode 100644 index 785a893..0000000 --- a/src/app/design/adminhtml/default/default/template/fontis/ewayau/form.phtml +++ /dev/null @@ -1,75 +0,0 @@ - -getMethodCode() ?> - - diff --git a/src/app/design/adminhtml/default/default/template/fontis/ewayau/info.phtml b/src/app/design/adminhtml/default/default/template/fontis/ewayau/info.phtml deleted file mode 100644 index f35609b..0000000 --- a/src/app/design/adminhtml/default/default/template/fontis/ewayau/info.phtml +++ /dev/null @@ -1,23 +0,0 @@ - -__('Name on the Card: %s', $this->htmlEscape($this->getInfo()->getCcOwner())) ?>
-__('Credit Card Type: %s', $this->htmlEscape($this->getCcTypeName())) ?>
-__('Credit Card Number: xxxx-%s', $this->htmlEscape($this->getInfo()->getCcLast4())) ?>
-__('Expiration Date: %s/%s', $this->htmlEscape($this->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?> diff --git a/src/app/design/adminhtml/default/default/template/fontis/ewayau/pdf/info.phtml b/src/app/design/adminhtml/default/default/template/fontis/ewayau/pdf/info.phtml deleted file mode 100644 index 0ffe4ab..0000000 --- a/src/app/design/adminhtml/default/default/template/fontis/ewayau/pdf/info.phtml +++ /dev/null @@ -1,26 +0,0 @@ - -__('Name on the Card: %s', $this->htmlEscape($this->getInfo()->getCcOwner())) ?> - {{pdf_row_separator}} -__('Credit Card Type: %s', $this->htmlEscape($this->getCcTypeName())) ?> - {{pdf_row_separator}} -__('Credit Card Number: xxxx-%s', $this->htmlEscape($this->getInfo()->getCcLast4())) ?> - {{pdf_row_separator}} -__('Expiration Date: %s/%s', $this->htmlEscape($this->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?> diff --git a/src/app/design/adminhtml/default/default/template/fontis/ewayau/test/login.phtml b/src/app/design/adminhtml/default/default/template/fontis/ewayau/test/login.phtml new file mode 100644 index 0000000..8b2c468 --- /dev/null +++ b/src/app/design/adminhtml/default/default/template/fontis/ewayau/test/login.phtml @@ -0,0 +1,55 @@ + + + +getMethod(); ?> + + + + + diff --git a/src/app/design/frontend/base/default/layout/fontis_ewayau.xml b/src/app/design/frontend/base/default/layout/fontis/ewayau.xml similarity index 73% rename from src/app/design/frontend/base/default/layout/fontis_ewayau.xml rename to src/app/design/frontend/base/default/layout/fontis/ewayau.xml index d7e26ee..83ae8d9 100644 --- a/src/app/design/frontend/base/default/layout/fontis_ewayau.xml +++ b/src/app/design/frontend/base/default/layout/fontis/ewayau.xml @@ -6,15 +6,16 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @author Ron Carr + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ --> @@ -26,7 +27,7 @@ - + @@ -35,7 +36,7 @@ - + diff --git a/src/app/design/frontend/base/default/template/fontis/ewayau/cc/form.phtml b/src/app/design/frontend/base/default/template/fontis/ewayau/cc/form.phtml new file mode 100644 index 0000000..bb7f502 --- /dev/null +++ b/src/app/design/frontend/base/default/template/fontis/ewayau/cc/form.phtml @@ -0,0 +1,85 @@ + + +
+ getMethodCode(); ?> + +
diff --git a/src/app/design/frontend/base/default/template/fontis/ewayau/cc/info.phtml b/src/app/design/frontend/base/default/template/fontis/ewayau/cc/info.phtml new file mode 100644 index 0000000..db03869 --- /dev/null +++ b/src/app/design/frontend/base/default/template/fontis/ewayau/cc/info.phtml @@ -0,0 +1,26 @@ + +getInfo()): ?> +__('Name on the Card: %s', $this->escapeHtml($info->getCcOwner())) ?>
+__('Credit Card Type: %s', $this->escapeHtml($this->getCcTypeName())) ?>
+__('Credit Card Number: xxxx-%s', $this->escapeHtml($info->getCcLast4())) ?>
+__('Expiration Date: %s/%s', $this->escapeHtml($this->getCcExpMonth()), $this->escapeHtml($info->getCcExpYear())) ?> + diff --git a/src/app/design/frontend/base/default/template/fontis/ewayau/shared/failure.phtml b/src/app/design/frontend/base/default/template/fontis/ewayau/failure.phtml similarity index 53% rename from src/app/design/frontend/base/default/template/fontis/ewayau/shared/failure.phtml rename to src/app/design/frontend/base/default/template/fontis/ewayau/failure.phtml index e9d9d9b..c9065db 100644 --- a/src/app/design/frontend/base/default/template/fontis/ewayau/shared/failure.phtml +++ b/src/app/design/frontend/base/default/template/fontis/ewayau/failure.phtml @@ -5,20 +5,21 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @author Ron Carr + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ ?>
-

__('Error occurred') ?>

+

__('Error occurred'); ?>

-

getErrorMessage() ?>.

-

__('Please continue shopping.', $this->getContinueShoppingUrl()) ?>

+

getErrorMessage(); ?>.

+

__('Please continue shopping.', $this->getContinueShoppingUrl()); ?>

diff --git a/src/app/design/frontend/base/default/template/fontis/ewayau/form.phtml b/src/app/design/frontend/base/default/template/fontis/ewayau/form.phtml deleted file mode 100644 index f9b60d1..0000000 --- a/src/app/design/frontend/base/default/template/fontis/ewayau/form.phtml +++ /dev/null @@ -1,83 +0,0 @@ - - -
- getMethodCode() ?> - -
diff --git a/src/app/design/frontend/base/default/template/fontis/ewayau/info.phtml b/src/app/design/frontend/base/default/template/fontis/ewayau/info.phtml deleted file mode 100644 index 76a03e1..0000000 --- a/src/app/design/frontend/base/default/template/fontis/ewayau/info.phtml +++ /dev/null @@ -1,27 +0,0 @@ - -getInfo()): ?> -__('Name on the Card: %s', $this->htmlEscape($this->getInfo()->getCcOwner())) ?>
-__('Credit Card Type: %s', $this->htmlEscape($this->getCcTypeName())) ?>
-__('Credit Card Number: xxxx-%s', $this->htmlEscape($this->getInfo()->getCcLast4())) ?>
-__('Expiration Date: %s/%s', $this->htmlEscape($this->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?> - - - diff --git a/src/app/design/frontend/base/default/template/fontis/ewayau/secure/failure.phtml b/src/app/design/frontend/base/default/template/fontis/ewayau/secure/failure.phtml deleted file mode 100644 index e9d9d9b..0000000 --- a/src/app/design/frontend/base/default/template/fontis/ewayau/secure/failure.phtml +++ /dev/null @@ -1,24 +0,0 @@ - -
-

__('Error occurred') ?>

-
-

getErrorMessage() ?>.

-

__('Please continue shopping.', $this->getContinueShoppingUrl()) ?>

diff --git a/src/app/design/frontend/base/default/template/fontis/ewayau/secure/form.phtml b/src/app/design/frontend/base/default/template/fontis/ewayau/secure/form.phtml index 3867a35..bd3ed5f 100644 --- a/src/app/design/frontend/base/default/template/fontis/ewayau/secure/form.phtml +++ b/src/app/design/frontend/base/default/template/fontis/ewayau/secure/form.phtml @@ -5,23 +5,24 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @author Ron Carr + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ ?>
- getMethodCode() ?> -
diff --git a/src/app/design/frontend/base/default/template/fontis/ewayau/shared/form.phtml b/src/app/design/frontend/base/default/template/fontis/ewayau/shared/form.phtml index f32fcec..eb0ff31 100644 --- a/src/app/design/frontend/base/default/template/fontis/ewayau/shared/form.phtml +++ b/src/app/design/frontend/base/default/template/fontis/ewayau/shared/form.phtml @@ -5,23 +5,24 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @author Ron Carr + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ ?>
- getMethodCode() ?> -
diff --git a/src/app/etc/modules/Fontis_EwayAu.xml b/src/app/etc/modules/Fontis_EwayAu.xml index b41ac5a..bc19f9e 100644 --- a/src/app/etc/modules/Fontis_EwayAu.xml +++ b/src/app/etc/modules/Fontis_EwayAu.xml @@ -6,15 +6,16 @@ * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) - * that is available through the world-wide-web at this URL: + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php - * If you are unable to obtain it through the world-wide-web, please send - * an email to license@magentocommerce.com so you can be sent a copy. * * @category Fontis * @package Fontis_EwayAu * @author Chris Norton - * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @author Matthew Gamble + * @author Ron Carr + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ --> diff --git a/src/app/locale/en_AU/Fontis_EwayAu.csv b/src/app/locale/en_AU/Fontis_EwayAu.csv index b8ff148..6dd584e 100644 --- a/src/app/locale/en_AU/Fontis_EwayAu.csv +++ b/src/app/locale/en_AU/Fontis_EwayAu.csv @@ -1,38 +1,38 @@ -API Gateway URL,API Gateway URL -Accepted currency,Accepted currency -Card Verification Number,Card Verification Number -Credit Card Number,Credit Card Number -Credit Card Number: xxxx-%s,Credit Card Number: xxxx-%s -Credit Card Type,Credit Card Type -Credit Card Type: %s,Credit Card Type: %s -Credit Card Types,Credit Card Types -Credit Card Verification,Credit Card Verification -Customer ID,Customer ID -Customer successfully returned from eWAY,Customer successfully returned from eWAY -Customer was redirected to eWAY.,Customer was redirected to eWAY. -Customer was rejected by eWAY,Customer was rejected by eWAY -Debug Flag,Debug Flag -Enabled,Enabled -Error occurred,Error occurred -Expiration Date,Expiration Date -Expiration Date: %s/%s,Expiration Date: %s/%s -Name on Card,Name on Card -Name on the Card: %s,Name on the Card: %s -New order status,New order status -Payment from Specific countries,Payment from Specific countries -Payment from applicable countries,Payment from applicable countries +"API Gateway URL","API Gateway URL" +"Accepted currency","Accepted currency" +"Card Verification Number","Card Verification Number" +"Credit Card Number","Credit Card Number" +"Credit Card Number: xxxx-%s","Credit Card Number: xxxx-%s" +"Credit Card Type","Credit Card Type" +"Credit Card Type: %s","Credit Card Type: %s" +"Credit Card Types","Credit Card Types" +"Credit Card Verification","Credit Card Verification" +"Customer ID","Customer ID" +"Customer successfully returned from eWAY","Customer successfully returned from eWAY" +"Customer was redirected to eWAY.","Customer was redirected to eWAY." +"Customer was rejected by eWAY","Customer was rejected by eWAY" +"Debug Flag","Debug Flag" +"Enabled","Enabled" +"Error occurred","Error occurred" +"Expiration Date","Expiration Date" +"Expiration Date: %s/%s","Expiration Date: %s/%s" +"Name on Card","Name on Card" +"Name on the Card: %s","Name on the Card: %s" +"New order status","New order status" +"Payment from Specific countries","Payment from Specific countries" +"Payment from applicable countries","Payment from applicable countries" "Please continue shopping.","Please continue shopping." -Please Select,Please Select -Selected currency code (,Selected currency code ( -Sort order,Sort order -There has been an error processing your payment.,There has been an error processing your payment. -There has been an error processing your payment. Please try later or contact us for help.,There has been an error processing your payment. Please try later or contact us for help. -Title,Title -What is this?,What is this? -You will be redirected to eWAY 3D-Secure in a few seconds.,You will be redirected to eWAY 3D-Secure in a few seconds. -You will be redirected to eWAY 3D-Secure website when you place an order.,You will be redirected to eWAY 3D-Secure website when you place an order. -You will be redirected to eWAY in a few seconds.,You will be redirected to eWAY in a few seconds. -You will be redirected to eWAY website when you place an order.,You will be redirected to eWAY website when you place an order. -eWAY 3D-Secure,eWAY 3D-Secure -eWAY Direct,eWAY Direct -eWAY Shared,eWAY Shared +"Please Select","Please Select" +"Selected currency code (","Selected currency code (" +"Sort order","Sort order" +"There has been an error processing your payment.","There has been an error processing your payment." +"There has been an error processing your payment. Please try later or contact us for help.","There has been an error processing your payment. Please try later or contact us for help." +"Title","Title" +"What is this?","What is this?" +"You will be redirected to eWAY 3D-Secure in a few seconds.","You will be redirected to eWAY 3D-Secure in a few seconds." +"You will be redirected to eWAY 3D-Secure website when you place an order.","You will be redirected to eWAY 3D-Secure website when you place an order." +"You will be redirected to eWAY in a few seconds.","You will be redirected to eWAY in a few seconds." +"You will be redirected to eWAY website when you place an order.","You will be redirected to eWAY website when you place an order." +"eWAY 3D-Secure","eWAY 3D-Secure" +"eWAY Direct","eWAY Direct" +"eWAY Shared","eWAY Shared" diff --git a/src/app/locale/en_US/Fontis_EwayAu.csv b/src/app/locale/en_US/Fontis_EwayAu.csv index 6e0e226..fd9751f 100644 --- a/src/app/locale/en_US/Fontis_EwayAu.csv +++ b/src/app/locale/en_US/Fontis_EwayAu.csv @@ -13,7 +13,7 @@ "Customer was rejected by eWAY","Customer was rejected by eWAY" "Debug Flag","Debug Flag" "Enabled","Enabled" -"Error occured","Error occured" +"Error occurred","Error occured" "Expiration Date","Expiration Date" "Expiration Date: %s/%s","Expiration Date: %s/%s" "Name on Card","Name on Card" diff --git a/src/skin/adminhtml/default/default/fontis/ewayau/css/styles.css b/src/skin/adminhtml/default/default/fontis/ewayau/css/styles.css new file mode 100644 index 0000000..2488db6 --- /dev/null +++ b/src/skin/adminhtml/default/default/fontis/ewayau/css/styles.css @@ -0,0 +1,35 @@ +/** + * Fontis eWAY Australia Extension + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-3.0.php + * + * @category Fontis + * @package Fontis_EwayAu + * @author Chris Norton + * @author Matthew Gamble + * @author Ron Carr + * @copyright Copyright (c) 2014 Fontis Pty. Ltd. (http://www.fontis.com.au) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +.test_result_icon { + color: transparent; + width: 20px; + height: 20px; + vertical-align: middle; +} + +.test_result_icon.success { + background: url(../../../images/success_msg_icon.gif) no-repeat; + display: inline-block; +} + +.test_result_icon.failure { + background: url(../../../images/error_msg_icon.gif) no-repeat; + display: inline-block; +}