diff --git a/.gitignore b/.gitignore deleted file mode 100644 index a946dc69..00000000 --- a/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -vendor/ -public/ -publish/ - -.DS_Store -*.lock -node_modules -build.properties -Capfile -/config/ -/log/ -.idea/ \ No newline at end of file diff --git a/AUTHORS.md b/AUTHORS.md deleted file mode 100644 index 1cbf567f..00000000 --- a/AUTHORS.md +++ /dev/null @@ -1,12 +0,0 @@ -# Authors - -## Version 2 - -- Henry Fan -- Ben Zhang - -## Version 1 - -- Sagar Bhandari -- Ben Zhang -- Roger Bi \ No newline at end of file diff --git a/LICENCE.md b/LICENCE.md index 3174c9b3..6a4a4887 100644 --- a/LICENCE.md +++ b/LICENCE.md @@ -1,21 +1,52 @@ -The MIT License (MIT) - -Copyright (c) Zip Co. and its affiliates. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +# Open Software License v. 3.0 (OSL-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. + +[A brief explanation of this license is available][0]. + + +[0]: http://rosenlaw.com/OSL3.0-explained.htm diff --git a/READEME.md b/READEME.md deleted file mode 100644 index fc3f776b..00000000 --- a/READEME.md +++ /dev/null @@ -1,107 +0,0 @@ -# Zip Payment - Magento 1 extension v2 - -Here is the second version of Magento 1 extension which has been fully refactored. - -## Getting Started - -These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. - -### Prerequisites - -What things you need to install the software and how to install them - -- PHP -- PHP Composer - -## Commands - -### Deploy Command - -- Build deployment package - -``` shell -composer run-script deploy:package -``` - -## Installation - -### Install via FTP - -- Download the latest release package -- Extract the contents of the package to your computer -- Grab all code and copy into corresponding folders in Magento 1 root directory - -### Install via Magento Connect Manager - -- Download the latest package release -- Navigate to `System > Magento Conenct > Magento Connect Manager` -- Go to `Direct package file upload` section and Upload the package -- Press 'Install' button to install this extension - -### Install via Module Manager (modman) - -- modman update - -## Configuration - -### Payment Section - -- Open the Magento Admin -- Navigate to `Systems -> Configuration` and then locate the `Payment Methods` section in the left menu to access the `Zip Payment - Own it now, pay later` method -- Click `Configure` button to open configuration panel - -### Status - -- *Version*: Show current version for this extension -- *Health Check*: List all errors and warnings. It's not been allowed to enable the extension if there is any error found in health check. - -### Settings - -- Set Enable to `Yes` to enable this payment solution -- Choose `environment` and press `Find your keys` button to log into merchant dashboard and grab private key & public key -- Enter the `Private Key` and `Public Key` in the following fields - -#### Checkout - -- *Title*: the label will be used as payment option on checkout page -- *Payment Action*: define how payment will be handled, immediate capture or authorize only -- *Display Mode*: different display mode on checkout page to handle Zip confirmation page - -#### Referred Appication - -- *Order Handling*: whether new order will be created for referred application -- *New Order Status*: define the order status for referred application - -#### Country and Currency - -This section is used to identify configuration of country and currency - -#### Debug Mode - -To enable debug mode and define level of log for debugging - -#### Admin Notification - -Set `Yes` to accept marketing news and notifications - -### Widgets and Banners - -- Scroll down and expand each page section -- Expand each widget section and set Enable to `Yes` to enable widget -- Type `Element selector` to define the location where this widget should put in - -## Copyright - - Copyright 2019 Zip Co - - Licensed under the The MIT License (MIT) (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://opensource.org/licenses/MIT - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md deleted file mode 100644 index 364ed75e..00000000 --- a/RELEASE-NOTES.md +++ /dev/null @@ -1,99 +0,0 @@ -# Release Notes - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## **2.0.0** - February 14, 2019 - -> Download [Source code (zip)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v2.0.0.zip) | [Source code (gz)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v2.0.0.gz) | [Source code (bz2)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v2.0.0.bz2) - -### Core - Extension Refactoring - -- Refactored the whole plugin to improve payment process and fix all fundamental issues -- Admin configurations been rebuilt, including new structured configuration panel, admin wizard and admin notifications -- Able to handle store credit, discount & loyalty programs -- Support redirect (by default) and lightbox to process checkout -- Include PHP SDK in the package, do not need composer to install it -- Handle referred applications -- Support in-plugin health check function -- Support PHP 5.3 and Magento 1.7 - -### Fix - Legacy issue fixes - -- Issues related to the event of a checkout error -- Stop the plugin grabbing customer DOB if it exists -- Phone number validation issue - -## **1.0.6** - October 18, 2018 - -> Download [Source code (zip)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.6.zip) | [Source code (gz)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.6.gz) | [Source code (bz2)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.6.bz2) - -### Development - Coding Standard with Codacy - -- Add Codacy status in README file -- Apply coding standard to the plugin and fix Bugs -- Add codacy settings - -## **1.0.5** - June 18, 2018 - -> Download [Source code (zip)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.5.zip) | [Source code (gz)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.5.gz) | [Source code (bz2)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.5.bz2) - -### Deployment - Update Package XML file - -- Update package xml file - -## **1.0.4** - June 15, 2018 - -> Download [Source code (zip)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.4.zip) | [Source code (gz)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.4.gz) | [Source code (bz2)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.4.bz2) - -### Core - Configuration update - -- Update configuration text and images -- Update payment title -- Update asset URIs - -## **1.0.3** - April 30, 2018 - -> Download [Source code (zip)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.3.zip) | [Source code (gz)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.3.gz) | [Source code (bz2)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.3.bz2) - -### Core - Checkout Script - -- Replace configuration field from 'Payment Action' to 'Payment Mode' -- Add 'holding' overlay on checkout page -- Update checkout script to handle billing save - -## **1.0.2** - February 9, 2018 - -> Download [Source code (zip)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.2.zip) | [Source code (gz)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.2.gz) | [Source code (bz2)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.2.bz2) - -### Core - Order Placement Refactoring - -- Refactor the order state validation -- Add the payment info block to display the receipt number in invoices -- Rename the data setup directory -- Update the mageci source repository -- Aitoc Checkout Compatibility - -## **1.0.1** - September 26, 2017 - -> Download [Source code (zip)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.1.zip) | [Source code (gz)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.1.gz) | [Source code (bz2)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.1.bz2) - -### Core - Code cleanup - -- Code cleanup -- Update Payload - -## **1.0.0** - July 26, 2017 - -> Download [Source code (zip)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.0.zip) | [Source code (gz)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.0.gz) | [Source code (bz2)](https://bitbucket.org/zipmoney-platform/zip.magento1/get/v1.0.0.bz2) - -### Core - Build Extension - -- Build Magento 1 extension -- Add Onestepcheckout Extensions Compatibility -- Handle Zip API calls -- Identify checkout flow -- Implement marketing widget integration - \ No newline at end of file diff --git a/src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/CredentialButton.php b/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/CredentialButton.php similarity index 90% rename from src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/CredentialButton.php rename to app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/CredentialButton.php index ed40ab62..e47a7eb3 100644 --- a/src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/CredentialButton.php +++ b/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/CredentialButton.php @@ -7,7 +7,8 @@ * @author Zip Co - Plugin Team **/ -class Zip_Payment_Block_Adminhtml_System_Config_Field_CredentialButton extends Mage_Adminhtml_Block_System_Config_Form_Field +class Zip_Payment_Block_Adminhtml_System_Config_Field_CredentialButton +extends Mage_Adminhtml_Block_System_Config_Form_Field { const CONFIG_PORTAL_SANDBOX_PATH = 'payment/zip_payment/portal/sandbox'; @@ -16,7 +17,7 @@ class Zip_Payment_Block_Adminhtml_System_Config_Field_CredentialButton extends M /** * @var string */ - protected $template = 'zip/payment/system/config/field/credential_button.phtml'; + protected $_template = 'zip/payment/system/config/field/credential_button.phtml'; /** * Set template to itself @@ -25,7 +26,7 @@ protected function _prepareLayout() { parent::_prepareLayout(); if (!$this->getTemplate()) { - $this->setTemplate($this->template); + $this->setTemplate($this->_template); } return $this; diff --git a/src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/HealthCheck.php b/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/HealthCheck.php similarity index 77% rename from src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/HealthCheck.php rename to app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/HealthCheck.php index 33c09036..8a0d8ed7 100644 --- a/src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/HealthCheck.php +++ b/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/HealthCheck.php @@ -7,12 +7,13 @@ * @author Zip Co - Plugin Team **/ -class Zip_Payment_Block_Adminhtml_System_Config_Field_HealthCheck extends Mage_Adminhtml_Block_System_Config_Form_Field +class Zip_Payment_Block_Adminhtml_System_Config_Field_HealthCheck +extends Mage_Adminhtml_Block_System_Config_Form_Field { /** * @var string */ - protected $template = 'zip/payment/system/config/field/health_check.phtml'; + protected $_template = 'zip/payment/system/config/field/health_check.phtml'; const HEALTH_CHECK_CACHE_ID = 'zip_payment_health_check'; /** @@ -21,8 +22,8 @@ class Zip_Payment_Block_Adminhtml_System_Config_Field_HealthCheck extends Mage_A protected function _prepareLayout() { parent::_prepareLayout(); - if (!$this->getTemplate() && $this->template) { - $this->setTemplate($this->template); + if (!$this->getTemplate() && $this->_template) { + $this->setTemplate($this->_template); } return $this; @@ -47,7 +48,7 @@ public function getStatusLabel($statusLevel = null) Zip_Payment_Model_Adminhtml_System_Config_Backend_HealthCheck::STATUS_ERROR => $helper->__('Error') ); - return (!is_null($statusLevel) && isset($statusList[$statusLevel])) ? $statusList[$statusLevel] : null; + return ($statusLevel !== null && isset($statusList[$statusLevel])) ? $statusList[$statusLevel] : null; } diff --git a/src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/Version.php b/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/Version.php similarity index 66% rename from src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/Version.php rename to app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/Version.php index f1ba5797..627089e3 100644 --- a/src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/Version.php +++ b/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Field/Version.php @@ -7,12 +7,13 @@ * @author Zip Co - Plugin Team **/ -class Zip_Payment_Block_Adminhtml_System_Config_Field_Version extends Mage_Adminhtml_Block_System_Config_Form_Field +class Zip_Payment_Block_Adminhtml_System_Config_Field_Version +extends Mage_Adminhtml_Block_System_Config_Form_Field { /** * @var string */ - protected $template = 'zip/payment/system/config/field/version.phtml'; + protected $_template = 'zip/payment/system/config/field/version.phtml'; /** * Set template to itself @@ -20,8 +21,8 @@ class Zip_Payment_Block_Adminhtml_System_Config_Field_Version extends Mage_Admin protected function _prepareLayout() { parent::_prepareLayout(); - if (!$this->getTemplate() && $this->template) { - $this->setTemplate($this->template); + if (!$this->getTemplate() && $this->_template) { + $this->setTemplate($this->_template); } return $this; diff --git a/src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Expanded.php b/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Expanded.php similarity index 91% rename from src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Expanded.php rename to app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Expanded.php index 4137fa0c..a41ccc2b 100644 --- a/src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Expanded.php +++ b/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Expanded.php @@ -7,7 +7,8 @@ * @author Zip Co - Plugin Team **/ -class Zip_Payment_Block_Adminhtml_System_Config_Fieldset_Expanded extends Mage_Adminhtml_Block_System_Config_Form_Fieldset +class Zip_Payment_Block_Adminhtml_System_Config_Fieldset_Expanded +extends Mage_Adminhtml_Block_System_Config_Form_Fieldset { /** * Return collapse state diff --git a/src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Group.php b/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Group.php similarity index 59% rename from src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Group.php rename to app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Group.php index ff8a47c8..ee6e78a7 100644 --- a/src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Group.php +++ b/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Group.php @@ -7,19 +7,20 @@ * @author Zip Co - Plugin Team **/ -class Zip_Payment_Block_Adminhtml_System_Config_Fieldset_Group extends Mage_Adminhtml_Block_System_Config_Form_Fieldset +class Zip_Payment_Block_Adminhtml_System_Config_Fieldset_Group +extends Mage_Adminhtml_Block_System_Config_Form_Fieldset { - protected $noticeTemplate = 'zip/payment/system/config/fieldset/group/notice.phtml'; + protected $_noticeTemplate = 'zip/payment/system/config/fieldset/group/notice.phtml'; - protected $notificationFeedModel = null; - protected $currentVersion = ''; - protected $notificationData = array(); + protected $_notificationFeedModel = null; + protected $_currentVersion = ''; + protected $_notificationData = array(); protected function _construct() { - $this->notificationFeedModel = Mage::getSingleton('zip_payment/adminhtml_notification_feed'); - $this->currentVersion = Mage::helper('zip_payment')->getCurrentVersion(); - $this->notificationData = $this->notificationFeedModel->getFeedData(); + $this->_notificationFeedModel = Mage::getSingleton('zip_payment/adminhtml_notification_feed'); + $this->_currentVersion = Mage::helper('zip_payment')->getCurrentVersion(); + $this->_notificationData = $this->_notificationFeedModel->getFeedData(); parent::_construct(); } @@ -27,10 +28,10 @@ protected function _construct() protected function _getHeaderCommentHtml($element) { $block = Mage::app()->getLayout()->createBlock('core/template'); - $block->setTemplate($this->noticeTemplate); + $block->setTemplate($this->_noticeTemplate); $block->setData( array( - 'version_notification' => $this->notificationFeedModel->getVersionUpgradeNotification(), + 'version_notification' => $this->_notificationFeedModel->getVersionUpgradeNotification(), 'latest_news' => $this->getLatestNews() ) ); @@ -45,8 +46,8 @@ protected function getLatestNews() { $notificationField = Zip_Payment_Model_Adminhtml_Notification_Feed::NOTIFICATION_FIELD; - if (isset($this->notificationData[$notificationField])) { - $feedData = array_reverse($this->notificationData[$notificationField]); + if (isset($this->_notificationData[$notificationField])) { + $feedData = array_reverse($this->_notificationData[$notificationField]); if (!empty($feedData)) { return $feedData[0]; diff --git a/src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Wizard.php b/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Wizard.php similarity index 70% rename from src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Wizard.php rename to app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Wizard.php index f8ef5cbf..df1f5374 100644 --- a/src/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Wizard.php +++ b/app/code/community/Zip/Payment/Block/Adminhtml/System/Config/Fieldset/Wizard.php @@ -7,18 +7,12 @@ * @author Zip Co - Plugin Team **/ -class Zip_Payment_Block_Adminhtml_System_Config_Fieldset_Wizard extends Mage_Adminhtml_Block_System_Config_Form_Fieldset +class Zip_Payment_Block_Adminhtml_System_Config_Fieldset_Wizard +extends Mage_Adminhtml_Block_System_Config_Form_Fieldset { - protected $headerTitleTemplate = 'zip/payment/system/config/fieldset/wizard/header_title.phtml'; - protected $noticeTemplate = 'zip/payment/system/config/fieldset/wizard/notice.phtml'; + protected $_headerTitleTemplate = 'zip/payment/system/config/fieldset/wizard/header_title.phtml'; + protected $_noticeTemplate = 'zip/payment/system/config/fieldset/wizard/notice.phtml'; - protected $pluginCurrentVersion = ''; - - protected function _construct() - { - $this->pluginCurrentVersion = Mage::helper('zip_payment')->getCurrentVersion(); - parent::_construct(); - } /** * Add custom css class @@ -43,7 +37,10 @@ protected function isPaymentEnabled($element) $groupConfig = $this->getGroup($element)->asArray(); $activePath = isset($groupConfig['active_path']) ? $groupConfig['active_path'] : ''; - return !empty($activePath) ? (bool) (string) $this->_getConfigDataModel()->getConfigDataValue($activePath) : false; + return !empty($activePath) ? (bool) (string) $this-> + _getConfigDataModel() + ->getConfigDataValue($activePath) : + false; } /** @@ -69,13 +66,13 @@ protected function _getConfigDataModel() protected function _getHeaderTitleHtml($element) { $block = Mage::app()->getLayout()->createBlock('core/template'); - $block->setTemplate($this->headerTitleTemplate); + $block->setTemplate($this->_headerTitleTemplate); $block->setData( array( - 'version' => $this->pluginCurrentVersion, - 'logo' => Mage::helper('zip_payment')->getConfig()->getLogo(), - 'element' => $element, - 'config' => $this->getGroup($element)->asArray() + 'version' => Mage::helper('zip_payment')->getCurrentVersion(), + 'logo' => Mage::helper('zip_payment')->getConfig()->getLogo(), + 'element' => $element, + 'config' => $this->getGroup($element)->asArray() ) ); diff --git a/src/app/code/community/Zip/Payment/Block/Checkout/Failure.php b/app/code/community/Zip/Payment/Block/Checkout/Failure.php similarity index 70% rename from src/app/code/community/Zip/Payment/Block/Checkout/Failure.php rename to app/code/community/Zip/Payment/Block/Checkout/Failure.php index 7f389a70..68cfb638 100644 --- a/src/app/code/community/Zip/Payment/Block/Checkout/Failure.php +++ b/app/code/community/Zip/Payment/Block/Checkout/Failure.php @@ -13,7 +13,7 @@ class Zip_Payment_Block_Checkout_Failure extends Zip_Payment_Block_Checkout_Page const CONFIG_CHECKOUT_FAILURE_HEADING_PATH = 'payment/zip_payment/checkout/failure/heading'; const CONFIG_CHECKOUT_FAILURE_CONTENT_PATH = 'payment/zip_payment/checkout/failure/content'; - protected $headingTextConfigPath = self::CONFIG_CHECKOUT_FAILURE_HEADING_PATH; - protected $contentHtmlConfigPath = self::CONFIG_CHECKOUT_FAILURE_CONTENT_PATH; + protected $_headingTextConfigPath = self::CONFIG_CHECKOUT_FAILURE_HEADING_PATH; + protected $_contentHtmlConfigPath = self::CONFIG_CHECKOUT_FAILURE_CONTENT_PATH; } diff --git a/app/code/community/Zip/Payment/Block/Checkout/Overlay.php b/app/code/community/Zip/Payment/Block/Checkout/Overlay.php new file mode 100644 index 00000000..193ec43f --- /dev/null +++ b/app/code/community/Zip/Payment/Block/Checkout/Overlay.php @@ -0,0 +1,21 @@ +isActive(); + } +} diff --git a/src/app/code/community/Zip/Payment/Block/Checkout/Page.php b/app/code/community/Zip/Payment/Block/Checkout/Page.php similarity index 74% rename from src/app/code/community/Zip/Payment/Block/Checkout/Page.php rename to app/code/community/Zip/Payment/Block/Checkout/Page.php index 3bfb4cce..3f19c2c2 100644 --- a/src/app/code/community/Zip/Payment/Block/Checkout/Page.php +++ b/app/code/community/Zip/Payment/Block/Checkout/Page.php @@ -10,13 +10,13 @@ class Zip_Payment_Block_Checkout_Page extends Mage_Core_Block_Template { - protected $headingTextConfigPath = null; - protected $contentHtmlConfigPath = null; - protected $messageItems = null; + protected $_headingTextConfigPath = null; + protected $_contentHtmlConfigPath = null; + protected $_messageItems = null; public function __construct() { - $this->messageItems = Mage::helper('zip_payment')->getCheckoutSession()->getMessages()->getItems(); + $this->_messageItems = Mage::helper('zip_payment')->getCheckoutSession()->getMessages()->getItems(); } /** @@ -45,9 +45,9 @@ public function getSlogan() * * @return array */ - public function getMessageItems() + public function get_messageItems() { - return $this->messageItems; + return $this->_messageItems; } /** @@ -57,7 +57,7 @@ public function getMessageItems() */ public function getHeadingText() { - $headingText = Mage::helper('zip_payment')->getConfig()->getValue($this->headingTextConfigPath); + $headingText = Mage::helper('zip_payment')->getConfig()->getValue($this->_headingTextConfigPath); return Mage::helper('zip_payment')->__($headingText); } @@ -66,7 +66,7 @@ public function getHeadingText() */ public function getContentHtml() { - return Mage::helper('zip_payment')->getConfig()->getValue($this->contentHtmlConfigPath); + return Mage::helper('zip_payment')->getConfig()->getValue($this->_contentHtmlConfigPath); } } diff --git a/src/app/code/community/Zip/Payment/Block/Checkout/Referred.php b/app/code/community/Zip/Payment/Block/Checkout/Referred.php similarity index 70% rename from src/app/code/community/Zip/Payment/Block/Checkout/Referred.php rename to app/code/community/Zip/Payment/Block/Checkout/Referred.php index f23367d7..9862359e 100644 --- a/src/app/code/community/Zip/Payment/Block/Checkout/Referred.php +++ b/app/code/community/Zip/Payment/Block/Checkout/Referred.php @@ -13,6 +13,6 @@ class Zip_Payment_Block_Checkout_Referred extends Zip_Payment_Block_Checkout_Pag const CONFIG_CHECKOUT_REFERRED_HEADING_PATH = 'payment/zip_payment/checkout/referred/heading'; const CONFIG_CHECKOUT_REFERRED_CONTENT_PATH = 'payment/zip_payment/checkout/referred/content'; - protected $headingTextConfigPath = self::CONFIG_CHECKOUT_REFERRED_HEADING_PATH; - protected $contentHtmlConfigPath = self::CONFIG_CHECKOUT_REFERRED_CONTENT_PATH; + protected $_headingTextConfigPath = self::CONFIG_CHECKOUT_REFERRED_HEADING_PATH; + protected $_contentHtmlConfigPath = self::CONFIG_CHECKOUT_REFERRED_CONTENT_PATH; } diff --git a/src/app/code/community/Zip/Payment/Block/Checkout/Script.php b/app/code/community/Zip/Payment/Block/Checkout/Script.php similarity index 71% rename from src/app/code/community/Zip/Payment/Block/Checkout/Script.php rename to app/code/community/Zip/Payment/Block/Checkout/Script.php index 119f0377..913b7f63 100644 --- a/src/app/code/community/Zip/Payment/Block/Checkout/Script.php +++ b/app/code/community/Zip/Payment/Block/Checkout/Script.php @@ -30,7 +30,9 @@ public function isActive() */ public function getMethodCode() { - return Mage::helper('zip_payment')->getConfig()->getMethodCode(); + return Mage::helper('zip_payment') + ->getConfig() + ->getMethodCode(); } /** @@ -40,7 +42,8 @@ public function getMethodCode() */ public function getCheckoutUrl() { - return Mage::helper('zip_payment')->getUrl(Zip_Payment_Model_Config::CHECKOUT_START_URL_ROUTE); + return Mage::helper('zip_payment') + ->getUrl(Zip_Payment_Model_Config::CHECKOUT_START_URL_ROUTE); } /** @@ -50,7 +53,9 @@ public function getCheckoutUrl() */ public function getResponseUrl() { - return Mage::helper('zip_payment')->getUrl(Zip_Payment_Model_Config::CHECKOUT_RESPONSE_URL_ROUTE) . '?' . Zip_Payment_Model_Config::URL_PARAM_RESULT . '='; + return Mage::helper('zip_payment') + ->getUrl(Zip_Payment_Model_Config::CHECKOUT_RESPONSE_URL_ROUTE) . + '?' . Zip_Payment_Model_Config::URL_PARAM_RESULT . '='; } /** @@ -58,7 +63,9 @@ public function getResponseUrl() */ public function getCheckoutJsLibUrl() { - return Mage::helper('zip_payment')->getConfig()->getValue(Zip_Payment_Model_Config::CONFIG_CHECKOUT_JS_LIB_PATH); + return Mage::helper('zip_payment') + ->getConfig() + ->getValue(Zip_Payment_Model_Config::CONFIG_CHECKOUT_JS_LIB_PATH); } /** @@ -70,10 +77,12 @@ public function getCheckoutScriptList() $baseScript = $scriptBaseUrl . self::CHECKOUT_JS_PATH; $scriptList = array($baseScript); - if (Mage::helper('zip_payment')->isOnepageCheckout()) { + if (Mage::helper('zip_payment')->isUsingOnePageCheckout()) { array_push($scriptList, $scriptBaseUrl . self::ONEPAGE_CHECKOUT_JS_PATH); } else { - $customScript = Mage::helper('zip_payment')->getConfig()->getValue(Zip_Payment_Model_Config::CONFIG_CHECKOUT_CUSTOM_SCRIPT_PATH); + $customScript = Mage::helper('zip_payment') + ->getConfig() + ->getValue(Zip_Payment_Model_Config::CONFIG_CHECKOUT_CUSTOM_SCRIPT_PATH); if ($customScript) { array_push($scriptList, $customScript); } @@ -90,7 +99,7 @@ public function getCheckoutScriptList() */ public function isRedirect() { - return Mage::helper('zip_payment')->getConfig()->getValue(Zip_Payment_Model_Config::CONFIG_CEHCKOUT_DISPLAY_MODE_PATH) == Zip_Payment_Model_Adminhtml_System_Config_Source_DisplayMode::DISPLAY_MODE_REDIRECT; + return Mage::helper('zip_payment')->isRedirectCheckoutDisplayModel(); } /** diff --git a/src/app/code/community/Zip/Payment/Block/Method/Form.php b/app/code/community/Zip/Payment/Block/Method/Form.php similarity index 77% rename from src/app/code/community/Zip/Payment/Block/Method/Form.php rename to app/code/community/Zip/Payment/Block/Method/Form.php index 94f2de9d..9e1b20ed 100644 --- a/src/app/code/community/Zip/Payment/Block/Method/Form.php +++ b/app/code/community/Zip/Payment/Block/Method/Form.php @@ -9,14 +9,14 @@ class Zip_Payment_Block_Method_Form extends Mage_Payment_Block_Form { - protected $template = 'zip/payment/method/form/default.phtml'; - protected $labelTemplate = 'zip/payment/method/form/label.phtml'; + protected $_template = 'zip/payment/method/form/default.phtml'; + protected $_labelTemplate = 'zip/payment/method/form/label.phtml'; protected function _construct() { parent::_construct(); - $this->setTemplate($this->template); + $this->setTemplate($this->_template); $this->setMethodLabelAfterHtml($this->getMethodLabelHtml()); $this->setMethodTitle(""); } @@ -24,7 +24,7 @@ protected function _construct() protected function getMethodLabelHtml() { $block = Mage::app()->getLayout()->createBlock('core/template'); - $block->setTemplate($this->labelTemplate); + $block->setTemplate($this->_labelTemplate); $config = Mage::helper('zip_payment')->getConfig(); $block->setData( diff --git a/src/app/code/community/Zip/Payment/Block/Method/Info.php b/app/code/community/Zip/Payment/Block/Method/Info.php similarity index 78% rename from src/app/code/community/Zip/Payment/Block/Method/Info.php rename to app/code/community/Zip/Payment/Block/Method/Info.php index 56e73d60..756efb12 100644 --- a/src/app/code/community/Zip/Payment/Block/Method/Info.php +++ b/app/code/community/Zip/Payment/Block/Method/Info.php @@ -10,20 +10,14 @@ class Zip_Payment_Block_Method_Info extends Mage_Payment_Block_Info { const RECEIPT_NUMBER_LABEL = 'Receipt Number'; + const PRODUCT_TYPE_LABEL = 'Product Type'; - protected $template = 'zip/payment/method/info/default.phtml'; - - /** - * Config model instance - * - * @var Zip_Payment_Model_Config - */ - protected $config = null; + protected $_template = 'zip/payment/method/info/default.phtml'; protected function _construct() { parent::_construct(); - $this->setTemplate($this->template); + $this->setTemplate($this->_template); } /** @@ -41,6 +35,10 @@ protected function _prepareSpecificInformation($transport = null) $info[self::RECEIPT_NUMBER_LABEL] = $additionalInformation[Zip_Payment_Model_Config::PAYMENT_RECEIPT_NUMBER_KEY]; } + if (isset($additionalInformation['product'])) { + $info[self::PRODUCT_TYPE_LABEL] = $additionalInformation['product']; + } + return $transport->addData($info); } diff --git a/src/app/code/community/Zip/Payment/Block/Widget.php b/app/code/community/Zip/Payment/Block/Widget.php similarity index 82% rename from src/app/code/community/Zip/Payment/Block/Widget.php rename to app/code/community/Zip/Payment/Block/Widget.php index 27596c90..6a712116 100644 --- a/src/app/code/community/Zip/Payment/Block/Widget.php +++ b/app/code/community/Zip/Payment/Block/Widget.php @@ -19,14 +19,14 @@ class Zip_Payment_Block_Widget extends Mage_Core_Block_Template const CONFIG_ENVIRONMENT_PATH = 'payment/zip_payment/environment'; const CONFIG_HOME_PAGE_PATH = 'web/default/cms_home_page'; - protected $supportedWidgetTypes = array('widget', 'banner', 'tagline'); + protected $_supportedWidgetTypes = array('widget', 'banner', 'tagline'); /** * Config instance * * @var Zip_Payment_Model_Config */ - protected $config = null; + protected $_config = null; /** * Config instance getter @@ -35,11 +35,11 @@ class Zip_Payment_Block_Widget extends Mage_Core_Block_Template */ public function getConfig() { - if ($this->config == null) { - $this->config = Mage::helper('zip_payment')->getConfig(); + if ($this->_config == null) { + $this->_config = Mage::helper('zip_payment')->getConfig(); } - return $this->config; + return $this->_config; } /** @@ -82,7 +82,7 @@ protected function isActive() if (Mage::helper('zip_payment')->isActive() && $this->getConfig()->getFlag(self::CONFIG_WIDGETS_ENABLED_PATH)) { $pageType = $this->getWidgetPageType(); - if (is_null($pageType)) { + if ($pageType === null) { return false; } @@ -90,13 +90,14 @@ protected function isActive() return true; } - foreach ($this->supportedWidgetTypes as $widgetType) { - $enabled = $this->getConfig()->getValue(self::CONFIG_WIDGET_PATH_PREFIX . $pageType . '_page/' . $widgetType . '/enabled'); + foreach ($this->_supportedWidgetTypes as $widgetType) { + $enabled = $this->getConfig() + ->getValue(self::CONFIG_WIDGET_PATH_PREFIX . $pageType . '_page/' . $widgetType . '/enabled'); /** * Make sure there one widget type is enable for current page type */ - if (!is_null($enabled) && $enabled) { + if ($enabled !== null && $enabled) { return true; } } @@ -114,12 +115,12 @@ protected function getElementSelectors() $selectors = array(); $helper = Mage::helper('zip_payment'); - foreach ($this->supportedWidgetTypes as $widgetType) { + foreach ($this->_supportedWidgetTypes as $widgetType) { $pageType = $this->getWidgetPageType(); $path = self::CONFIG_WIDGET_PATH_PREFIX . $pageType . '_page/' . $widgetType; $enabled = $helper->getConfig()->getValue($path . '/enabled'); - if (!is_null($enabled) && $enabled) { + if ($enabled !== null && $enabled) { $widgetType = $widgetType == 'widget' ? $pageType . '_' . $widgetType : $widgetType; $selectors[$widgetType] = $helper->getConfig()->getValue($path . '/selector'); } @@ -138,7 +139,7 @@ protected function getWidgetPageType() $helper = Mage::helper('zip_payment'); $pageIdentifier = $helper->getPageIdentifier(); - if ($helper->isOnepageCheckout() || $helper->isOnestepCheckout()) { + if ($helper->isUsingOnePageCheckout() || $helper->isUsingOneStepCheckout()) { return 'checkout'; } diff --git a/src/app/code/community/Zip/Payment/Controller/Checkout.php b/app/code/community/Zip/Payment/Controller/Checkout.php similarity index 86% rename from src/app/code/community/Zip/Payment/Controller/Checkout.php rename to app/code/community/Zip/Payment/Controller/Checkout.php index d9ff7a52..ae807e17 100644 --- a/src/app/code/community/Zip/Payment/Controller/Checkout.php +++ b/app/code/community/Zip/Payment/Controller/Checkout.php @@ -13,7 +13,7 @@ class Zip_Payment_Controller_Checkout extends Mage_Core_Controller_Front_Action /** * @var Zip_Payment_Model_Logger */ - protected $logger = null; + protected $_logger = null; /** * Retrieve model helper @@ -32,11 +32,11 @@ protected function getHelper() */ public function getLogger() { - if ($this->logger == null) { - $this->logger = Mage::getSingleton('zip_payment/logger'); + if ($this->_logger == null) { + $this->_logger = Mage::getSingleton('zip_payment/logger'); } - return $this->logger; + return $this->_logger; } @@ -79,7 +79,10 @@ protected function createBreadCrumbs($key, $label) ) ); - $isLandingPageEnabled = $this->getHelper()->getConfig()->getFlag(Zip_Payment_Model_Config::CONFIG_LANDING_PAGE_ENABLED_PATH); + $isLandingPageEnabled = $this + ->getHelper() + ->getConfig() + ->getFlag(Zip_Payment_Model_Config::CONFIG_LANDING_PAGE_ENABLED_PATH); if ($isLandingPageEnabled) { $breadcrumbs->addCrumb( diff --git a/src/app/code/community/Zip/Payment/Helper/Data.php b/app/code/community/Zip/Payment/Helper/Data.php similarity index 62% rename from src/app/code/community/Zip/Payment/Helper/Data.php rename to app/code/community/Zip/Payment/Helper/Data.php index 3ec89364..605e4fd4 100644 --- a/src/app/code/community/Zip/Payment/Helper/Data.php +++ b/app/code/community/Zip/Payment/Helper/Data.php @@ -115,6 +115,15 @@ public function returnJsonResponse($response) Mage::app()->getFrontController()->getResponse()->setBody(Mage::helper('core')->jsonEncode($response)); } + /** + * check whether checkout display model is redirect + */ + public function isRedirectCheckoutDisplayModel() + { + return $this->getConfig()->getValue(Zip_Payment_Model_Config::CONFIG_CHECKOUT_DISPLAY_MODE_PATH) == + Zip_Payment_Model_Adminhtml_System_Config_Source_DisplayMode::DISPLAY_MODE_REDIRECT; + } + /******************************************* * PAGE DETECTION @@ -128,20 +137,38 @@ public function getPageIdentifier() return Mage::app()->getFrontController()->getAction()->getFullActionName(); } + + /** + * get path for current page + */ + public function getPagePath() + { + $currentUrl = Mage::helper('core/url')->getCurrentUrl(); + $url = Mage::getSingleton('core/url')->parseUrl($currentUrl); + return $url->getPath(); + } + /** * is currently using one page checkout */ - public function isOnepageCheckout() + public function isUsingOnePageCheckout() { - return $this->getPageIdentifier() == Zip_Payment_Model_Config::ONEPAGE_CHECKOUT_IDENTIFIER; + return $this->getPagePath() == Zip_Payment_Model_Config::ONEPAGE_CHECKOUT_IDENTIFIER && + $this->getConfig()->getValue(Zip_Payment_Model_Config::CONFIG_CHECKOUT_TYPE_PATH) == + Zip_Payment_Model_Adminhtml_System_Config_Source_CheckoutType::CHECKOUT_TYPE_ONE_PAGE; } /** - * checkout current page is onestep checkout + * is current page onestep checkout */ - public function isOnestepCheckout() + public function isUsingOneStepCheckout() { - return $this->getConfig()->getFlag(Zip_Payment_Model_Config::CONFIG_CHECKOUT_ONESTEPCHECKOUTS_PATH . '/' . $this->getPageIdentifier()); + $path = rtrim($this->getPagePath(), '/'); + $checkoutPath = rtrim($this->getConfig()->getValue(Zip_Payment_Model_Config::CONFIG_CHECKOUT_PATH_PATH), '/'); + + return $path == $checkoutPath && + $this->getConfig()->getValue(Zip_Payment_Model_Config::CONFIG_CHECKOUT_TYPE_PATH) == + Zip_Payment_Model_Adminhtml_System_Config_Source_CheckoutType::CHECKOUT_TYPE_ONE_STEP; } /** @@ -150,11 +177,40 @@ public function isOnestepCheckout() public function isReferredOrder($order) { if ($order && $order->getId()) { - return $order->getStatus() === $this->getConfig()->getValue(Zip_Payment_Model_Config::CONFIG_CHECKOUT_REFERRED_ORDER_STATUS_PATH); + return $order->getStatus() === $this + ->getConfig() + ->getValue(Zip_Payment_Model_Config::CONFIG_CHECKOUT_REFERRED_ORDER_STATUS_PATH); } return false; + } + + /** + * check whether an order is a pickup order + */ + public function isPickupOrder($order) + { + if ($order && $order->getId()) { + // virtual product will use pick up shipping method + if($order->getIsVirtual()) { + return true; + } + $shippingAddress = $order->getShippingAddress(); + if($shippingAddress == null) { + return true; + } + $shippingMethod = $shippingAddress->getShippingMethod(); + if(empty($shippingMethod)) { + return true; + } + // Check click and collect and set pickup as true + $clickCollect = $this->getConfig()->getValue(Zip_Payment_Model_Config::CONFIG_CHECKOUT_CLICK_COLLECT_PATH); + if(!empty($clickCollect) && preg_match('/.' . $clickCollect . '*/', $shippingMethod)) { + return true; + } + } + return false; } @@ -184,15 +240,16 @@ public function getCheckoutSessionData() return $this->getCheckoutSession()->getData(Zip_Payment_Model_Config::CHECKOUT_SESSION_KEY); } - /** - * get checkout id from checkout session - * - * @return string - */ + /** + * get checkout id from checkout session + * + * @return string + */ public function getCheckoutIdFromSession() { $sessionData = $this->getCheckoutSessionData(); - return isset($sessionData[Zip_Payment_Model_Api_Checkout::CHECKOUT_ID_KEY]) ? $sessionData[Zip_Payment_Model_Api_Checkout::CHECKOUT_ID_KEY] : null; + return isset($sessionData[Zip_Payment_Model_Api_Checkout::CHECKOUT_ID_KEY]) ? + $sessionData[Zip_Payment_Model_Api_Checkout::CHECKOUT_ID_KEY] : null; } /** @@ -203,7 +260,8 @@ public function getCheckoutIdFromSession() public function getCheckoutRedirectUrlFromSession() { $sessionData = $this->getCheckoutSessionData(); - return isset($sessionData[Zip_Payment_Model_Api_Checkout::CHECKOUT_REDIRECT_URL_KEY]) ? $sessionData[Zip_Payment_Model_Api_Checkout::CHECKOUT_REDIRECT_URL_KEY] : null; + return isset($sessionData[Zip_Payment_Model_Api_Checkout::CHECKOUT_REDIRECT_URL_KEY]) ? + $sessionData[Zip_Payment_Model_Api_Checkout::CHECKOUT_REDIRECT_URL_KEY] : null; } /** @@ -214,7 +272,8 @@ public function getCheckoutRedirectUrlFromSession() public function getCheckoutStateFromSession() { $sessionData = $this->getCheckoutSessionData(); - return isset($sessionData[Zip_Payment_Model_Api_Checkout::CHECKOUT_STATE_KEY]) ? $sessionData[Zip_Payment_Model_Api_Checkout::CHECKOUT_STATE_KEY] : null; + return isset($sessionData[Zip_Payment_Model_Api_Checkout::CHECKOUT_STATE_KEY]) ? + $sessionData[Zip_Payment_Model_Api_Checkout::CHECKOUT_STATE_KEY] : null; } /** @@ -234,4 +293,13 @@ public function isReferredCheckout() } + /** + * delete log file + */ + public function removeLogFile($filename) + { + $path = Mage::getBaseDir('var') . DS . 'log' . DS . $filename; + $io = new Varien_Io_File(); + $io->rm($path); + } } diff --git a/src/app/code/community/Zip/Payment/Model/Adminhtml/Notification/Feed.php b/app/code/community/Zip/Payment/Model/Adminhtml/Notification/Feed.php similarity index 66% rename from src/app/code/community/Zip/Payment/Model/Adminhtml/Notification/Feed.php rename to app/code/community/Zip/Payment/Model/Adminhtml/Notification/Feed.php index 64b7771e..56a93059 100644 --- a/src/app/code/community/Zip/Payment/Model/Adminhtml/Notification/Feed.php +++ b/app/code/community/Zip/Payment/Model/Adminhtml/Notification/Feed.php @@ -16,26 +16,7 @@ class Zip_Payment_Model_Adminhtml_Notification_Feed extends Mage_AdminNotificati const NOTIFICATION_FIELD = 'notifications'; const DEFAULT_NOTIFICATION_TITLE = 'Zip Payment'; - protected $feedData = null; - - /** - * Config model instance - * - * @var Zip_Payment_Model_Config - */ - protected $config = null; - - /** - * get config instance - */ - protected function getConfig() - { - if ($this->config == null) { - $this->config = $this->getHelper()->getConfig(); - } - - return $this->config; - } + protected $_feedData = null; /** * get model helper @@ -50,18 +31,21 @@ protected function getHelper() */ public function checkUpdate() { - if (($this->getFrequency() + $this->getLastUpdate()) > time()) { + if (($this->getFrequency() + $this->getLastUpdate()) > Mage::getSingleton('core/date')->timestamp()) { return $this; } $data = array(); - $this->feedData = $this->getFeedData(); + $this->_feedData = $this->getFeedData(); - if (!empty($this->feedData) && isset($this->feedData[self::NOTIFICATION_FIELD])) { - foreach ($this->feedData[self::NOTIFICATION_FIELD] as $item) { + if (!empty($this->_feedData) && isset($this->_feedData[self::NOTIFICATION_FIELD])) { + foreach ($this->_feedData[self::NOTIFICATION_FIELD] as $item) { $data[] = array( 'severity' => Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE, - 'date_added' => isset($item['date']) ? gmdate('Y-m-d H:i:s', strtotime($item['date'])) : date('Y-m-d H:i:s'), + 'date_added' => Mage::getSingleton('core/date')->date( + 'Y-m-d H:i:s', + isset($item['date']) ? strtotime($item['date']) : null + ), 'title' => isset($item['title']) ? $item['title'] : self::DEFAULT_NOTIFICATION_TITLE, 'description' => isset($item['description']) ? $item['description'] : '', 'url' => isset($item['url']) ? $item['url'] : '' @@ -90,19 +74,27 @@ public function getVersionUpgradeNotification() { $currentVersion = $this->getHelper()->getCurrentVersion(); - if ($this->feedData == null) { - $this->feedData = $this->getFeedData(); + if ($this->_feedData == null) { + $this->_feedData = $this->getFeedData(); } - if (!empty($currentVersion) && isset($this->feedData[self::RELEASE_FIELD]) && isset($this->feedData[self::RELEASE_FIELD][self::VERSION_FIELD])) { - $item = $this->feedData[self::RELEASE_FIELD]; + $isVersionUpdated = !empty($currentVersion) && + isset($this->_feedData[self::RELEASE_FIELD]) && + isset($this->_feedData[self::RELEASE_FIELD][self::VERSION_FIELD]); + + if ($isVersionUpdated) { + $item = $this->_feedData[self::RELEASE_FIELD]; $latestVersion = trim($item[self::VERSION_FIELD]); if (!empty($latestVersion) && $currentVersion < $latestVersion) { return array( 'severity' => Mage_AdminNotification_Model_Inbox::SEVERITY_MAJOR, - 'date_added' => isset($item['date']) ? gmdate('Y-m-d H:i:s', strtotime($item['date'])) : date('Y-m-d H:i:s'), - 'title' => isset($item['title']) ? $item['title'] : 'New Zip Payment version ' . $latestVersion . ' is available now!', + 'date_added' => Mage::getSingleton('core/date')->date( + 'Y-m-d H:i:s', + isset($item['date']) ? strtotime($item['date']) : null + ), + 'title' => isset($item['title']) ? + $item['title'] : 'New Zip Payment version ' . $latestVersion . ' is available now!', 'description' => isset($item['description']) ? $item['description'] : '', 'url' => isset($item['url']) ? $item['url'] : '' ); @@ -119,8 +111,8 @@ public function getVersionUpgradeNotification() */ public function getFeedUrl() { - if (is_null($this->_feedUrl)) { - $this->_feedUrl = $this->getConfig()->getValue(self::CONFIG_FEED_URL_PATH); + if ($this->_feedUrl === null) { + $this->_feedUrl = $this->getHelper()->getConfig()->getValue(self::CONFIG_FEED_URL_PATH); } return $this->_feedUrl; @@ -138,7 +130,7 @@ public function getFeedData() ) ); - $curl->write(Zend_Http_Client::GET, $this->getFeedUrl(), '1.0'); + $curl->write(Zend_Http_Client::GET, $this->getFeedUrl()); $data = $curl->read(); if ($data === false) { diff --git a/src/app/code/community/Zip/Payment/Model/Adminhtml/Observer.php b/app/code/community/Zip/Payment/Model/Adminhtml/Observer.php similarity index 70% rename from src/app/code/community/Zip/Payment/Model/Adminhtml/Observer.php rename to app/code/community/Zip/Payment/Model/Adminhtml/Observer.php index f2f364d7..109a9d2e 100644 --- a/src/app/code/community/Zip/Payment/Model/Adminhtml/Observer.php +++ b/app/code/community/Zip/Payment/Model/Adminhtml/Observer.php @@ -12,26 +12,6 @@ class Zip_Payment_Model_Adminhtml_Observer { - /** - * Config model instance - * - * @var Zip_Payment_Model_Config - */ - protected $config = null; - - /** - * get config instance - */ - protected function getConfig() - { - if ($this->config == null) { - $this->config = $this->getHelper()->getConfig(); - } - - return $this->config; - } - - /** * get model helper */ @@ -45,7 +25,7 @@ protected function getHelper() */ public function checkAdminNotifications(Varien_Event_Observer $observer) { - $enabled = $this->getConfig()->getFlag(Zip_Payment_Model_Config::CONFIG_NOTIFICATION_ENABLED_PATH); + $enabled = $this->getHelper()->getConfig()->getFlag(Zip_Payment_Model_Config::CONFIG_NOTIFICATION_ENABLED_PATH); if ($enabled) { Mage::getSingleton('zip_payment/adminhtml_notification_feed')->checkUpdate(); diff --git a/src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Backend/HealthCheck.php b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Backend/HealthCheck.php similarity index 59% rename from src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Backend/HealthCheck.php rename to app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Backend/HealthCheck.php index 1b4d70a8..4b857d1e 100644 --- a/src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Backend/HealthCheck.php +++ b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Backend/HealthCheck.php @@ -14,9 +14,8 @@ class Zip_Payment_Model_Adminhtml_System_Config_Backend_HealthCheck extends Mage const STATUS_WARNING = 2; const STATUS_ERROR = 3; - const SSL_DISABLED_MESSAGE = 'Your site does not have SSL Certificates'; + const SSL_DISABLED_MESSAGE = 'Your store {store_name} ({store_url}) does not have SSL'; const CURL_EXTENSION_DISABLED = 'CURL extension has not been installed or disabled'; - const CURL_SSL_VERIFICATION_DISABLED_MESSAGE = 'CURL SSL Verification has been disabled'; const API_CERTIFICATE_INVALID_MESSAGE = 'SSL Certificate is not valid for the API'; const API_PRIVATE_KEY_INVALID_MESSAGE = 'Your API private key is empty or invalid'; const API_PUBLIC_KEY_INVALID_MESSAGE = 'Your API public key is empty or invalid'; @@ -26,7 +25,7 @@ class Zip_Payment_Model_Adminhtml_System_Config_Backend_HealthCheck extends Mage const CONFIG_PRIVATE_KEY_PATH = 'payment/zip_payment/private_key'; const CONFIG_PUBLIC_KEY_PATH = 'payment/zip_payment/public_key'; - protected $result = array( + protected $_result = array( 'overall_status' => self::STATUS_SUCCESS, 'items' => array() ); @@ -43,8 +42,9 @@ protected function _afterLoad() protected function getHealthResult() { $config = Mage::helper('zip_payment')->getConfig(); + $apiConfig = Mage::getSingleton('zip_payment/api_configuration') + ->generateApiConfiguration(); - $sslEnabled = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off'; $curlEnabled = function_exists('curl_version'); $publicKey = $config->getValue(self::CONFIG_PUBLIC_KEY_PATH); $privateKey = $config->getValue(self::CONFIG_PRIVATE_KEY_PATH); @@ -65,45 +65,33 @@ protected function getHealthResult() } // check whether SSL is enabled - if (!$sslEnabled) { - $this->appendFailedItem(self::STATUS_WARNING, self::SSL_DISABLED_MESSAGE); - } + $this->checkStoreSSLSettings(); // check whether CURL is enabled ot not if (!$curlEnabled) { $this->appendFailedItem(self::STATUS_ERROR, self::CURL_EXTENSION_DISABLED); } else { - $curl = curl_init(); - - $curlSSLVerificationEnabled = curl_getinfo($curl, CURLOPT_SSL_VERIFYPEER) && curl_getinfo($curl, CURLOPT_SSL_VERIFYPEER); - $apiConfig = Mage::getSingleton('zip_payment/api_configuration')->generateApiConfiguration(); - $url = $apiConfig->getHost(); - - curl_setopt($curl, CURLOPT_NOBODY, true); - curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); - curl_setopt($curl, CURLOPT_TIMEOUT, 20); - curl_setopt($curl, CURLOPT_URL, $url); - - // if SSL verification is disabled - if (!$curlSSLVerificationEnabled) { - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); - - $this->appendFailedItem(self::STATUS_WARNING, self::CURL_SSL_VERIFICATION_DISABLED_MESSAGE); - } + $curl = new Varien_Http_Adapter_Curl(); + $curl->setConfig( + array( + 'timeout' => 10 + ) + ); try { $headers = array( - 'Authorization: ' . $apiConfig->getApiKeyPrefix('Authorization') . ' ' . $apiConfig->getApiKey('Authorization'), + 'Authorization: ' . + $apiConfig->getApiKeyPrefix('Authorization') . + ' ' . + $apiConfig->getApiKey('Authorization'), 'Content-Type: application/json', 'Zip-Version: 2017-03-01' ); - curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - curl_exec($curl); + $curl->write(Zend_Http_Client::GET, $apiConfig->getHost(), '1.1', $headers); - $sslVerified = curl_getinfo($curl, CURLINFO_SSL_VERIFYRESULT) == 0; - $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + $sslVerified = $curl->getInfo(CURLINFO_SSL_VERIFYRESULT) == 0; + $httpCode = $curl->getInfo(CURLINFO_HTTP_CODE); // if API certification invalid if (!$sslVerified) { @@ -119,29 +107,62 @@ protected function getHealthResult() $this->appendFailedItem(self::STATUS_ERROR, self::CONFIG_PRIVATE_KEY_PATH); } - curl_close($curl); + $curl->close(); } usort( - $this->result['items'], function ($a, $b) { + $this->_result['items'], function ($a, $b) { return $b['status'] - $a['status']; } ); - return $this->result; + return $this->_result; } + protected function checkStoreSSLSettings() + { + foreach (Mage::app()->getWebsites() as $website) { + foreach ($website->getGroups() as $group) { + $stores = $group->getStores(); + foreach ($stores as $store) { + if ($store->getIsActive() !== '1' + || Mage::getStoreConfig(Zip_Payment_Model_Config::CONFIG_ACTIVE_PATH, $store->getStoreId()) !== '1' + ) { + continue; + } + + $storeSecureUrl = Mage::getStoreConfig( + Mage_Core_Model_Url::XML_PATH_SECURE_URL, $store->getStoreId() + ); + $url = parse_url($storeSecureUrl); + + if ($url['scheme'] !== 'https') { + $message = self::SSL_DISABLED_MESSAGE; + $message = str_replace('{store_name}', $store->getName(), $message); + $message = str_replace('{store_url}', $storeSecureUrl, $message); + + $this->appendFailedItem( + self::STATUS_WARNING, + $message + ); + } + } + } + } + } + + /** * append failed item into health result */ protected function appendFailedItem($status, $label) { - if (!is_null($status) && $this->result['overall_status'] < $status) { - $this->result['overall_status'] = $status; + if ($status !== null && $this->_result['overall_status'] < $status) { + $this->_result['overall_status'] = $status; } - $this->result['items'][] = array( + $this->_result['items'][] = array( "status" => $status, "label" => $label ); diff --git a/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/CheckoutType.php b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/CheckoutType.php new file mode 100644 index 00000000..05a7c81e --- /dev/null +++ b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/CheckoutType.php @@ -0,0 +1,41 @@ + self::CHECKOUT_TYPE_ONE_PAGE, + 'label' => Mage::helper('zip_payment')->__('Default Magento Checkout') + ), + array( + 'value' => self::CHECKOUT_TYPE_ONE_STEP, + 'label' => Mage::helper('zip_payment')->__('One Step Checkout') + ), + array( + 'value' => self::CHECKOUT_TYPE_OTHERS, + 'label' => Mage::helper('zip_payment')->__('Others') + ) + ); + } + +} diff --git a/src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Country.php b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Country.php similarity index 82% rename from src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Country.php rename to app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Country.php index 2381a292..4d24382a 100644 --- a/src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Country.php +++ b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Country.php @@ -15,7 +15,9 @@ class Zip_Payment_Model_Adminhtml_System_Config_Source_Country extends Mage_Admi public function toOptionArray($isMultiselect = false) { $options = array(); - $supportedCountries = Mage::helper('zip_payment')->getConfig()->getValue(Zip_Payment_Model_Config::CONFIG_SUPPORTED_COUNTRIES_PATH); + $supportedCountries = Mage::helper('zip_payment') + ->getConfig() + ->getValue(Zip_Payment_Model_Config::CONFIG_SUPPORTED_COUNTRIES_PATH); if (!empty($supportedCountries)) { $supportedCountries = explode(',', (string) $supportedCountries); diff --git a/src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Currency.php b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Currency.php similarity index 84% rename from src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Currency.php rename to app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Currency.php index 1487e406..2892a0eb 100644 --- a/src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Currency.php +++ b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Currency.php @@ -8,13 +8,15 @@ **/ -class Zip_Payment_Model_Adminhtml_System_Config_Source_Currency extends Mage_Adminhtml_Model_System_Config_Source_Currency +class Zip_Payment_Model_Adminhtml_System_Config_Source_Currency extends +Mage_Adminhtml_Model_System_Config_Source_Currency { public function toOptionArray($isMultiselect) { $options = array(); - $supportedCurrencies = Mage::getSingleton('zip_payment/config')->getValue(Zip_Payment_Model_Config::CONFIG_SUPPORTED_CURRENCIES_PATH); + $supportedCurrencies = Mage::getSingleton('zip_payment/config') + ->getValue(Zip_Payment_Model_Config::CONFIG_SUPPORTED_CURRENCIES_PATH); if (!empty($supportedCurrencies)) { $supportedCurrencies = explode(',', (string) $supportedCurrencies); diff --git a/src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/DisplayMode.php b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/DisplayMode.php similarity index 100% rename from src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/DisplayMode.php rename to app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/DisplayMode.php diff --git a/src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Environment.php b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Environment.php similarity index 100% rename from src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Environment.php rename to app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Environment.php diff --git a/src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/LogLevel.php b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/LogLevel.php similarity index 100% rename from src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/LogLevel.php rename to app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/LogLevel.php diff --git a/src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Payment/Allspecificcountries.php b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Payment/Allspecificcountries.php similarity index 80% rename from src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Payment/Allspecificcountries.php rename to app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Payment/Allspecificcountries.php index 1062085b..f4d775a9 100644 --- a/src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Payment/Allspecificcountries.php +++ b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/Payment/Allspecificcountries.php @@ -7,7 +7,8 @@ * @author Zip Co - Plugin Team **/ -class Zip_Payment_Model_Adminhtml_System_Config_Source_Payment_Allspecificcountries extends Mage_Adminhtml_Model_System_Config_Source_Payment_Allspecificcountries +class Zip_Payment_Model_Adminhtml_System_Config_Source_Payment_Allspecificcountries +extends Mage_Adminhtml_Model_System_Config_Source_Payment_Allspecificcountries { public function toOptionArray() { diff --git a/src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/PaymentAction.php b/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/PaymentAction.php similarity index 100% rename from src/app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/PaymentAction.php rename to app/code/community/Zip/Payment/Model/Adminhtml/System/Config/Source/PaymentAction.php diff --git a/src/app/code/community/Zip/Payment/Model/Api/Abstract.php b/app/code/community/Zip/Payment/Model/Api/Abstract.php similarity index 79% rename from src/app/code/community/Zip/Payment/Model/Api/Abstract.php rename to app/code/community/Zip/Payment/Model/Api/Abstract.php index b6f501b8..4cc9a4d6 100644 --- a/src/app/code/community/Zip/Payment/Model/Api/Abstract.php +++ b/app/code/community/Zip/Payment/Model/Api/Abstract.php @@ -10,18 +10,17 @@ use \Zip\Model\OrderShipping; use \Zip\Model\OrderItem; use \Zip\Model\Address; -use \Zip\Model\Metadata; use \Zip\ApiException; abstract class Zip_Payment_Model_Api_Abstract { - protected $api = null; - protected $apiConfig = null; - protected $logger = null; - protected $response = null; - protected $order = null; - protected $quote = null; - protected $storeId = null; + protected $_api = null; + protected $_apiConfig = null; + protected $_logger = null; + protected $_response = null; + protected $_order = null; + protected $_quote = null; + protected $_storeId = null; public function __construct($options) { @@ -31,16 +30,15 @@ public function __construct($options) $storeId = Mage::app()->getStore()->getId(); } - if ($this->apiConfig === null || $this->storeId !== $storeId) { + if ($this->_apiConfig === null || $this->_storeId !== $storeId) { // when api configuration is null or store id has been changed // new api configuration need to be created - $this->apiConfig = Mage::getSingleton('zip_payment/api_configuration')->generateApiConfiguration($storeId); - $this->storeId = $storeId; + $this->_apiConfig = Mage::getSingleton('zip_payment/api_configuration')->generateApiConfiguration($storeId); + $this->_storeId = $storeId; } } abstract protected function getApi(); - abstract protected function prepareCreatePayload(); /** * Get logger object @@ -49,11 +47,11 @@ abstract protected function prepareCreatePayload(); */ protected function getLogger() { - if ($this->logger == null) { - $this->logger = Mage::getModel('zip_payment/logger'); + if ($this->_logger == null) { + $this->_logger = Mage::getModel('zip_payment/logger'); } - return $this->logger; + return $this->_logger; } /** @@ -71,7 +69,7 @@ protected function getHelper() */ protected function getOrder() { - return $this->order; + return $this->_order; } /** @@ -81,11 +79,11 @@ protected function getOrder() */ protected function getQuote() { - if ($this->quote === null) { - $this->quote = $this->getHelper()->getCheckoutSession()->getQuote(); + if ($this->_quote === null) { + $this->_quote = $this->getHelper()->getCheckoutSession()->getQuote(); } - return $this->quote; + return $this->_quote; } /** @@ -105,11 +103,11 @@ protected function logException($e) } } - /** - * capture order's shipping details - * - * @return Zip\Model\OrderShipping - */ + /** + * capture order's shipping details + * + * @return Zip\Model\OrderShipping + */ protected function getOrderShipping() { $model = $this->getOrder() ?: $this->getQuote(); @@ -117,7 +115,7 @@ protected function getOrderShipping() $shippingDetail = new OrderShipping(); $address = $model->getShippingAddress(); - $isPickup = $model->getIsVirtual() || $address == null; + $isPickup = $this->getHelper()->isPickupOrder($model); $shippingDetail->setPickup($isPickup); $region = $address->getRegion(); @@ -135,9 +133,6 @@ protected function getOrderShipping() ->setCity($address->getCity()); $shippingDetail->setAddress($shippingAddress); - - // TODO: implementation for tracking - // $shippingDetail->setTracking() } return $shippingDetail; @@ -185,8 +180,8 @@ protected function getOrderItems() $orderItems[] = $orderItem; } - //discount and other promotion to balance out - $shippingAmount = (float) ($this->getOrder() ? $model->getShippingInclTax() : $model->getShippingAddress()->getShippingAmount()); + //discount and other promotion to balance out + $shippingAmount = (float) ($this->getOrder() ? $model->getShippingInclTax() : $model->getShippingAddress()->getShippingAmount()); if ($shippingAmount > 0) { $shippingItem = new OrderItem; @@ -231,8 +226,10 @@ protected function getOrderItems() protected function getMetadata() { // object not working must use array - $metadata['platform'] = "Magento 1"; - $metadata['version'] = Mage::getVersion(); + $metadata['platform'] = 'Magento 1'; + $metadata['platform_version'] = Mage::getVersion(); + $metadata['plugin'] = 'zip-magento1'; + $metadata['plugin_version'] = '2.1.0'; return $metadata; } @@ -241,8 +238,12 @@ protected function getMetadata() * * @return string */ - protected function getIdempotencyKey() + protected function getIdempotencyKey($id = '') { + if ($id !== '' && $id !== null) { + return sha1($id); + } + return uniqid(); } @@ -253,8 +254,6 @@ protected function getIdempotencyKey() */ protected function getResponse() { - return $this->response; + return $this->_response; } - - } diff --git a/src/app/code/community/Zip/Payment/Model/Api/Charge.php b/app/code/community/Zip/Payment/Model/Api/Charge.php similarity index 88% rename from src/app/code/community/Zip/Payment/Model/Api/Charge.php rename to app/code/community/Zip/Payment/Model/Api/Charge.php index 900370b2..6a8120d8 100644 --- a/src/app/code/community/Zip/Payment/Model/Api/Charge.php +++ b/app/code/community/Zip/Payment/Model/Api/Charge.php @@ -21,9 +21,7 @@ class Zip_Payment_Model_Api_Charge extends Zip_Payment_Model_Api_Abstract const AUTHORITY_TYPE_TOKEN = "account_token"; const AUTHORITY_TYPE_STORECODE = "store_code"; - protected $chargeId = null; - protected $receiptNumber = null; - protected $paymentAction = null; + protected $_paymentAction = null; /** * get API model @@ -32,11 +30,11 @@ class Zip_Payment_Model_Api_Charge extends Zip_Payment_Model_Api_Abstract */ public function getApi() { - if ($this->api === null) { - $this->api = new ChargeApi(); + if ($this->_api === null) { + $this->_api = new ChargeApi(); } - return $this->api; + return $this->_api; } /** @@ -47,14 +45,14 @@ public function getApi() */ public function create($order, $paymentAction) { - $this->order = $order; - $this->paymentAction = $paymentAction; + $this->_order = $order; + $this->_paymentAction = $paymentAction; $payload = $this->prepareCreatePayload(); try { $charge = $this->getApi() - ->chargesCreate($payload, $this->getIdempotencyKey()); + ->chargesCreate($payload, $this->getIdempotencyKey($order->getIncrementId())); if (isset($charge->error)) { Mage::throwException($this->getHelper()->__('Could not create the charge')); @@ -66,7 +64,7 @@ public function create($order, $paymentAction) $this->getLogger()->log($this->getHelper()->__("Charge State: %s", $charge->getState())); - $this->response = $charge; + $this->_response = $charge; } catch (ApiException $e) { $this->logException($e); throw $e; @@ -107,7 +105,7 @@ public function capture($chargeId, $amount, $isPartialCapture = null) $this->getLogger()->debug('Charge State: ' . $charge->getState()); - $this->response = $charge; + $this->_response = $charge; } catch (ApiException $e) { $this->logException($e); throw $e; @@ -122,7 +120,7 @@ public function capture($chargeId, $amount, $isPartialCapture = null) public function cancel($chargeId) { try { - $this->getLogger()->debug('Cancel charge: '. $chargeId); + $this->getLogger()->debug('Cancel charge: ' . $chargeId); $charge = $this->getApi() ->chargesCancel($chargeId, $this->getIdempotencyKey()); @@ -137,7 +135,7 @@ public function cancel($chargeId) $this->getLogger()->debug('Charge State: ' . $charge->getState()); - $this->response = $charge; + $this->_response = $charge; } catch (ApiException $e) { $this->logException($e); throw $e; @@ -182,7 +180,6 @@ protected function getChargeOrder() ->setCartReference((string) $this->getOrder()->getId()); return $chargeOrder; - } @@ -207,7 +204,7 @@ protected function getAuthority($type = self::AUTHORITY_TYPE_CHECKOUT) */ protected function isImmediateCapture() { - return $this->paymentAction == Zip_Payment_Model_Method::ACTION_AUTHORIZE_CAPTURE; + return $this->_paymentAction == Zip_Payment_Model_Method::ACTION_AUTHORIZE_CAPTURE; } /** @@ -225,4 +222,9 @@ public function getReceiptNumber() { return $this->getResponse() ? $this->getResponse()->getReceiptNumber() : null; } + + public function getProduct() + { + return $this->getResponse() ? $this->getResponse()->getProduct() : null; + } } diff --git a/src/app/code/community/Zip/Payment/Model/Api/Checkout.php b/app/code/community/Zip/Payment/Model/Api/Checkout.php similarity index 94% rename from src/app/code/community/Zip/Payment/Model/Api/Checkout.php rename to app/code/community/Zip/Payment/Model/Api/Checkout.php index f1f928a2..27cbe334 100644 --- a/src/app/code/community/Zip/Payment/Model/Api/Checkout.php +++ b/app/code/community/Zip/Payment/Model/Api/Checkout.php @@ -38,11 +38,11 @@ class Zip_Payment_Model_Api_Checkout extends Zip_Payment_Model_Api_Abstract */ protected function getApi() { - if ($this->api === null) { - $this->api = new CheckoutApi(); + if ($this->_api === null) { + $this->_api = new CheckoutApi(); } - return $this->api; + return $this->_api; } /** @@ -76,7 +76,7 @@ public function create() throw new Mage_Payment_Exception("Could not create checkout"); } - $this->response = $checkout; + $this->_response = $checkout; } catch (ApiException $e) { $this->logException($e); throw $e; @@ -103,7 +103,7 @@ public function retrieve($checkoutId) throw new Mage_Payment_Exception("Could not retrieve a checkout"); } - $this->response = $checkout; + $this->_response = $checkout; } catch (ApiException $e) { $this->logException($e); throw $e; @@ -191,11 +191,11 @@ protected function getCheckoutOrder() return $order; } - /** - * Returns the prepared checkout configuration model - * - * @return Zip\Model\CheckoutConfiguration - */ + /** + * Returns the prepared checkout configuration model + * + * @return Zip\Model\CheckoutConfiguration + */ protected function getCheckoutConfiguration() { $checkoutConfig = new CheckoutConfiguration(); @@ -210,7 +210,7 @@ protected function getCheckoutConfiguration() */ public function getRedirectUrl() { - return $this->getResponse() ? $this->getResponse()->getUri() : null; + return $this->getHelper()->getCheckoutRedirectUrlFromSession(); } /** @@ -244,6 +244,4 @@ public function getOrderReference() { return $this->getResponse() ? $this->getResponse()->getOrder()->getReference() : null; } - - } diff --git a/src/app/code/community/Zip/Payment/Model/Api/Configuration.php b/app/code/community/Zip/Payment/Model/Api/Configuration.php similarity index 88% rename from src/app/code/community/Zip/Payment/Model/Api/Configuration.php rename to app/code/community/Zip/Payment/Model/Api/Configuration.php index 6f37ae11..a46a0735 100644 --- a/src/app/code/community/Zip/Payment/Model/Api/Configuration.php +++ b/app/code/community/Zip/Payment/Model/Api/Configuration.php @@ -42,7 +42,11 @@ public function generateApiConfiguration($storeId = null) $extensionVersion = $this->getHelper()->getCurrentVersion(); $apiConfig - ->setApiKey('Authorization', Mage::helper('core')->decrypt($config->getValue(Zip_Payment_Model_Config::CONFIG_PRIVATE_KEY_PATH, $storeId))) + ->setApiKey( + 'Authorization', + Mage::helper('core') + ->decrypt($config->getValue(Zip_Payment_Model_Config::CONFIG_PRIVATE_KEY_PATH, $storeId)) + ) ->setEnvironment($config->getValue(Zip_Payment_Model_Config::CONFIG_ENVIRONMENT_PATH, $storeId)) ->setApiKeyPrefix('Authorization', 'Bearer') ->setPlatform("Magento/{$magentoVersion} Zip_Payment/{$extensionVersion}") diff --git a/src/app/code/community/Zip/Payment/Model/Api/Refund.php b/app/code/community/Zip/Payment/Model/Api/Refund.php similarity index 71% rename from src/app/code/community/Zip/Payment/Model/Api/Refund.php rename to app/code/community/Zip/Payment/Model/Api/Refund.php index 7f7f503c..92818a82 100644 --- a/src/app/code/community/Zip/Payment/Model/Api/Refund.php +++ b/app/code/community/Zip/Payment/Model/Api/Refund.php @@ -13,9 +13,6 @@ class Zip_Payment_Model_Api_Refund extends Zip_Payment_Model_Api_Abstract { - protected $amount = 0.0; - protected $chargeId = null; - protected $reason = null; /** * get API model @@ -24,11 +21,11 @@ class Zip_Payment_Model_Api_Refund extends Zip_Payment_Model_Api_Abstract */ protected function getApi() { - if ($this->api === null) { - $this->api = new RefundApi(); + if ($this->_api === null) { + $this->_api = new RefundApi(); } - return $this->api; + return $this->_api; } /** @@ -40,19 +37,15 @@ protected function getApi() */ public function create($chargeId, $amount, $reason) { - $this->chargeId = $chargeId; - $this->amount = $amount; - $this->reason = $reason; - - $payload = $this->prepareCreatePayload(); + $payload = $this->prepareCreatePayload($chargeId, $amount, $reason); try { $this->getLogger()->debug( "Create refund" . json_encode( array( - 'charge_id' => $chargeId, - 'amount' => $amount, - 'reason' => $reason + 'charge_id' => $chargeId, + 'amount' => $amount, + 'reason' => $reason ) ) ); @@ -67,7 +60,7 @@ public function create($chargeId, $amount, $reason) Mage::throwException($this->getHelper()->__('Invalid Refund')); } - $this->response = $refund; + $this->_response = $refund; }catch (ApiException $e) { $this->logException($e); throw $e; @@ -79,14 +72,14 @@ public function create($chargeId, $amount, $reason) /** * generate payload for refund */ - protected function prepareCreatePayload() + protected function prepareCreatePayload($chargeId, $amount, $reason) { $refundReq = new CreateRefundRequest(); $refundReq - ->setAmount($this->amount) - ->setReason($this->reason) - ->setChargeId($this->chargeId) + ->setAmount($amount) + ->setReason($reason) + ->setChargeId($chargeId) ->setMetadata($this->getMetadata()); return $refundReq; diff --git a/src/app/code/community/Zip/Payment/Model/Checkout.php b/app/code/community/Zip/Payment/Model/Checkout.php similarity index 86% rename from src/app/code/community/Zip/Payment/Model/Checkout.php rename to app/code/community/Zip/Payment/Model/Checkout.php index ac2efce5..fbf0dc1f 100644 --- a/src/app/code/community/Zip/Payment/Model/Checkout.php +++ b/app/code/community/Zip/Payment/Model/Checkout.php @@ -15,17 +15,12 @@ class Zip_Payment_Model_Checkout /** * @var Zip_Payment_Model_Logger */ - protected $logger = null; + protected $_logger = null; /** * @var Mage_Sales_Model_Quote */ - protected $quote; - - /** - * @var Zip_Payment_Model_config - */ - protected $config = null; + protected $_quote; /** * Get logger object @@ -34,11 +29,11 @@ class Zip_Payment_Model_Checkout */ public function getLogger() { - if ($this->logger == null) { - $this->logger = Mage::getSingleton('zip_payment/logger'); + if ($this->_logger == null) { + $this->_logger = Mage::getSingleton('zip_payment/logger'); } - return $this->logger; + return $this->_logger; } /** @@ -58,25 +53,11 @@ protected function getHelper() */ protected function getQuote() { - if (empty($this->quote)) { - $this->quote = $this->getHelper()->getCheckoutSession()->getQuote(); + if (empty($this->_quote)) { + $this->_quote = $this->getHelper()->getCheckoutSession()->getQuote(); } - return $this->quote; - } - - /** - * Get config - * - * @return Zip_Payment_Model_config - */ - protected function getConfig() - { - if ($this->config == null) { - $this->config = $this->getHelper()->getConfig(); - } - - return $this->config; + return $this->_quote; } /** @@ -87,16 +68,19 @@ protected function getConfig() */ public function handleResponse($checkoutId, $state) { + $hasCart = $this->getQuote()->getId() && $this->getQuote()->getIsActive(); $response = array( 'success' => false, 'message' => null, - 'redirect_url' => ($this->getQuote()->getId() && $this->getQuote()->getIsActive()) ? Zip_Payment_Model_Config::CHECKOUT_CART_URL_ROUTE : Zip_Payment_Model_Config::CHECKOUT_FAILURE_URL_ROUTE + 'redirect_url' => $hasCart ? Zip_Payment_Model_Config:: + CHECKOUT_CART_URL_ROUTE : Zip_Payment_Model_Config:: + CHECKOUT_FAILURE_URL_ROUTE ); try { $checkoutIdFromSession = $this->getHelper()->getCheckoutIdFromSession(); - $isReferred = !empty($checkoutId) && (empty($checkoutIdFromSession) || $checkoutIdFromSession != $checkoutId); - empty($checkoutIdFromSession) ? : $checkoutId = $checkoutIdFromSession; + $isReferred = !empty($checkoutId) && + (empty($checkoutIdFromSession) || $checkoutIdFromSession != $checkoutId); if (empty($checkoutId)) { Mage::throwException('The checkout Id does not exist'); @@ -135,8 +119,10 @@ public function handleResponse($checkoutId, $state) case Zip_Payment_Model_Api_Checkout::STATE_REFERRED: $this->getLogger()->debug('Handle referred checkout'); + $needCreateOrder = $this->getHelper()->getConfig() + ->getFlag(Zip_Payment_Model_Config::CONFIG_CHECKOUT_REFERRED_ORDER_CREATION_PATH); - if ($this->getConfig()->getFlag(Zip_Payment_Model_Config::CONFIG_CHECKOUT_REFERRED_ORDER_CREATION_PATH)) { + if ($needCreateOrder) { $this->placeOrder(); } @@ -256,12 +242,16 @@ protected function placeOrderWithExistingOrder($order) // if the order state is not pending if (!$this->getHelper()->isReferredOrder($order)) { - Mage::throwException($this->getHelper()->__('Current order is not a valid referred order. payment can\'t be processed.')); + Mage::throwException( + $this->getHelper()->__('Current order is not a valid referred order. payment can\'t be processed.') + ); } // if the order can be invoiced if (!$order->canInvoice()) { - Mage::throwException($this->getHelper()->__('Cannot create an invoice for this order.')); + Mage::throwException( + $this->getHelper()->__('Cannot create an invoice for this order.') + ); } try { @@ -278,7 +268,7 @@ protected function placeOrderWithExistingOrder($order) ); $invoice - ->addComment('Invoice generated by Zip Payment - Referred Application automatically') + ->addComment('Invoice generated by Zip Payment - Referred Application') ->register() ->sendEmail(true); diff --git a/src/app/code/community/Zip/Payment/Model/Config.php b/app/code/community/Zip/Payment/Model/Config.php similarity index 83% rename from src/app/code/community/Zip/Payment/Model/Config.php rename to app/code/community/Zip/Payment/Model/Config.php index 20432462..477d25f4 100644 --- a/src/app/code/community/Zip/Payment/Model/Config.php +++ b/app/code/community/Zip/Payment/Model/Config.php @@ -67,15 +67,26 @@ class Zip_Payment_Model_Config const CHECKOUT_SESSION_KEY = 'zip_payment_checkout'; const ONEPAGE_CHECKOUT_IDENTIFIER = 'checkout_onepage_index'; + const CONFIG_CHECKOUT_TYPE_PATH = 'payment/zip_payment/checkout/type'; const CONFIG_CHECKOUT_GENERAL_ERROR_PATH = 'payment/zip_payment/checkout/error/general'; const CONFIG_CHECKOUT_JS_LIB_PATH = 'payment/zip_payment/checkout/js_lib'; - const CONFIG_CEHCKOUT_DISPLAY_MODE_PATH = 'payment/zip_payment/checkout/display_mode'; + + const CONFIG_CHECKOUT_DISPLAY_MODE_PATH = 'payment/zip_payment/checkout/display_mode'; const CONFIG_CHECKOUT_CUSTOM_SCRIPT_PATH = 'payment/zip_payment/checkout/custom_script'; - const CONFIG_CHECKOUT_ONESTEPCHECKOUTS_PATH = 'payment/zip_payment/checkout/onestepcheckouts'; + const CONFIG_CHECKOUT_PATH_PATH = 'payment/zip_payment/checkout/path'; + + /** + * Referred + */ const CONFIG_CHECKOUT_REFERRED_ORDER_CREATION_PATH = 'payment/zip_payment/checkout/referred/order_creation'; const CONFIG_CHECKOUT_REFERRED_ORDER_STATUS_PATH = 'payment/zip_payment/checkout/referred/order_status'; + /** + * Click & Collect + */ + const CONFIG_CHECKOUT_CLICK_COLLECT_PATH = 'payment/zip_payment/checkout/click_collect'; + /** * Response */ @@ -92,25 +103,25 @@ class Zip_Payment_Model_Config */ const CONFIG_NOTIFICATION_ENABLED_PATH = 'payment/zip_payment/admin_notification/enabled'; - protected $methodCode = self::METHOD_CODE; - protected $debugEnabled = null; - protected $logEnabled = null; - protected $logLevel = null; - protected $logFile = null; - protected $apiConfig = null; - - /** - * Method code setter - * - * @param string|Mage_Payment_Model_Method_Abstract $method - * @return Mage_Paypal_Model_Config - */ + protected $_methodCode = self::METHOD_CODE; + protected $_debugEnabled = null; + protected $_logEnabled = null; + protected $_logLevel = null; + protected $_logFile = null; + protected $_apiConfig = null; + + /** + * Method code setter + * + * @param string|Mage_Payment_Model_Method_Abstract $method + * @return Mage_Paypal_Model_Config + */ public function setMethod($method) { if ($method instanceof Mage_Payment_Model_Method_Abstract) { - $this->methodCode = $method->getCode(); + $this->_methodCode = $method->getCode(); } elseif (is_string($method)) { - $this->methodCode = $method; + $this->_methodCode = $method; } return $this; @@ -124,7 +135,7 @@ public function setMethod($method) */ public function getMethodCode() { - return $this->methodCode; + return $this->_methodCode; } /********************************** @@ -148,11 +159,11 @@ public function getTitle() public function isDebugEnabled() { - if ($this->debugEnabled === null) { - $this->debugEnabled = $this->getFlag(self::CONFIG_DEBUG_ENABLED_PATH); + if ($this->_debugEnabled === null) { + $this->_debugEnabled = $this->getFlag(self::CONFIG_DEBUG_ENABLED_PATH); } - return $this->debugEnabled; + return $this->_debugEnabled; } /** @@ -162,11 +173,11 @@ public function isDebugEnabled() */ public function getLogLevel() { - if ($this->logLevel === null) { - $this->logLevel = (int) $this->getValue(self::CONFIG_DEBUG_LOG_LEVEL_PATH); + if ($this->_logLevel === null) { + $this->_logLevel = (int) $this->getValue(self::CONFIG_DEBUG_LOG_LEVEL_PATH); } - return $this->logLevel; + return $this->_logLevel; } /** @@ -174,18 +185,18 @@ public function getLogLevel() */ public function isLogEnabled() { - if ($this->logEnabled === null) { - $this->logEnabled = false; + if ($this->_logEnabled === null) { + $this->_logEnabled = false; if ($this->isDebugEnabled()) { $isDeveloperLogActive = $this->getFlag(self::CONFIG_DEVELOPER_LOG_ACTIVE_PATH); $logLevel = $this->getLogLevel(); - $this->logEnabled = ($isDeveloperLogActive && $logLevel >= 0); + $this->_logEnabled = ($isDeveloperLogActive && $logLevel >= 0); } } - return $this->logEnabled; + return $this->_logEnabled; } /** @@ -195,17 +206,17 @@ public function isLogEnabled() */ public function getLogFile() { - if ($this->logFile === null) { + if ($this->_logFile === null) { $logFile = $this->getValue(self::CONFIG_DEBUG_LOG_FILE_PATH); if (empty($logFile)) { $logFile = self::DEFAULT_LOG_FILE_NAME; } - $this->logFile = $logFile; + $this->_logFile = $logFile; } - return $this->logFile; + return $this->_logFile; } /********************************** @@ -290,7 +301,6 @@ public function getFlag($path, $storeId = null) { $value = $this->getValue($path, $storeId); return !empty($value) && 'false' !== $value; - } /********************************** @@ -311,5 +321,4 @@ public function isMethodAvailable($methodCode = null) return $this->getFlag("payment/{$methodCode}/active") && $this->isMerchantCountrySupported(); } - } diff --git a/src/app/code/community/Zip/Payment/Model/LegacyMethod.php b/app/code/community/Zip/Payment/Model/LegacyMethod.php similarity index 100% rename from src/app/code/community/Zip/Payment/Model/LegacyMethod.php rename to app/code/community/Zip/Payment/Model/LegacyMethod.php diff --git a/src/app/code/community/Zip/Payment/Model/Logger.php b/app/code/community/Zip/Payment/Model/Logger.php similarity index 82% rename from src/app/code/community/Zip/Payment/Model/Logger.php rename to app/code/community/Zip/Payment/Model/Logger.php index 780727fd..dc327c9f 100644 --- a/src/app/code/community/Zip/Payment/Model/Logger.php +++ b/app/code/community/Zip/Payment/Model/Logger.php @@ -12,8 +12,8 @@ class Zip_Payment_Model_Logger { const CONFIG_DEBUG_PRIVATE_DATA_KEYS_PATH = 'payment/zip_payment/debug/log_private_data_keys'; - protected $config = null; - protected $privateDataKeys = null; + protected $_config = null; + protected $_privateDataKeys = null; /** * get configuration model @@ -22,11 +22,11 @@ class Zip_Payment_Model_Logger */ protected function getConfig() { - if ($this->config === null) { - $this->config = Mage::getSingleton('zip_payment/config'); + if ($this->_config === null) { + $this->_config = Mage::getSingleton('zip_payment/config'); } - return $this->config; + return $this->_config; } /** @@ -36,11 +36,14 @@ protected function getConfig() */ public function getPrivateDataKeys() { - if ($this->privateDataKeys === null) { - $this->privateDataKeys = explode(',', (string) $this->getConfig()->getValue(self::CONFIG_DEBUG_PRIVATE_DATA_KEYS_PATH)); + if ($this->_privateDataKeys === null) { + $this->_privateDataKeys = explode( + ',', + (string) $this->getConfig()->getValue(self::CONFIG_DEBUG_PRIVATE_DATA_KEYS_PATH) + ); } - return $this->privateDataKeys; + return $this->_privateDataKeys; } /** @@ -74,7 +77,10 @@ protected function sanitizeDebugData($debugData) { if (is_array($debugData) && is_array($this->getPrivateDataKeys())) { foreach ($debugData as $key => $value) { - if (in_array($key, $this->getPrivateDataKeys())) { + if (in_array( + $key, (array) $this->getPrivateDataKeys() + ) + ) { $debugData[$key] = '****'; } else { if (is_array($debugData[$key])) { diff --git a/src/app/code/community/Zip/Payment/Model/Method.php b/app/code/community/Zip/Payment/Model/Method.php similarity index 81% rename from src/app/code/community/Zip/Payment/Model/Method.php rename to app/code/community/Zip/Payment/Model/Method.php index eec87bbc..4ae14922 100644 --- a/src/app/code/community/Zip/Payment/Model/Method.php +++ b/app/code/community/Zip/Payment/Model/Method.php @@ -22,10 +22,10 @@ class Zip_Payment_Model_Method extends Mage_Payment_Model_Method_Abstract * * @var Zip_Payment_Model_Config */ - protected $config = null; - protected $logger = null; - protected $quote = null; - protected $paymentAction = null; + protected $_config = null; + protected $_logger = null; + protected $_quote = null; + protected $_paymentAction = null; /** * Payment Method features @@ -65,12 +65,12 @@ class Zip_Payment_Model_Method extends Mage_Payment_Model_Method_Abstract */ public function getConfig() { - if ($this->config == null) { - $this->config = $this->_getHelper()->getConfig(); - $this->config->setMethod($this->getCode()); + if ($this->_config == null) { + $this->_config = $this->_getHelper()->getConfig(); + $this->_config->setMethod($this->getCode()); } - return $this->config; + return $this->_config; } /** @@ -80,11 +80,11 @@ public function getConfig() */ public function getLogger() { - if ($this->logger == null) { - $this->logger = Mage::getSingleton('zip_payment/logger'); + if ($this->_logger == null) { + $this->_logger = Mage::getSingleton('zip_payment/logger'); } - return $this->logger; + return $this->_logger; } @@ -105,18 +105,18 @@ protected function _getHelper() */ protected function getQuote() { - if ($this->quote === null) { - $this->quote = $this->_getHelper()->getCheckoutSession()->getQuote(); + if ($this->_quote === null) { + $this->_quote = $this->_getHelper()->getCheckoutSession()->getQuote(); } - return $this->quote; + return $this->_quote; } - /** - * Log debug data to file - * - * @param mixed $debugData - */ + /** + * Log debug data to file + * + * @param mixed $debugData + */ protected function _debug($debugData) { if ($this->getDebugFlag()) { @@ -145,12 +145,12 @@ public function isAvailable($quote = null) return parent::isAvailable($quote) && $this->getConfig()->isMethodAvailable(); } - /** - * Check method for processing with base currency - * - * @param string $currencyCode - * @return boolean - */ + /** + * Check method for processing with base currency + * + * @param string $currencyCode + * @return boolean + */ public function canUseForCurrency($currencyCode) { return $this->getConfig()->isCurrencySupported($currencyCode); @@ -172,7 +172,7 @@ public function getConfigData($field, $storeId = null) $configValue = $this->getConfig()->getValue("payment/{$this->getCode()}/checkout/referred/{$field}"); } - if (is_null($configValue)) { + if ($configValue === null) { $configValue = $this->getConfig()->getValue("payment/{$this->getCode()}/{$field}"); } @@ -187,9 +187,10 @@ public function getConfigData($field, $storeId = null) */ public function getConfigPaymentAction() { - $this->paymentAction || $this->paymentAction = $this->_getHelper()->isReferredCheckout() ? self::ACTION_ORDER : parent::getConfigPaymentAction(); + $this->_paymentAction || $this->_paymentAction = $this->_getHelper()->isReferredCheckout() ? + self::ACTION_ORDER : parent::getConfigPaymentAction(); - return $this->paymentAction; + return $this->_paymentAction; } /** @@ -208,12 +209,11 @@ public function getCheckoutRedirectUrl() } // return redirect url for one step checkout - if ($redirectUrl && !$this->_getHelper()->isOnepageCheckout()) { + if ($redirectUrl && ($this->_getHelper()->isUsingOneStepCheckout() || $this->_getHelper()->isRedirectCheckoutDisplayModel())) { return $redirectUrl; } return parent::getCheckoutRedirectUrl(); - } @@ -245,11 +245,11 @@ protected function createCheckout() // Create Checkout $checkout = Mage::getModel('zip_payment/api_checkout') - ->create(); + ->create(); $this->_getHelper()->saveCheckoutSessionData( array( - Zip_Payment_Model_Api_Checkout::CHECKOUT_ID_KEY => $checkout->getId(), + Zip_Payment_Model_Api_Checkout::CHECKOUT_ID_KEY => $checkout->getId(), ) ); @@ -314,7 +314,8 @@ public function authorize(Varien_Object $payment, $amount) ->setIsTransactionClosed(0) ->setAdditionalInformation( array( - Zip_Payment_Model_Config::PAYMENT_RECEIPT_NUMBER_KEY => $charge->getReceiptNumber() + Zip_Payment_Model_Config::PAYMENT_RECEIPT_NUMBER_KEY => $charge->getReceiptNumber(), + "product" => $charge->getProduct() ) ); } @@ -322,11 +323,11 @@ public function authorize(Varien_Object $payment, $amount) return $this; } - /** - * capture payment - * - * @return Zip_Payment_Model_Method - */ + /** + * capture payment + * + * @return Zip_Payment_Model_Method + */ public function capture(Varien_Object $payment, $amount) { $this->getLogger()->debug($this->_getHelper()->__("Zip_Payment_Model_Method - Capture")); @@ -363,9 +364,13 @@ public function capture(Varien_Object $payment, $amount) $checkoutState = $this->_getHelper()->getCheckoutStateFromSession(); if (!$checkoutState) { - Mage::throwException($this->_getHelper()->__('Invalid Checkout state, payment will not be processing.')); + Mage::throwException( + $this->_getHelper()->__('Invalid Checkout state, payment will not be processing.') + ); } else if ($checkoutState !== Zip_Payment_Model_Api_Checkout::STATE_APPROVED) { - Mage::throwException($this->_getHelper()->__('Checkout is %s, payment will not be processing.', $checkoutState)); + Mage::throwException( + $this->_getHelper()->__('Checkout is %s, payment will not be processing.', $checkoutState) + ); } $checkoutId = $this->_getHelper()->getCheckoutIdFromSession(); @@ -392,7 +397,8 @@ public function capture(Varien_Object $payment, $amount) ->setIsTransactionClosed(0) ->setAdditionalInformation( array( - Zip_Payment_Model_Config::PAYMENT_RECEIPT_NUMBER_KEY => $receiptNumber + Zip_Payment_Model_Config::PAYMENT_RECEIPT_NUMBER_KEY => $receiptNumber, + "product" => $charge->getProduct() ) ); @@ -402,14 +408,13 @@ public function capture(Varien_Object $payment, $amount) } return $this; - } - /** - * Process refund - * - * @return Zip_Payment_Model_Method - */ + /** + * Process refund + * + * @return Zip_Payment_Model_Method + */ public function refund(Varien_Object $payment, $amount) { $this->getLogger()->debug($this->_getHelper()->__("Zip_Payment_Model_Method - Refund")); @@ -418,7 +423,7 @@ public function refund(Varien_Object $payment, $amount) Mage::throwException($this->_getHelper()->__('Refund action is not available.')); } - $creditmemo = Mage::app()->getRequest()->getParam('creditmemo'); + $param = Mage::app()->getRequest()->getParam('creditmemo'); $reason = isset($param['comment_text']) && !empty($param['comment_text']) ? $param['comment_text'] : 'N/A'; $transactionID = $payment->getParentTransactionID(); @@ -432,21 +437,24 @@ public function refund(Varien_Object $payment, $amount) Mage::throwException($this->_getHelper()->__('Please provide refund amount')); } - $orderId = $payment->getOrder()->getIncrementId(); - $storeId = $payment->getOrder()->getStoreId(); + $order = $payment->getOrder(); + $orderId = $order->getIncrementId(); + $storeId = $order->getStoreId(); $chargeId = preg_replace('/_rn_[0-9]+?$/i', '', $transactionID); // Create refund $this->getLogger()->debug('Refund store id: ' . $storeId); $refund = Mage::getModel('zip_payment/api_refund', array('store_id' => $storeId)) - ->create($chargeId, $amount, $reason); + ->create($chargeId, $amount, $reason); - $this->getLogger()->info($this->_getHelper()->__("Refund for Order [ %s ] for amount %s was successful", $orderId, $amount)); + $this->getLogger()->info( + $this->_getHelper()->__("Refund for Order [ %s ] for amount %s was successful", $orderId, $amount) + ); $payment ->setTransactionId($refund->getId()) ->setIsTransactionClosed(true) - ->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_VOID); + ->setStatus(self::STATUS_VOID); } catch (Exception $e) { $this->_getHelper()->unsetCheckoutSessionData(); Mage::throwException($this->_getHelper()->__('Could not refund the payment - ' . $e->getMessage())); @@ -462,7 +470,10 @@ public function refund(Varien_Object $payment, $amount) */ public function cancel(Varien_Object $payment) { - if (!$payment->getOrder()->getInvoiceCollection()->count()) { + $order = $payment->getOrder(); + + // when order is a referred order and order invoices have not been generated + if (!$this->_getHelper()->isReferredOrder($order) && !$order->getInvoiceCollection()->count()) { $this->void($payment); } @@ -481,7 +492,7 @@ public function void(Varien_Object $payment) } $orderId = $payment->getOrder()->getIncrementId(); - $chargeId = $payment->getParentTransactionID(); + $chargeId = preg_replace('/^' . self::AUTHORIZE_TRANSACTION_ID_PREFIX . '/i', '', $payment->getParentTransactionID()); $storeId = $payment->getOrder()->getStoreId(); $this->getLogger()->debug('Cancel Charge For Order: ' . $orderId); @@ -489,7 +500,7 @@ public function void(Varien_Object $payment) try { // Cancel Charge $charge = Mage::getModel('zip_payment/api_charge', array('store_id' => $storeId)) - ->cancel($chargeId); + ->cancel($chargeId); if (isset($charge->error)) { Mage::throwException($this->_getHelper()->__('Could not cancel the charge')); @@ -504,5 +515,4 @@ public function void(Varien_Object $payment) return $this; } - } diff --git a/src/app/code/community/Zip/Payment/Model/Observer.php b/app/code/community/Zip/Payment/Model/Observer.php similarity index 94% rename from src/app/code/community/Zip/Payment/Model/Observer.php rename to app/code/community/Zip/Payment/Model/Observer.php index a2c4dad8..983b2fca 100644 --- a/src/app/code/community/Zip/Payment/Model/Observer.php +++ b/app/code/community/Zip/Payment/Model/Observer.php @@ -70,7 +70,7 @@ public function setCheckoutLayoutHandle($observer) { $layoutHandle = 'checkout_layout_handle'; - if (Mage::helper('zip_payment')->isOnepageCheckout() || Mage::helper('zip_payment')->isOnestepCheckout()) { + if (Mage::helper('zip_payment')->isUsingOnePageCheckout() || Mage::helper('zip_payment')->isUsingOneStepCheckout()) { Mage::app()->getLayout()->getUpdate()->addHandle($layoutHandle); } } diff --git a/src/app/code/community/Zip/Payment/controllers/CheckoutController.php b/app/code/community/Zip/Payment/controllers/CheckoutController.php similarity index 85% rename from src/app/code/community/Zip/Payment/controllers/CheckoutController.php rename to app/code/community/Zip/Payment/controllers/CheckoutController.php index 6861e1f5..3d46e257 100644 --- a/src/app/code/community/Zip/Payment/controllers/CheckoutController.php +++ b/app/code/community/Zip/Payment/controllers/CheckoutController.php @@ -28,7 +28,10 @@ public function responseAction() $state = $this->getRequest()->getParam(Zip_Payment_Model_Config::URL_PARAM_RESULT); // get checkout id from checkout url parameter // filter the result to remove additional GTM string - $checkoutId = preg_replace('/\?.+$/', '', $this->getRequest()->getParam(Zip_Payment_Model_Config::URL_PARAM_CHECKOUT_ID) ?: ''); + $checkoutId = preg_replace( + '/\?.+$/', '', + $this->getRequest()->getParam(Zip_Payment_Model_Config::URL_PARAM_CHECKOUT_ID) ?: '' + ); try { $response = Mage::getSingleton('zip_payment/checkout')->handleResponse($checkoutId, $state); @@ -88,7 +91,10 @@ public function failureAction() $this->getLogger()->debug('Successfully redirect to the failure page.'); } catch (Exception $e) { $this->getLogger()->error(json_encode($this->getRequest()->getParams())); - Mage::getSingleton('checkout/session')->addError($this->getHelper()->__('An error occurred during redirecting to failure page.')); + Mage::getSingleton('checkout/session') + ->addError( + $this->getHelper()->__('An error occurred during redirecting to failure page.') + ); } } @@ -111,7 +117,10 @@ public function referredAction() $this->getLogger()->debug('Successfully redirect to the referred page.'); } catch (Exception $e) { $this->getLogger()->error(json_encode($this->getRequest()->getParams())); - Mage::getSingleton('checkout/session')->addError($this->getHelper()->__('An error occurred during redirecting to referred page.')); + Mage::getSingleton('checkout/session') + ->addError( + $this->getHelper()->__('An error occurred during redirecting to referred page.') + ); } } diff --git a/src/app/code/community/Zip/Payment/data/zip_payment_setup/data-install-2.0.0.php b/app/code/community/Zip/Payment/data/zip_payment_setup/data-install-2.0.0.php similarity index 97% rename from src/app/code/community/Zip/Payment/data/zip_payment_setup/data-install-2.0.0.php rename to app/code/community/Zip/Payment/data/zip_payment_setup/data-install-2.0.0.php index 248a3202..2a0ddf53 100644 --- a/src/app/code/community/Zip/Payment/data/zip_payment_setup/data-install-2.0.0.php +++ b/app/code/community/Zip/Payment/data/zip_payment_setup/data-install-2.0.0.php @@ -1,8 +1,6 @@ load($block, 'block_name') + ->setData('block_name', $block) + ->setData('is_allowed', 1) + ->save(); + } +} + +// Delete old log file +Mage::helper('zip_payment')->removeLogFile('zipMoney-payment.log'); diff --git a/src/app/code/community/Zip/Payment/etc/adminhtml.xml b/app/code/community/Zip/Payment/etc/adminhtml.xml similarity index 100% rename from src/app/code/community/Zip/Payment/etc/adminhtml.xml rename to app/code/community/Zip/Payment/etc/adminhtml.xml diff --git a/src/app/code/community/Zip/Payment/etc/config.xml b/app/code/community/Zip/Payment/etc/config.xml similarity index 85% rename from src/app/code/community/Zip/Payment/etc/config.xml rename to app/code/community/Zip/Payment/etc/config.xml index be345c76..a1386aa0 100644 --- a/src/app/code/community/Zip/Payment/etc/config.xml +++ b/app/code/community/Zip/Payment/etc/config.xml @@ -3,7 +3,7 @@ - 2.0.0 + 2.1.0 @@ -51,13 +51,13 @@ - - - zip_payment/observer - setCheckoutLayoutHandle - - - + + + zip_payment/observer + setCheckoutLayoutHandle + + + @@ -127,6 +127,8 @@ processing 1 + one_page + /checkout/onepage redirect 1 @@ -144,7 +146,7 @@ zip_payment.log - 0 + 1 0 @@ -202,14 +204,13 @@ - http://d3k1w8lx8mqizo.cloudfront.net/INTEGRATIONS/2016/zippay/logos/zipPay-logo-onWhite.png + https://zip.co/assets/zip/logos/zip/primary.svg https://merchant.sandbox.zipmoney.com.au/ https://merchant.zipmoney.com.au/ - //static.zipmoney.com.au/checkout/checkout-v1.min.js - https://s3-ap-southeast-2.amazonaws.com/zip-labs-assets/defaults/ajax-loader.gif + https://static.zipmoney.com.au/checkout/checkout-v1.min.js Something went wrong. Please try to checkout out again @@ -219,20 +220,12 @@ Order Placed Successfully - Congratulations! You have successfully placed your order, pending approval of your Zip Money application.

You will recevie an email with instructions shortly on whether your application has been approved or not. If approved you will be able to complete your purchase following the link in the email.

]]>
+ Congratulations! You have successfully placed your order, pending approval of your Zip Money application.

You will receive an email with instructions shortly on whether your application has been approved or not. If approved you will be able to complete your purchase following the link in the email.

]]>
- - 1 - 1 - 1 - 1 - 1 - 1 -
- AU - AUD + AU,NZ + AUD,NZD 0 @@ -242,7 +235,7 @@ ACCT,EXPDATE,CVV2,CARDISSUE,CARDSTART,CREDITCARDTYPE,USER,PWD,SIGNATURE - https://static.zipmoney.com.au/lib/js/notification/magento1.json + https://zip-labs-assets.s3-ap-southeast-2.amazonaws.com/plugin/magento1/notification.json 1 diff --git a/src/app/code/community/Zip/Payment/etc/system.xml b/app/code/community/Zip/Payment/etc/system.xml similarity index 90% rename from src/app/code/community/Zip/Payment/etc/system.xml rename to app/code/community/Zip/Payment/etc/system.xml index 5d5f5dba..2125fa42 100644 --- a/src/app/code/community/Zip/Payment/etc/system.xml +++ b/app/code/community/Zip/Payment/etc/system.xml @@ -91,7 +91,7 @@ 40 1 1 - 0 + 1
@@ -110,7 +110,7 @@ 50 1 1 - 0 + 1 @@ -120,7 +120,7 @@ 60 1 1 - 0 + 1 @@ -131,8 +131,8 @@ 1 100 - - + + text 1 1 @@ -148,7 +148,7 @@ 10 1 1 - 0 + 1 @@ -159,7 +159,7 @@ 20 1 1 - 0 + 1 @@ -170,30 +170,18 @@ 30 1 1 - 0 + 1 - - - Select display mode for Zip Checkout, popup or redirect - This setting is used to identify how can we handle checkout authentication and confirmation from Zip - payment/zip_payment/checkout/display_mode - select - zip_payment/adminhtml_system_config_source_displayMode - 40 - 1 - 1 - 0 - The minimum order value amount required to checkout payment/zip_payment/min_order_total text validate-number - 70 + 40 1 1 - 0 + 1 @@ -201,21 +189,78 @@ payment/zip_payment/sort_order text validate-number - 80 + 50 1 1 1 + + + + + text + 1 + 1 + 1 + 20 + + + + Select checkout type. one page checkout or one step checkout + This setting is used to identify which type of checkout has been used + payment/zip_payment/checkout/type + select + zip_payment/adminhtml_system_config_source_checkoutType + 10 + 1 + 1 + 1 + + + + Please enter a path to identify checkout page, not includes last slash + Sample checkout path: /checkout/onepage, /onestepcheckout + payment/zip_payment/checkout/path + text + 20 + 1 + 1 + 1 + + + + Select display mode for Zip Checkout, popup or redirect + This setting is used to identify how can we handle checkout authentication and confirmation from Zip + payment/zip_payment/checkout/display_mode + select + zip_payment/adminhtml_system_config_source_displayMode + 30 + 1 + 1 + 1 + + + + Enter a code/word to help Zip recognise the 'Click and Collect' shipping method. + We'll use regex expression to match all shipping methods includes this method code. pickup means '*pickup*' that will matched "auspost_pickup" or "pickup_****" or "pickup****". Empty field means Zip Payment will not detect Click and Collect shipping method. + payment/zip_payment/checkout/click_collect + 40 + text + 1 + 1 + 1 + + - + text 1 1 1 - 20 + 40 @@ -227,7 +272,7 @@ 10 1 1 - 0 + 1 @@ -239,10 +284,10 @@ 20 1 1 - 0 + 1 - + @@ -306,7 +351,7 @@ 10 1 1 - 0 + 1 @@ -328,7 +373,7 @@ 1 1 1 - 50 + 40 @@ -366,7 +411,7 @@ 1 1 1 - 60 + 50 @@ -435,6 +480,9 @@ 1 1 1 + + 1 + @@ -479,6 +527,9 @@ 1 1 1 + + 1 + @@ -511,6 +562,9 @@ 1 1 1 + + 1 + @@ -543,6 +597,9 @@ 1 1 1 + + 1 + @@ -587,6 +644,9 @@ 1 1 1 + + 1 + @@ -631,6 +691,9 @@ 1 1 1 + + 1 + @@ -663,6 +726,9 @@ 1 1 1 + + 1 + @@ -695,6 +761,9 @@ 1 1 1 + + 1 + @@ -739,6 +808,9 @@ 1 1 1 + + 1 + @@ -774,4 +846,4 @@ - \ No newline at end of file + diff --git a/src/app/design/adminhtml/default/default/template/zip/payment/method/info/default.phtml b/app/design/adminhtml/default/default/template/zip/payment/method/info/default.phtml similarity index 52% rename from src/app/design/adminhtml/default/default/template/zip/payment/method/info/default.phtml rename to app/design/adminhtml/default/default/template/zip/payment/method/info/default.phtml index 16b003ec..d38ac8a5 100644 --- a/src/app/design/adminhtml/default/default/template/zip/payment/method/info/default.phtml +++ b/app/design/adminhtml/default/default/template/zip/payment/method/info/default.phtml @@ -5,26 +5,30 @@
- Zip Payment + Zip Payment - + escapeHtml($title); ?>
-getSpecificInformation()) :?> +getSpecificInformation()) : ?> - $value):?> + $value): ?> - - + +
escapeHtml($label)?>:getValueAsArray($value, true), "\n"))?> + escapeHtml($label); ?>: + + escapeHtml(nl2br(implode("\n", $this->getValueAsArray($value, true)))); ?> +
- + -getChildHtml() ?> +getChildHtml(); ?> + + diff --git a/app/design/frontend/base/default/template/zip/payment/checkout/overlay.phtml b/app/design/frontend/base/default/template/zip/payment/checkout/overlay.phtml new file mode 100644 index 00000000..0334f8c5 --- /dev/null +++ b/app/design/frontend/base/default/template/zip/payment/checkout/overlay.phtml @@ -0,0 +1,26 @@ +isActive(); +?> + + +
+
+
+ + + + +
+ +
+

Processing your Zip payment

+

Please do not refresh or close this page

+
+
+
+ + diff --git a/src/app/design/frontend/base/default/template/zip/payment/checkout/page.phtml b/app/design/frontend/base/default/template/zip/payment/checkout/page.phtml similarity index 54% rename from src/app/design/frontend/base/default/template/zip/payment/checkout/page.phtml rename to app/design/frontend/base/default/template/zip/payment/checkout/page.phtml index c4850792..17edc03b 100644 --- a/src/app/design/frontend/base/default/template/zip/payment/checkout/page.phtml +++ b/app/design/frontend/base/default/template/zip/payment/checkout/page.phtml @@ -8,30 +8,32 @@
- <?php echo $slogan ?> -

+ <?php echo $this->escapeHtml($slogan); ?> +

escapeHtml($slogan); ?>

-

+

escapeHtml($heading); ?>

-
+
  • - getText() ?> + escapeHtml($item->getText()); ?>

- getContentHtml() ?> -

+ getContentHtml(); ?> +

-
diff --git a/src/app/design/frontend/base/default/template/zip/payment/method/form/default.phtml b/app/design/frontend/base/default/template/zip/payment/method/form/default.phtml similarity index 58% rename from src/app/design/frontend/base/default/template/zip/payment/method/form/default.phtml rename to app/design/frontend/base/default/template/zip/payment/method/form/default.phtml index 89e67abb..13ffb75c 100644 --- a/src/app/design/frontend/base/default/template/zip/payment/method/form/default.phtml +++ b/app/design/frontend/base/default/template/zip/payment/method/form/default.phtml @@ -2,14 +2,14 @@ $methodCode = $this->getMethodCode(); ?> - diff --git a/src/app/design/frontend/base/default/template/zip/payment/method/form/label.phtml b/app/design/frontend/base/default/template/zip/payment/method/form/label.phtml similarity index 59% rename from src/app/design/frontend/base/default/template/zip/payment/method/form/label.phtml rename to app/design/frontend/base/default/template/zip/payment/method/form/label.phtml index 6b01930f..ec828dd7 100644 --- a/src/app/design/frontend/base/default/template/zip/payment/method/form/label.phtml +++ b/app/design/frontend/base/default/template/zip/payment/method/form/label.phtml @@ -5,27 +5,27 @@ ?> - Zip Payment + Zip Payment - + escapeHtml($title); ?> diff --git a/src/app/design/frontend/base/default/template/zip/payment/widgets.phtml b/src/app/design/frontend/base/default/template/zip/payment/widgets.phtml deleted file mode 100644 index d6322836..00000000 --- a/src/app/design/frontend/base/default/template/zip/payment/widgets.phtml +++ /dev/null @@ -1,25 +0,0 @@ -isActive()) { - return; -} -?> - - - -
- - -isDebugModeEnabled()) : ?> - - diff --git a/src/js/zip/payment/checkout.js b/src/js/zip/payment/checkout.js deleted file mode 100644 index 5ec9c725..00000000 --- a/src/js/zip/payment/checkout.js +++ /dev/null @@ -1,90 +0,0 @@ -/*********************************************************************************** - * Base functions for Zip.Checkout - * - * @author Zip Co - Plugin Team - * - ***********************************************************************************/ - -if('Zip' in window && Zip.Checkout) { - Object.extend( - Zip.Checkout, { - - showOverlay: function () { - document.getElementById('zip_payment_overlay').setAttribute('class', 'active'); - }, - hideOverlay: function () { - document.getElementById('zip_payment_overlay').removeAttribute('class'); - }, - redirectTo: function (url) { - location.href = url; - }, - - placeOrder: function (callback) { - if(payment.currentMethod == Zip.Checkout.settings.methodCode) { - Zip.Checkout.showOverlay(); - - // if current display mode is lightbox and redirect url is not same as response url - if(Zip.Checkout) { - Zip.Checkout.init( - { - request: 'standard', - redirect: Zip.Checkout.settings.isRedirect, - checkoutUri: Zip.Checkout.settings.checkoutUrl, - redirectUri: Zip.Checkout.settings.responseUrl, - logLevel: Zip.Checkout.settings.logLevel, - onComplete: function (data) { - var url = Zip.Checkout.settings.responseUrl + data.state; - - switch(data.state) { - case 'approved': - Zip.Checkout.redirectTo(url); - break; - case 'cancelled': - Zip.Checkout.hideOverlay(); - return; - default: - $j.ajax( - { - url: url, - type: 'GET', - success: function (resp) { - if(resp.error_message) { - Zip.Checkout.hideOverlay(); - alert(resp.error_message); - } - else if(resp.redirect_url) { - Zip.Checkout.redirectTo(resp.redirect_url); - } - - } - } - ); - break; - } - - }, - onError: function (data) { - if(data.state) { - alert('Something wrong while processing your checkout. Checkout has been ' + data.state); - } - else { - // redirect to cart if status is not available - Zip.Checkout.redirectTo('/checkout/cart'); - } - - }, - logLevel: Zip.Checkout.settings.logLevel - } - ); - } - - return; - } - - callback(); - - } - - } - ); -} \ No newline at end of file diff --git a/src/notification_sample.json b/src/notification_sample.json deleted file mode 100644 index e36d97d8..00000000 --- a/src/notification_sample.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "Zip Payment Plugin Notifications", - "release": { - "version": "2.0.1", - "title": "Zip Payment version 2.0.1 is available now! New Tools to Fuel Your Growth", - "description": "fix keyName checking for arrow keys in IE11", - "url": "https://zip.co/", - "date": "2018/11/25" - }, - "notifications": [ - { - "title": "Own the way you pay at your favourite stores", - "description": "Buy the things you love today and pay for them over time, interest free.", - "url": "https://zip.co/stores/", - "date": "2018/9/25" - }, - { - "title": "Big news. Gift cards now available at Zip", - "description": "Get that special someone a gift with Zip. Choose a digital gift card from our range in Zip.", - "url": "https://zip.co/giftcards/", - "date": "2018/10/25" - } - ] -} \ No newline at end of file diff --git a/src/package.xml b/src/package.xml deleted file mode 100644 index 6cdd9ea8..00000000 --- a/src/package.xml +++ /dev/null @@ -1,282 +0,0 @@ - - - Zip_Payment - 2.0.0 - stable - MIT - community - - Zip Payment extension for Magento 1 - The official Zip extension for Magento 1 allows you to offer Zip as a payment method on your Magento store, empowering your customers to own what they want today and pay later. - Refactor the whole plugin - - - Henry Fan - zipMoney - haolong.fan@zip.co - - - Ben Zhang - zipMoney - ben.zhang@zip.co - - - 2019-01-31 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5.3.0 - 7.3.0 - - - Core - 1.7.0 - - - - - diff --git a/test/Test.php b/test/Test.php deleted file mode 100644 index f1a04b12..00000000 --- a/test/Test.php +++ /dev/null @@ -1,16 +0,0 @@ -assertEquals( - 'user@example.com', - 'user@example.com' - ); - } -} -