├── docs
├── Payment Method Settings.png
├── Module version info in admin.png
├── Afterpay Magento Order Statuses.png
├── Afterpay Magento Order Statuses.vsdx
├── Afterpay Magento Order Processing.png
├── Afterpay Magento Order Processing.vsdx
└── Installments Amount configuration.png
├── src
├── skin
│ └── frontend
│ │ └── base
│ │ └── default
│ │ └── afterpay
│ │ ├── images
│ │ └── ap-logo-152x31.png
│ │ ├── js
│ │ └── afterpay_youtube.js
│ │ └── css
│ │ └── afterpay.css
├── app
│ ├── etc
│ │ └── modules
│ │ │ └── Afterpay_Afterpay.xml
│ ├── code
│ │ └── community
│ │ │ └── Afterpay
│ │ │ └── Afterpay
│ │ │ ├── Exception.php
│ │ │ ├── Block
│ │ │ ├── Config.php
│ │ │ ├── Require.php
│ │ │ ├── Adminhtml
│ │ │ │ └── System
│ │ │ │ │ └── Config
│ │ │ │ │ └── Form
│ │ │ │ │ └── Field
│ │ │ │ │ ├── ModuleVersion.php
│ │ │ │ │ └── Update
│ │ │ │ │ └── Limits.php
│ │ │ ├── Form
│ │ │ │ ├── Abstract.php
│ │ │ │ └── Payovertime.php
│ │ │ ├── Banner.php
│ │ │ ├── Redirect.php
│ │ │ ├── Info.php
│ │ │ ├── Onetouch.php
│ │ │ └── Catalog
│ │ │ │ └── Installments.php
│ │ │ ├── Model
│ │ │ ├── System
│ │ │ │ └── Config
│ │ │ │ │ └── Source
│ │ │ │ │ ├── RedirectMode.php
│ │ │ │ │ ├── CartMode.php
│ │ │ │ │ ├── Category.php
│ │ │ │ │ └── ApiMode.php
│ │ │ ├── Api
│ │ │ │ ├── Http
│ │ │ │ │ └── Client.php
│ │ │ │ ├── Routers
│ │ │ │ │ └── Routerv1.php
│ │ │ │ └── Adapters
│ │ │ │ │ └── Adapterv1.php
│ │ │ ├── Method
│ │ │ │ └── Payovertime.php
│ │ │ ├── Observer.php
│ │ │ └── Order.php
│ │ │ ├── sql
│ │ │ └── afterpay_setup
│ │ │ │ ├── upgrade-0.2.2-0.3.0.php
│ │ │ │ ├── upgrade-0.2.1-0.2.2.php
│ │ │ │ ├── install-0.2.0.php
│ │ │ │ ├── upgrade-0.12.9-0.13.0.php
│ │ │ │ ├── upgrade-0.3.2-0.4.0.php
│ │ │ │ ├── upgrade-0.7.3-0.8.0.php
│ │ │ │ ├── upgrade-0.5.0-0.6.0.php
│ │ │ │ ├── uninstall.php
│ │ │ │ ├── upgrade-0.8.0-0.9.0.php
│ │ │ │ ├── install-0.13.0.php
│ │ │ │ └── install-0.5.0.php
│ │ │ ├── controllers
│ │ │ ├── OnetouchController.php
│ │ │ └── Adminhtml
│ │ │ │ └── AfterpayController.php
│ │ │ ├── etc
│ │ │ ├── adminhtml.xml
│ │ │ └── config.xml
│ │ │ └── Helper
│ │ │ └── Checkout.php
│ └── design
│ │ ├── frontend
│ │ └── base
│ │ │ └── default
│ │ │ ├── template
│ │ │ └── afterpay
│ │ │ │ ├── failure.phtml
│ │ │ │ ├── checkout
│ │ │ │ ├── title_custom.phtml
│ │ │ │ ├── magestore_onestep.phtml
│ │ │ │ ├── require.phtml
│ │ │ │ ├── quickcheckout.phtml
│ │ │ │ ├── gomage.phtml
│ │ │ │ ├── iwd_opc.phtml
│ │ │ │ ├── firecheckout.phtml
│ │ │ │ ├── awesomecheckout.phtml
│ │ │ │ ├── aw_onestepcheckout.phtml
│ │ │ │ ├── config.phtml
│ │ │ │ ├── onestep.phtml
│ │ │ │ ├── default.phtml
│ │ │ │ └── onetouch.phtml
│ │ │ │ ├── catalog
│ │ │ │ └── installments.phtml
│ │ │ │ ├── form
│ │ │ │ └── payovertime_custom.phtml
│ │ │ │ ├── banner_requirements.phtml
│ │ │ │ └── redirect.phtml
│ │ │ └── layout
│ │ │ └── afterpay.xml
│ │ └── adminhtml
│ │ └── default
│ │ └── default
│ │ └── template
│ │ └── afterpay
│ │ └── limits.phtml
└── js
│ └── Afterpay
│ ├── checkout
│ ├── payovertime.js
│ ├── firecheckout.js
│ ├── onepage.js
│ ├── quickcheckout.js
│ ├── aw_onestepcheckout.js
│ ├── gomage.js
│ ├── mw_onestepcheckout.js
│ ├── amasty_onestepcheckout.js
│ ├── idev_onestep.js
│ ├── awesomecheckout.js
│ ├── iwd_opc.js
│ └── magestore_onestep.js
│ └── Installments.js
├── README.md
└── LICENSE.md
/docs/Payment Method Settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/afterpay/afterpay-magento/HEAD/docs/Payment Method Settings.png
--------------------------------------------------------------------------------
/docs/Module version info in admin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/afterpay/afterpay-magento/HEAD/docs/Module version info in admin.png
--------------------------------------------------------------------------------
/docs/Afterpay Magento Order Statuses.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/afterpay/afterpay-magento/HEAD/docs/Afterpay Magento Order Statuses.png
--------------------------------------------------------------------------------
/docs/Afterpay Magento Order Statuses.vsdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/afterpay/afterpay-magento/HEAD/docs/Afterpay Magento Order Statuses.vsdx
--------------------------------------------------------------------------------
/docs/Afterpay Magento Order Processing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/afterpay/afterpay-magento/HEAD/docs/Afterpay Magento Order Processing.png
--------------------------------------------------------------------------------
/docs/Afterpay Magento Order Processing.vsdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/afterpay/afterpay-magento/HEAD/docs/Afterpay Magento Order Processing.vsdx
--------------------------------------------------------------------------------
/docs/Installments Amount configuration.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/afterpay/afterpay-magento/HEAD/docs/Installments Amount configuration.png
--------------------------------------------------------------------------------
/src/skin/frontend/base/default/afterpay/images/ap-logo-152x31.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/afterpay/afterpay-magento/HEAD/src/skin/frontend/base/default/afterpay/images/ap-logo-152x31.png
--------------------------------------------------------------------------------
/src/app/etc/modules/Afterpay_Afterpay.xml:
--------------------------------------------------------------------------------
1 |
2 |
__('Continue to shop', $this->getContinueShoppingUrl()) ?>
7 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/Block/Config.php: -------------------------------------------------------------------------------- 1 | getTemplateHelper()->getTitleTemplateId() ?>"> 2 | 9 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/Block/Require.php: -------------------------------------------------------------------------------- 1 | $this->getSkinUrl('afterpay/css/afterpay.css'), 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/afterpay/checkout/magestore_onestep.phtml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/afterpay/checkout/require.phtml: -------------------------------------------------------------------------------- 1 | 9 | getRequireStyle() as $css) :?> 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/Model/System/Config/Source/RedirectMode.php: -------------------------------------------------------------------------------- 1 | 'Redirect', 17 | self::LIGHTBOX => 'Lightbox', 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/afterpay/checkout/quickcheckout.phtml: -------------------------------------------------------------------------------- 1 | setAfterpayErrorRedirect('checkout/cart'); ?> 2 | noConflict()) { ?> 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/afterpay/checkout/gomage.phtml: -------------------------------------------------------------------------------- 1 | noConflict()) { ?> 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/sql/afterpay_setup/upgrade-0.2.2-0.3.0.php: -------------------------------------------------------------------------------- 1 | startSetup(); 12 | 13 | 14 | $table = $installer->getTable('sales_flat_order_payment'); 15 | $installer->getConnection()->addColumn($table, "afterpay_fetched_at", "TIMESTAMP NULL"); 16 | 17 | 18 | $installer->endSetup(); 19 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/afterpay/checkout/iwd_opc.phtml: -------------------------------------------------------------------------------- 1 | noConflict()) { ?> 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/afterpay/checkout/firecheckout.phtml: -------------------------------------------------------------------------------- 1 | noConflict()) { ?> 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/afterpay/checkout/awesomecheckout.phtml: -------------------------------------------------------------------------------- 1 | noConflict()) { ?> 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/Block/Adminhtml/System/Config/Form/Field/ModuleVersion.php: -------------------------------------------------------------------------------- 1 | getModuleVersion(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/afterpay/checkout/aw_onestepcheckout.phtml: -------------------------------------------------------------------------------- 1 | noConflict()) { ?> 2 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/afterpay/checkout/config.phtml: -------------------------------------------------------------------------------- 1 | noConflict()) { ?> 2 | 3 | 10 | 11 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/Model/System/Config/Source/CartMode.php: -------------------------------------------------------------------------------- 1 | 'Yes - Magento Checkout', 18 | self::EXPRESS => 'Yes - Afterpay Express Checkout', 19 | self::NO => 'No', 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/sql/afterpay_setup/upgrade-0.2.1-0.2.2.php: -------------------------------------------------------------------------------- 1 | startSetup(); 12 | 13 | 14 | $table = $installer->getTable('sales_flat_order_payment'); 15 | $installer->getConnection()->addColumn($table, "afterpay_order_id", "varchar(255) DEFAULT NULL COMMENT 'Afterpay Order ID'"); 16 | $installer->getConnection()->dropIndex($table, "IDX_SALES_FLAT_ORDER_PAYMENT_AFTERPAY_TOKEN"); 17 | 18 | 19 | $installer->endSetup(); 20 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/sql/afterpay_setup/install-0.2.0.php: -------------------------------------------------------------------------------- 1 | startSetup(); 13 | 14 | 15 | $table = $installer->getTable('sales_flat_order_payment'); 16 | $installer->getConnection()->addColumn($table, "afterpay_token", "varchar(255) DEFAULT NULL COMMENT 'Afterpay Order Token'"); 17 | $installer->getConnection()->addIndex($table, "IDX_SALES_FLAT_ORDER_PAYMENT_AFTERPAY_TOKEN", "afterpay_token", Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE); 18 | 19 | 20 | $installer->endSetup(); 21 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/sql/afterpay_setup/upgrade-0.12.9-0.13.0.php: -------------------------------------------------------------------------------- 1 | startSetup(); 10 | 11 | /** 12 | * Setup script to create new column on sales_flat_quote_payment for: 13 | * - afterpay_token 14 | * - afterpay_order_id 15 | */ 16 | 17 | $table = $installer->getTable('sales/quote_payment'); 18 | $installer->getConnection()->addColumn($table, 'afterpay_token', "varchar(255) DEFAULT NULL COMMENT 'Afterpay Order Token'"); 19 | $installer->getConnection()->addColumn($table, 'afterpay_order_id', "varchar(255) DEFAULT NULL COMMENT 'Afterpay Order ID'"); 20 | 21 | $installer->endSetup(); 22 | ?> -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/sql/afterpay_setup/upgrade-0.3.2-0.4.0.php: -------------------------------------------------------------------------------- 1 | startSetup(); 12 | 13 | 14 | $status = 'afterpay_payment_review'; 15 | $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW; 16 | 17 | $installer->run("INSERT INTO `{$this->getTable('sales_order_status')}` (`status`, `label`) VALUES ('{$status}', 'Afterpay Processing');"); 18 | $installer->run("INSERT INTO `{$this->getTable('sales/order_status_state')}` (`status`, `state`, `is_default`) VALUES ('{$status}', '{$state}', '0');"); 19 | 20 | 21 | $installer->endSetup(); 22 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/sql/afterpay_setup/upgrade-0.7.3-0.8.0.php: -------------------------------------------------------------------------------- 1 | startSetup(); 13 | $installer->run(" 14 | CREATE TABLE `{$installer->getTable('afterpay/afterpay_shipped_api_queue')}` ( 15 | `shipped_api_queue_id` INT(11) NOT NULL auto_increment, 16 | `payment_id` INT(11) NOT NULL, 17 | `tracking_number` VARCHAR(255), 18 | `courier` VARCHAR(255), 19 | `errors_count` INT(11), 20 | PRIMARY KEY (`shipped_api_queue_id`) 21 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 22 | "); 23 | $installer->endSetup(); 24 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/controllers/OnetouchController.php: -------------------------------------------------------------------------------- 1 | getQuote(); 18 | 19 | $quote->getPayment()->setMethod('afterpaypayovertime') 20 | ->save(); 21 | 22 | $helper = Mage::helper('checkout/url'); 23 | $this->_redirectUrl($helper->getCheckoutUrl()); 24 | } 25 | } -------------------------------------------------------------------------------- /src/app/design/adminhtml/default/default/template/afterpay/limits.phtml: -------------------------------------------------------------------------------- 1 | getWebsite())) { 3 | $website_code = Mage::getSingleton('adminhtml/config_data')->getWebsite(); 4 | $website_id = Mage::getModel('core/website')->load($website_code)->getId(); 5 | 6 | $overrides = array('website_id' => $website_id); 7 | 8 | $target = array('website', $website_id); 9 | } 10 | else { 11 | $target_id = 0; 12 | $level = 'default'; 13 | 14 | $target = array(); 15 | } 16 | 17 | $target = implode($target, "/"); 18 | ?> 19 | 20 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/etc/adminhtml.xml: -------------------------------------------------------------------------------- 1 | 2 |Your order was not approved on this occasion due to an issue with your card.
18 |Please contact your card issuer to ensure your card details are valid and the card provides sufficient funds to cover the payment amounts.
', 19 | 'is_active' => 1, 20 | 'stores' => array(0) 21 | ); 22 | 23 | /** @var $block Mage_Cms_Model_Block */ 24 | $block = Mage::getModel('cms/block'); 25 | $block->load($blockData['identifier'], 'identifier'); 26 | if (!$block->isObjectNew()) { 27 | unset($blockData['identifier']); 28 | } 29 | $block->addData($blockData); 30 | $block->save(); 31 | 32 | $installer->endSetup(); 33 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/sql/afterpay_setup/uninstall.php: -------------------------------------------------------------------------------- 1 | startSetup(); 13 | $installer->run(" 14 | ALTER TABLE `{$installer->getTable('sales_flat_order_payment')}` 15 | DROP COLUMN afterpay_token, 16 | DROP COLUMN afterpay_order_id, 17 | DROP COLUMN afterpay_fetched_at; 18 | "); 19 | 20 | $installer->run(" 21 | DELETE FROM `{$installer->getTable('sales_order_status_state')}` WHERE status='afterpay_payment_review'; 22 | "); 23 | 24 | $installer->run(" 25 | DELETE FROM `{$installer->getTable('sales_order_status')}` WHERE status='afterpay_payment_review'; 26 | "); 27 | 28 | $installer->run(" 29 | DROP TABLE IF EXISTS `{$installer->getTable('afterpay_shipped_api_queue')}`; 30 | "); 31 | 32 | $installer->run(" 33 | DELETE FROM `{$installer->getTable('core_resource')}` WHERE code='afterpay_setup'; 34 | "); 35 | 36 | $installer->endSetup(); 37 | ?> -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/afterpay/checkout/default.phtml: -------------------------------------------------------------------------------- 1 | noConflict()) { ?> 2 | 3 | 7 | 8 | isModuleEnabled("MW_Onestepcheckout"); 10 | $amasty_onestepcheckout = Mage::helper('core')->isModuleEnabled("Amasty_Scheckout"); 11 | ?> 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/sql/afterpay_setup/upgrade-0.8.0-0.9.0.php: -------------------------------------------------------------------------------- 1 | startSetup(); 13 | 14 | $blockData = array( 15 | 'identifier' => 'afterpay_video_banner', 16 | 'title' => 'Afterpay Video Banner', 17 | 'content' => ' 20 | 21 | 27 | 28 | 40 | ', 41 | 'is_active' => 1, 42 | 'stores' => array(0) 43 | ); 44 | 45 | /** @var $block Mage_Cms_Model_Block */ 46 | $block = Mage::getModel('cms/block'); 47 | 48 | $block->load($blockData['identifier'], 'identifier'); 49 | 50 | if (!$block->isObjectNew()) { 51 | unset($blockData['identifier']); 52 | } 53 | $block->addData($blockData)->save(); 54 | 55 | $installer->endSetup(); 56 | -------------------------------------------------------------------------------- /src/app/design/frontend/base/default/template/afterpay/redirect.phtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 42 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/Model/System/Config/Source/Category.php: -------------------------------------------------------------------------------- 1 | getCollection() 10 | ->addAttributeToSelect('name') 11 | ->addAttributeToSort('path', 'asc') 12 | ->addFieldToFilter('is_active', array('eq'=>'1')) 13 | ->load() 14 | ->toArray(); 15 | 16 | foreach ($categories as $catId => $category) 17 | { 18 | if (isset($category['name'])) { 19 | $categoryList[] = array( 20 | 'label' => $category['name'], 21 | 'level' =>$category['level'], 22 | 'value' => $catId 23 | ); 24 | } 25 | } 26 | 27 | return $categoryList; 28 | } 29 | 30 | public function toOptionArray() 31 | { 32 | $options = array(); 33 | 34 | $categoriesTreeView = $this->getCategoriesTreeView(); 35 | 36 | foreach ($categoriesTreeView as $cat) 37 | { 38 | $hyphen = ''; 39 | for ($i = 1; $i < $cat['level']; $i++) { 40 | $hyphen .= '--'; 41 | } 42 | $options[] = array( 43 | 'label' => $hyphen . $cat['label'], 44 | 'value' => $cat['value'] 45 | ); 46 | } 47 | 48 | return $options; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/sql/afterpay_setup/install-0.13.0.php: -------------------------------------------------------------------------------- 1 | startSetup(); 10 | 11 | /** 12 | * Setup script to create new column on sales_flat_quote_payment for: 13 | * - afterpay_token 14 | * - afterpay_order_id 15 | */ 16 | 17 | // add columns to sales/order_payment 18 | $table = $installer->getTable('sales_flat_order_payment'); 19 | $installer->getConnection()->addColumn($table, "afterpay_token", "varchar(255) DEFAULT NULL COMMENT 'Afterpay Order Token'"); 20 | $installer->getConnection()->addColumn($table, "afterpay_order_id", "varchar(255) DEFAULT NULL COMMENT 'Afterpay Order ID'"); 21 | $installer->getConnection()->addColumn($table, "afterpay_fetched_at", "TIMESTAMP NULL"); 22 | 23 | // add new status and map it to Payment Review state 24 | $status = 'afterpay_payment_review'; 25 | $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW; 26 | $installer->run("INSERT INTO `{$this->getTable('sales_order_status')}` (`status`, `label`) VALUES ('{$status}', 'Afterpay Processing');"); 27 | $installer->run("INSERT INTO `{$this->getTable('sales_order_status_state')}` (`status`, `state`, `is_default`) VALUES ('{$status}', '{$state}', '0');"); 28 | 29 | $table = $installer->getTable('sales/quote_payment'); 30 | $installer->getConnection()->addColumn($table, 'afterpay_token', "varchar(255) DEFAULT NULL COMMENT 'Afterpay Order Token'"); 31 | $installer->getConnection()->addColumn($table, 'afterpay_order_id', "varchar(255) DEFAULT NULL COMMENT 'Afterpay Order ID'"); 32 | 33 | $installer->endSetup(); 34 | 35 | ?> 36 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/sql/afterpay_setup/install-0.5.0.php: -------------------------------------------------------------------------------- 1 | startSetup(); 13 | 14 | //-------------------------------------------------- 15 | /* 16 | # add custom columns 17 | ALTER TABLE sales_flat_order_payment 18 | ADD COLUMN afterpay_token varchar(255) DEFAULT NULL COMMENT 'Afterpay Order Token', 19 | ADD COLUMN afterpay_order_id varchar(255) DEFAULT NULL COMMENT 'Afterpay Order ID', 20 | ADD COLUMN afterpay_fetched_at TIMESTAMP NULL; 21 | 22 | # add custom order status 23 | INSERT INTO sales_order_status (`status`, `label`) VALUES ('afterpay_payment_review', 'Afterpay Processing'); 24 | INSERT INTO sales_order_status_state (`status`, `state`, `is_default`) VALUES ('afterpay_payment_review', 'payment_review', '0'); 25 | */ 26 | //-------------------------------------------------- 27 | 28 | // add columns to sales/order_payment 29 | $table = $installer->getTable('sales_flat_order_payment'); 30 | $installer->getConnection()->addColumn($table, "afterpay_token", "varchar(255) DEFAULT NULL COMMENT 'Afterpay Order Token'"); 31 | $installer->getConnection()->addColumn($table, "afterpay_order_id", "varchar(255) DEFAULT NULL COMMENT 'Afterpay Order ID'"); 32 | $installer->getConnection()->addColumn($table, "afterpay_fetched_at", "TIMESTAMP NULL"); 33 | 34 | // add new status and map it to Payment Review state 35 | $status = 'afterpay_payment_review'; 36 | $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW; 37 | $installer->run("INSERT INTO `{$this->getTable('sales_order_status')}` (`status`, `label`) VALUES ('{$status}', 'Afterpay Processing');"); 38 | $installer->run("INSERT INTO `{$this->getTable('sales_order_status_state')}` (`status`, `state`, `is_default`) VALUES ('{$status}', '{$state}', '0');"); 39 | //-------------------------------------------------- 40 | 41 | $installer->endSetup(); 42 | -------------------------------------------------------------------------------- /src/app/code/community/Afterpay/Afterpay/Block/Banner.php: -------------------------------------------------------------------------------- 1 | getModuleVersion(); 33 | } 34 | 35 | return "document.write(' 57 | 58 | 59 | 60 | 61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/src/js/Afterpay/checkout/firecheckout.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | if (typeof window.checkout !== "undefined") {
3 | /**
4 | * Override the save method when placing order
5 | *
6 | * @type {FireCheckout.save}
7 | */
8 | var save = window.FireCheckout.prototype.save;
9 | window.FireCheckout.prototype.save = function (urlSuffix, forceSave) {
10 | // if we have paid with the afterpay pay over time method
11 | if (payment.currentMethod == 'afterpaypayovertime') {
12 | this.urls.save = window.AfterpayM1.saveUrl;
13 |
14 | /**
15 | * Override response if using Afterpay.
16 | * Check with response and do redirect or popup
17 | *
18 | * @param transport
19 | */
20 | this.setResponse = function(transport) {
21 | var response = {};
22 | // Parse the response - lifted from original method
23 | try {
24 | response = eval('(' + transport.responseText + ')');
25 | }
26 | catch (e) {
27 | response = {};
28 | }
29 |
30 | // if the order has been successfully placed
31 | if (response.success) {
32 | window.checkout.setLoadWaiting(false);
33 |
34 | //modified to suit API V1
35 | if( window.afterpayReturnUrl === false ) {
36 | if (typeof AfterPay.initialize === "function") {
37 | AfterPay.initialize(window.afterpayCountryCode);
38 | } else {
39 | AfterPay.init();
40 | }
41 | }
42 | else {
43 | AfterPay.init({
44 | relativeCallbackURL: window.afterpayReturnUrl
45 | });
46 | }
47 |
48 | switch (window.AfterpayM1.redirectMode) {
49 | case 'lightbox':
50 | AfterPay.display({
51 | token: response.token
52 | });
53 | break;
54 |
55 | case 'redirect':
56 | AfterPay.redirect({
57 | token: response.token
58 | });
59 | break;
60 | }
61 | } else {
62 | if (response.redirect) {
63 | this.isSuccess = false;
64 | location.href = response.redirect;
65 | } else {
66 | alert(response.message);
67 | }
68 | }
69 |
70 | };
71 | }
72 |
73 | // call the original function
74 | save.apply(this, arguments);
75 | }
76 | }
77 | })();
78 |
--------------------------------------------------------------------------------
/src/js/Afterpay/checkout/onepage.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | if (typeof window.Review !== "undefined") {
3 | var target = window.Review;
4 | }
5 | else if (typeof window.Payment !== "undefined") {
6 | var target = window.Payment;
7 | }
8 | else {
9 | var target = false;
10 | }
11 |
12 | if (target) {
13 | var reviewSave = target.prototype.save;
14 | target.prototype.save = function() {
15 | // check payment method
16 | if (payment.currentMethod == 'afterpaypayovertime') {
17 | this.saveUrl = window.AfterpayM1.saveUrl;
18 | /**
19 | * Override on complete to do afterpay payment
20 | *
21 | * @param transport
22 | */
23 | this.onComplete = function(transport) {
24 | var response = {};
25 |
26 | // Parse the response - lifted from original method
27 | try {
28 | response = eval('(' + transport.responseText + ')');
29 | } catch (e) {
30 | response = {};
31 | }
32 |
33 | // If response success
34 | if (response.success) {
35 | //modified to suit API V1
36 | if( window.afterpayReturnUrl === false ) {
37 | if (typeof AfterPay.initialize === "function") {
38 | AfterPay.initialize(window.afterpayCountryCode);
39 | } else {
40 | AfterPay.init();
41 | }
42 | }
43 | else {
44 | AfterPay.init({
45 | relativeCallbackURL: window.afterpayReturnUrl
46 | });
47 | }
48 |
49 | switch (window.AfterpayM1.redirectMode) {
50 | case 'lightbox':
51 | AfterPay.display({
52 | token: response.token
53 | });
54 | break;
55 |
56 | case 'redirect':
57 | AfterPay.redirect({
58 | token: response.token
59 | });
60 | break;
61 | }
62 | } else {
63 | if (response.redirect) {
64 | this.isSuccess = false;
65 | location.href = response.redirect;
66 | } else {
67 | alert(response.message);
68 | }
69 | }
70 | };
71 |
72 | /**
73 | * Override the redirect if lightbox is selected
74 | */
75 | if (window.AfterpayM1.redirectMode == 'lightbox') {
76 | this.onSave = function(){};
77 | }
78 | }
79 |
80 | /**
81 | * Call original function
82 | */
83 | reviewSave.apply(this, arguments);
84 | };
85 | }
86 | })();
87 |
--------------------------------------------------------------------------------
/src/js/Afterpay/checkout/quickcheckout.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Override the FME Quick checkout JS function
3 | */
4 | (function() {
5 | if (typeof window.Review !== 'undefined') {
6 | var original = window.Review.prototype.save;
7 |
8 | /**
9 | * Adding calculation for Afterpay payment method
10 | */
11 | window.Review.prototype.save = function () {
12 | // if we have paid with the afterpay pay over time method and use new flow
13 | if (payment.currentMethod == 'afterpaypayovertime') {
14 | // As per sage payment on checkout it self
15 | if ($("billing:use_for_shipping_yes").checked != true) {
16 | shipping.setSameAsBilling(true);
17 | }
18 | // Set the Ajax Url to use afterpay url
19 | review_url = AfterpayM1.saveUrl;
20 |
21 | /**
22 | * Override the response after ajax for afterpay method
23 | *
24 | * @param transport
25 | */
26 | onestepcheckout.processRespone = function(transport) {
27 | var response = {};
28 |
29 | // Parse the response - lifted from original method
30 | try {
31 | response = eval('(' + transport.responseText + ')');
32 | } catch (e) {
33 | response = {};
34 | }
35 |
36 | // If response success
37 | if (response.success) {
38 |
39 | //modified to suit API V1
40 | if( window.afterpayReturnUrl === false ) {
41 | if (typeof AfterPay.initialize === "function") {
42 | AfterPay.initialize(window.afterpayCountryCode);
43 | } else {
44 | AfterPay.init();
45 | }
46 | }
47 | else {
48 | AfterPay.init({
49 | relativeCallbackURL: window.afterpayReturnUrl
50 | });
51 | }
52 |
53 | switch (window.AfterpayM1.redirectMode) {
54 | case 'lightbox':
55 | AfterPay.display({
56 | token: response.token
57 | });
58 | break;
59 |
60 | case 'redirect':
61 | AfterPay.redirect({
62 | token: response.token
63 | });
64 | break;
65 | }
66 | } else {
67 | if (response.redirect) {
68 | this.isSuccess = false;
69 | location.href = response.redirect;
70 | return;
71 | } else {
72 | alert(response.message);
73 | }
74 | }
75 | };
76 | }
77 |
78 | // call the original function
79 | original.apply(this, arguments);
80 | };
81 | }
82 | })();
83 |
--------------------------------------------------------------------------------
/src/js/Afterpay/checkout/aw_onestepcheckout.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | if (typeof window.AWOnestepcheckoutForm !== 'undefined') {
3 | /**
4 | * Changing the function before placing the order
5 | *
6 | * @type {AWOnestepcheckoutForm._sendPlaceOrderRequest}
7 | */
8 | var sendPlaceOrder = window.AWOnestepcheckoutForm.prototype._sendPlaceOrderRequest;
9 | window.AWOnestepcheckoutForm.prototype._sendPlaceOrderRequest = function () {
10 | // check if using afterpay as a payment method
11 | if (awOSCPayment.currentMethod == 'afterpaypayovertime' || payment.currentMethod == 'afterpaypayovertime') {
12 | // Set the place order URL based on the configuration
13 | this.placeOrderUrl = window.AfterpayM1.saveUrl;
14 |
15 | /**
16 | * onComplete function will run after Ajax is finished.
17 | * 1. It will check if ajax return success and continue Afterpay
18 | * 2. Redirect or alert when it's failed
19 | *
20 | * @param transport
21 | */
22 | this.onComplete = function(transport) {
23 | var response = {};
24 |
25 | // Parse the response - lifted from original method
26 | try {
27 | response = eval('(' + transport.responseText + ')');
28 | } catch (e) {
29 | response = {};
30 | }
31 |
32 | // If response success
33 | if (response.success) {
34 |
35 | //modified to suit API V1
36 | if( window.afterpayReturnUrl === false ) {
37 | if (typeof AfterPay.initialize === "function") {
38 | AfterPay.initialize(window.afterpayCountryCode);
39 | } else {
40 | AfterPay.init();
41 | }
42 | }
43 | else {
44 | AfterPay.init({
45 | relativeCallbackURL: window.afterpayReturnUrl
46 | });
47 | }
48 |
49 | switch (window.AfterpayM1.redirectMode) {
50 | case 'lightbox':
51 | AfterPay.display({
52 | token: response.token
53 | });
54 | break;
55 |
56 | case 'redirect':
57 | AfterPay.redirect({
58 | token: response.token
59 | });
60 | break;
61 | }
62 | } else {
63 | if (response.redirect) {
64 | this.isSuccess = false;
65 | location.href = response.redirect;
66 | } else {
67 | alert(response.message);
68 | }
69 | }
70 | };
71 | }
72 |
73 | /**
74 | * Call original function
75 | */
76 | sendPlaceOrder.apply(this, arguments);
77 | };
78 | }
79 | })();
80 |
--------------------------------------------------------------------------------
/src/app/code/community/Afterpay/Afterpay/Model/System/Config/Source/ApiMode.php:
--------------------------------------------------------------------------------
1 | $settings) {
26 | $options[$name] = $settings[self::KEY_NAME];
27 | }
28 |
29 | return $options;
30 | }
31 |
32 | /**
33 | * Get config prefix for selected API mode
34 | *
35 | * @param string $environment
36 | * @return null|string
37 | */
38 | public static function getEnvironmentSettings($environment)
39 | {
40 | $settings = self::_getConfigSettings();
41 |
42 | if (isset($settings[$environment])) {
43 | return $settings[$environment];
44 | }
45 |
46 | return null;
47 | }
48 |
49 | /**
50 | * Get configured Afterpay environments from config.xml
51 | *
52 | * @return array
53 | */
54 | protected static function _getConfigSettings()
55 | {
56 | if(Mage::app()->getStore()->isAdmin()) {
57 | $websiteCode = Mage::app()->getRequest()->getParam('website');
58 |
59 | if ($websiteCode) {
60 | $website = Mage::getModel('core/website')->load($websiteCode);
61 | $websiteId = $website->getId();
62 | } else {
63 | $order_id = Mage::app()->getRequest()->getParam('order_id');
64 |
65 | if($order_id) {
66 | $websiteId = Mage::getModel('core/store')->load(Mage::getModel('sales/order')->load($order_id)->getStoreId())->getWebsiteId();
67 | } else {
68 | $websiteId = 0;
69 | }
70 | }
71 | } else {
72 | $websiteId = null;
73 | }
74 |
75 | if (Mage::app()->getWebsite($websiteId)->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_DEFAULT) == 'USD' ||
76 | Mage::app()->getWebsite($websiteId)->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_DEFAULT) == 'CAD') {
77 | $api = 'api_us_url';
78 | $web = 'web_us_url';
79 | } else {
80 | $api = 'api_url';
81 | $web = 'web_url';
82 | }
83 |
84 | $options = array();
85 |
86 | foreach (Mage::getConfig()->getNode('afterpay/environments')->children() as $environment) {
87 | $options[$environment->getName()] = array(
88 | self::KEY_NAME => (string) $environment->name,
89 | self::KEY_API_URL => (string) $environment->{$api},
90 | self::KEY_WEB_URL => (string) $environment->{$web},
91 | );
92 | }
93 |
94 | return $options;
95 | }
96 |
97 | /**
98 | * Get currencyCode for the store
99 | *
100 | * @return array
101 | */
102 | public static function getCurrencyCode()
103 | {
104 | return Mage::app()->getStore()->getCurrentCurrencyCode();
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/src/js/Afterpay/checkout/gomage.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | if (typeof window.Lightcheckout !== "undefined") {
3 | /**
4 | * Override saveorder ajax to get order token
5 | *
6 | * @type {Lightcheckout.prototype.saveorder|*|Lightcheckout.saveorder}
7 | */
8 | window.Lightcheckout.prototype.saveorder = function() {
9 | // Check wether is currently using afterpay
10 | if (payment.currentMethod == 'afterpaypayovertime') {
11 | this.showLoadinfo();
12 | // prepare params
13 | var params = this.getFormData();
14 | // Ajax to start order token
15 | var request = new Ajax.Request(
16 | window.AfterpayM1.saveUrl, // use Afterpay controller
17 | {
18 | method: 'post',
19 | parameters: params,
20 | onSuccess: function (transport) {
21 | var response = {};
22 |
23 | // Parse the response - lifted from original method
24 | try {
25 | response = eval('(' + transport.responseText + ')');
26 | }
27 | catch (e) {
28 | response = {};
29 | }
30 |
31 | // if the order has been successfully placed
32 | if (response.success) {
33 |
34 | //modified to suit API V1
35 | if( window.afterpayReturnUrl === false ) {
36 | if (typeof AfterPay.initialize === "function") {
37 | AfterPay.initialize(window.afterpayCountryCode);
38 | } else {
39 | AfterPay.init();
40 | }
41 | }
42 | else {
43 | AfterPay.init({
44 | relativeCallbackURL: window.afterpayReturnUrl
45 | });
46 | }
47 |
48 | switch (window.AfterpayM1.redirectMode) {
49 | case 'lightbox':
50 | AfterPay.display({
51 | token: response.token
52 | });
53 |
54 | break;
55 |
56 | case 'redirect':
57 | AfterPay.redirect({
58 | token: response.token
59 | });
60 |
61 | break;
62 | }
63 | } else {
64 | if (response.redirect) {
65 | this.isSuccess = false;
66 | location.href = response.redirect;
67 | } else {
68 | alert(response.message);
69 | }
70 | }
71 |
72 | }.bind(this),
73 | onFailure: function () {
74 | alert('Afterpay Gateway is not available.');
75 | }
76 | }
77 | );
78 | }
79 | };
80 | }
81 |
82 | })();
83 |
--------------------------------------------------------------------------------
/src/js/Afterpay/checkout/mw_onestepcheckout.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Function specifically for MW OneStepCheckout. The class especially for it
3 | */
4 | jQuery( document ).ready( function() {
5 | var form = document.getElementById('onestep_form');
6 | var action = form.getAttribute('action');
7 |
8 | // save in variable for default .submit
9 | var original = form.submit;
10 |
11 | /**
12 | * Create new definition on .submit
13 | *
14 | * - Check if using Afterpay and use new flow, do Ajax and pop up or redirect
15 | */
16 |
17 | //hacks the form to prevent override by other plugins
18 | jQuery(".btn-checkout").on("click", function(e) {
19 |
20 | if (payment.currentMethod == 'afterpaypayovertime') {
21 |
22 | e.preventDefault();
23 | e.stopPropagation();
24 |
25 | // prepare params
26 | var params = form.serialize(true);
27 |
28 | // Ajax to start order token
29 | var request = new Ajax.Request(
30 | window.AfterpayM1.saveUrl, // use Afterpay controller
31 | {
32 | method: 'post',
33 | parameters: params,
34 | onSuccess: function (transport) {
35 | var response = {};
36 |
37 | // Parse the response - lifted from original method
38 | try {
39 | response = eval('(' + transport.responseText + ')');
40 | }
41 | catch (e) {
42 | response = {};
43 | }
44 |
45 | // if the order has been successfully placed
46 | if (response.success) {
47 |
48 | //modified to suit API V1
49 | if( window.afterpayReturnUrl === false ) {
50 | if (typeof AfterPay.initialize === "function") {
51 | AfterPay.initialize(window.afterpayCountryCode);
52 | } else {
53 | AfterPay.init();
54 | }
55 | }
56 | else {
57 | AfterPay.init({
58 | relativeCallbackURL: window.afterpayReturnUrl
59 | });
60 | }
61 |
62 | switch (window.AfterpayM1.redirectMode) {
63 | case 'lightbox':
64 | AfterPay.display({
65 | token: response.token
66 | });
67 |
68 | break;
69 |
70 | case 'redirect':
71 | AfterPay.redirect({
72 | token: response.token
73 | });
74 |
75 | break;
76 | }
77 | } else {
78 | if (response.redirect) {
79 | this.isSuccess = false;
80 | location.href = response.redirect;
81 | } else {
82 | alert(response.message);
83 | }
84 | }
85 |
86 | }.bind(this),
87 | onFailure: function () {
88 | alert('Afterpay Gateway is not available.');
89 | }
90 | }
91 | );
92 | }
93 | });
94 | });
95 |
--------------------------------------------------------------------------------
/src/js/Afterpay/checkout/amasty_onestepcheckout.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Function specifically for MW OneStepCheckout. The class especially for it
3 | */
4 | jQuery( document ).ready( function() {
5 | var form = document.getElementById('amscheckout-onepage');
6 | var action = form.getAttribute('action');
7 |
8 | // save in variable for default .submit
9 | var original = form.submit;
10 |
11 | /**
12 | * Create new definition on .submit
13 | *
14 | * - Check if using Afterpay and use new flow, do Ajax and pop up or redirect
15 | */
16 |
17 | //hacks the form to prevent override by other plugins
18 | jQuery("#amscheckout-submit").on("click", function(e) {
19 |
20 | if (payment.currentMethod == 'afterpaypayovertime') {
21 |
22 | e.preventDefault();
23 | e.stopPropagation();
24 |
25 | // prepare params
26 | var params = form.serialize(true);
27 |
28 | // Ajax to start order token
29 | var request = new Ajax.Request(
30 | window.AfterpayM1.saveUrl, // use Afterpay controller
31 | {
32 | method: 'post',
33 | parameters: params,
34 | onSuccess: function (transport) {
35 | var response = {};
36 |
37 | // Parse the response - lifted from original method
38 | try {
39 | response = eval('(' + transport.responseText + ')');
40 | }
41 | catch (e) {
42 | response = {};
43 | }
44 |
45 | // if the order has been successfully placed
46 | if (response.success) {
47 |
48 | //modified to suit API V1
49 | if( window.afterpayReturnUrl === false ) {
50 | if (typeof AfterPay.initialize === "function") {
51 | AfterPay.initialize(window.afterpayCountryCode);
52 | } else {
53 | AfterPay.init();
54 | }
55 | }
56 | else {
57 | AfterPay.init({
58 | relativeCallbackURL: window.afterpayReturnUrl
59 | });
60 | }
61 |
62 | switch (window.AfterpayM1.redirectMode) {
63 | case 'lightbox':
64 | AfterPay.display({
65 | token: response.token
66 | });
67 |
68 | break;
69 |
70 | case 'redirect':
71 | AfterPay.redirect({
72 | token: response.token
73 | });
74 |
75 | break;
76 | }
77 | } else {
78 | if (response.redirect) {
79 | this.isSuccess = false;
80 | location.href = response.redirect;
81 | } else {
82 | alert(response.message);
83 | }
84 | }
85 |
86 | }.bind(this),
87 | onFailure: function () {
88 | alert('Afterpay Gateway is not available.');
89 | }
90 | }
91 | );
92 | }
93 | });
94 | });
95 |
--------------------------------------------------------------------------------
/src/js/Afterpay/checkout/idev_onestep.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Function specifically for Idev OneStepCheckout. The class especially for it
3 | */
4 | (function() {
5 | var form = $('onestepcheckout-form');
6 | var action = form.getAttribute('action');
7 |
8 | // save in variable for default .submit
9 | var original = form.submit;
10 |
11 | /**
12 | * Create new definition on .submit
13 | *
14 | * - Check if using Afterpay and use new flow, do Ajax and pop up or redirect
15 | */
16 | form.submit = function() {
17 | //jQuery("#onestepcheckout-place-order").on("click", function() {
18 | if (payment.currentMethod == 'afterpaypayovertime') {
19 | // prepare params
20 | var params = form.serialize(true);
21 |
22 | var customer_password = jQuery('#billing\\:customer_password').val();
23 |
24 | if( typeof customer_password !== 'undefined' && customer_password.length ) {
25 | params.create_account = 1;
26 | }
27 |
28 | // Registration handling
29 | doAfterpayAPICall(window.AfterpayM1.saveUrl, params);
30 | return false;
31 |
32 | } else {
33 | original.apply(this, arguments);
34 | }
35 | //}); For the jQuery version
36 | };
37 | })();
38 |
39 |
40 | function doAfterpayAPICall( saveURL, params ) {
41 | // Ajax to start order token
42 | var request = new Ajax.Request(
43 | saveURL, // use Afterpay controller
44 | {
45 | method: 'post',
46 | parameters: params,
47 | onSuccess: function (transport) {
48 | var response = {};
49 |
50 | // Parse the response - lifted from original method
51 | try {
52 | response = eval('(' + transport.responseText + ')');
53 | }
54 | catch (e) {
55 | response = {};
56 | }
57 |
58 | // if the order has been successfully placed
59 | if (response.success) {
60 |
61 | //modified to suit API V1
62 | if( window.afterpayReturnUrl === false ) {
63 | if (typeof AfterPay.initialize === "function") {
64 | AfterPay.initialize(window.afterpayCountryCode);
65 | } else {
66 | AfterPay.init();
67 | }
68 | }
69 | else {
70 | AfterPay.init({
71 | relativeCallbackURL: window.afterpayReturnUrl
72 | });
73 | }
74 |
75 | switch (window.AfterpayM1.redirectMode) {
76 | case 'lightbox':
77 | AfterPay.display({
78 | token: response.token
79 | });
80 |
81 | break;
82 |
83 | case 'redirect':
84 | AfterPay.redirect({
85 | token: response.token
86 | });
87 |
88 | break;
89 | }
90 | } else {
91 | if (response.redirect) {
92 | this.isSuccess = false;
93 | location.href = response.redirect;
94 | } else {
95 | alert(response.message);
96 | }
97 | }
98 |
99 | }.bind(this),
100 | onFailure: function () {
101 | alert('Afterpay Gateway is not available.');
102 | }
103 | }
104 | );
105 | }
106 |
--------------------------------------------------------------------------------
/src/app/code/community/Afterpay/Afterpay/Model/Api/Http/Client.php:
--------------------------------------------------------------------------------
1 | _helper = Mage::helper('afterpay');
11 |
12 | if (!extension_loaded('curl')) {
13 | throw Mage::exception(
14 | 'Afterpay_Afterpay',
15 | $this->_helper->__('cURL extension has to be loaded to use this Afterpay Http Client.')
16 | );
17 | }
18 |
19 | $this->_url = $url;
20 | }
21 |
22 | public function setConfigs($configs = array())
23 | {
24 | if (isset($configs['auth_user']) && isset($configs['auth_pwd'])) {
25 | $this->_configs[CURLOPT_USERPWD] = $configs['auth_user'].':'.$configs['auth_pwd'];
26 | }
27 |
28 | if (isset($configs['useragent'])) {
29 | $this->_configs[CURLOPT_USERAGENT] = $configs['useragent'];
30 | }
31 |
32 | if (isset($configs['timeout'])) {
33 | $this->_configs[CURLOPT_TIMEOUT] = $configs['timeout'];
34 | }
35 | }
36 |
37 | public function request($method = 'GET', $data = array())
38 | {
39 | $opts = $this->_configs + array(
40 | CURLOPT_URL => $this->_url,
41 | CURLOPT_HTTPHEADER => array(
42 | 'Accept: application/json',
43 | ),
44 | CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
45 | CURLOPT_RETURNTRANSFER => TRUE,
46 | CURLOPT_TIMEOUT => 80,
47 | );
48 |
49 | if (!empty($data)) {
50 | $opts[CURLOPT_POSTFIELDS] = json_encode($data);
51 | $opts[CURLOPT_HTTPHEADER][] = 'Content-Type: application/json';
52 | $opts[CURLOPT_HTTPHEADER][] = 'Content-Length: '.strlen($opts[CURLOPT_POSTFIELDS]);
53 |
54 | switch (strtoupper($method)) {
55 | case 'POST':
56 | $opts[CURLOPT_POST] = TRUE;
57 | break;
58 | case 'PUT':
59 | $opts[CURLOPT_CUSTOMREQUEST] = 'PUT';
60 | break;
61 | }
62 | }
63 |
64 | $ch = curl_init();
65 |
66 | if (!curl_setopt_array($ch, $opts)) {
67 | // If an option could not be successfully set
68 | curl_close($ch);
69 | $this->_helper->log('Unable to set cURL with options:');
70 | $this->_helper->log($opts);
71 |
72 | throw Mage::exception('Afterpay_Afterpay', $this->_helper->__('Unable to set options for cURL.'));
73 | }
74 |
75 | $output = curl_exec($ch);
76 | $errno = curl_errno($ch);
77 | $error = curl_error($ch);
78 |
79 | if ($errno) {
80 | // i.e. It cannot get a response
81 | $this->_helper->log('cURL error number: ' . $errno . ', error message: ' . $error);
82 | $output = json_encode(array(
83 | 'errorCode' => $errno,
84 | 'errorId' => null,
85 | 'message' => $error,
86 | 'httpStatusCode' => null
87 | ));
88 | }
89 | elseif (is_null(json_decode($output))) {
90 | // i.e. It does return a response but it is not in JSON format
91 | $output = json_encode(array(
92 | 'errorCode' => 'non_json',
93 | 'errorId' => null,
94 | 'message' => curl_getinfo($ch, CURLINFO_CONTENT_TYPE) . ' response could not be decoded: ' . json_last_error_msg(),
95 | 'httpStatusCode' => curl_getinfo($ch, CURLINFO_RESPONSE_CODE)
96 | ));
97 | }
98 |
99 | curl_close($ch);
100 |
101 | return $output;
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/src/js/Afterpay/checkout/awesomecheckout.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | if (typeof window.Review !== "undefined") {
3 | /**
4 | * Override save on order review function
5 | */
6 | var reviewSave = window.Review.prototype.save;
7 | window.Review.prototype.save = function() {
8 | // check payment method
9 | if (payment.currentMethod == 'afterpaypayovertime') {
10 | if (checkout.loadWaiting != false) return;
11 | checkout.setLoadWaiting('review');
12 | /**
13 | * Override on complete to do afterpay payment
14 | *
15 | * @param transport
16 | */
17 | // Run ajax to process Afterpay payment using Protorype
18 | var request = new Ajax.Request(
19 | window.AfterpayM1.saveUrl, // use Afterpay controller
20 | {
21 | method: 'post',
22 | onSuccess: function (transport) {
23 | var response = {};
24 |
25 | // Parse the response - lifted from original method
26 | try {
27 | response = eval('(' + transport.responseText + ')');
28 | }
29 | catch (e) {
30 | response = {};
31 | }
32 |
33 | // if the order has been successfully placed
34 | if (response.success) {
35 |
36 | //modified to suit API V1
37 | if( window.afterpayReturnUrl === false ) {
38 | if (typeof AfterPay.initialize === "function") {
39 | AfterPay.initialize(window.afterpayCountryCode);
40 | } else {
41 | AfterPay.init();
42 | }
43 | }
44 | else {
45 | AfterPay.init({
46 | relativeCallbackURL: window.afterpayReturnUrl
47 | });
48 | }
49 |
50 | switch (window.AfterpayM1.redirectMode) {
51 | case 'lightbox':
52 | AfterPay.display({
53 | token: response.token
54 | });
55 |
56 | break;
57 |
58 | case 'redirect':
59 | AfterPay.redirect({
60 | token: response.token
61 | });
62 |
63 | break;
64 | }
65 | } else {
66 | if (response.redirect) {
67 | this.isSuccess = false;
68 | location.href = response.redirect;
69 | } else {
70 | alert(response.message);
71 | }
72 | }
73 |
74 | }.bind(this),
75 | onFailure: function () {
76 | alert('Afterpay Gateway is not available.');
77 | }
78 | }
79 | );
80 | } else {
81 | /**
82 | * Call original function
83 | */
84 | reviewSave.apply(this, arguments);
85 | }
86 | };
87 | }
88 | })();
89 |
--------------------------------------------------------------------------------
/src/js/Afterpay/checkout/iwd_opc.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Override the IWD checkout JS function
3 | */
4 | (function() {
5 | if (typeof window.IWD !== 'undefined' && typeof window.IWD.OPC !== 'undefined') {
6 | /**
7 | * Override Saving order checkout to run Afterpay method first
8 | *
9 | * @type {IWD.OPC.callSaveOrder|*}
10 | */
11 | var saveOrder = window.IWD.OPC.callSaveOrder;
12 | window.IWD.OPC.callSaveOrder = function (form) {
13 | // if we have paid with the afterpay pay over time method
14 | if (payment.currentMethod == 'afterpaypayovertime') {
15 |
16 | // perform dispatch as per original
17 | IWD.OPC.Plugin.dispatch('saveOrder');
18 |
19 | // Run ajax to process Afterpay payment using Protorype
20 | var request = new Ajax.Request(
21 | window.AfterpayM1.saveUrl, // use Afterpay controller
22 | {
23 | method: 'post',
24 | parameters: form,
25 | onSuccess: function (transport) {
26 | var response = {};
27 |
28 | // Parse the response - lifted from original method
29 | try {
30 | response = eval('(' + transport.responseText + ')');
31 | }
32 | catch (e) {
33 | response = {};
34 | }
35 |
36 | // if the order has been successfully placed
37 | if (response.success) {
38 |
39 | //modified to suit API V1
40 | if( window.afterpayReturnUrl === false ) {
41 | if (typeof AfterPay.initialize === "function") {
42 | AfterPay.initialize(window.afterpayCountryCode);
43 | } else {
44 | AfterPay.init();
45 | }
46 | }
47 | else {
48 | AfterPay.init({
49 | relativeCallbackURL: window.afterpayReturnUrl
50 | });
51 | }
52 |
53 | switch (window.AfterpayM1.redirectMode) {
54 | case 'lightbox':
55 | AfterPay.display({
56 | token: response.token
57 | });
58 |
59 | break;
60 |
61 | case 'redirect':
62 | AfterPay.redirect({
63 | token: response.token
64 | });
65 |
66 | break;
67 | }
68 | } else {
69 | if (response.redirect) {
70 | this.isSuccess = false;
71 | location.href = response.redirect;
72 | } else {
73 | alert(response.message);
74 | }
75 | }
76 |
77 | }.bind(this),
78 | onFailure: function () {
79 | alert('Afterpay Gateway is not available.');
80 | }
81 | }
82 | );
83 | } else {
84 | // call the original function
85 | saveOrder.apply(this, arguments);
86 | }
87 | };
88 | }
89 | })();
90 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://business.adobe.com/blog/basics/support-magento-1-software-ends-june-30-2020)
2 |
3 | ## 1.1 New Afterpay Installation
4 |
5 | This section outlines the steps to install the Afterpay plugin on your Magento instance for the first time.
6 |
7 | Magento can be installed in any folder on your server. For the purposes of this document, `[MAGENTO]` will refer to the root folder where Magento is installed.
8 |
9 | 1. The Afterpay plugin for Magento 1 is available as a `.zip` or `tar.gz` file from the Afterpay GitHub repository
10 | 1. Unzip the file and copy everything in `/src/` to `[MAGENTO]/`
11 | 1. Login to the Magento Admin and navigate to "System > Cache Management"
12 | 1. Flush the cache storage by selecting _Flush Cache Storage_
13 |
14 | ## 1.2 Website Configuration
15 |
16 | Afterpay operates under a list of assumptions based on Magento configurations. To align with these assumptions, the Magento configurations must reflect the below.
17 |
18 | 1. **Website Currency must be set to AUD, NZD, USD or CAD**
19 |
20 | Inside the Magento Admin, navigate to "System > Configuration > Currency Setup". Set the base, display and allowed currency as appropriate to match your Afterpay Merchant Account.
21 |
22 | 1. **Postal Code must be mandatory**
23 |
24 | Inside the Magento Admin, navigate to "System > Configuration > General". Ensure _Postal Code_ is **not** configured as optional for any country that Afterpay is being applied to.
25 |
26 | ## 1.3 Afterpay Merchant Setup
27 |
28 | To configure your Afterpay Merchant Account credentials in the Magento Admin, please complete the steps below. The prerequisite for this section is to obtain an Afterpay Merchant ID and Secret Key from Afterpay.
29 |
30 | 1. Inside the Magento Admin, navigate to "System > Configuration > Sales > Payment Methods > Afterpay"
31 | 1. Enter the _Merchant ID_ and _Merchant Secret Key_ (provided by Afterpay)
32 | 1. Enable Afterpay by selecting "Yes" from the _Enabled_ dropdown
33 | 1. Configure the _API Mode_ - select _Sandbox_ for testing on a staging instance, or _Production_ for a live website with legitimate transactions
34 | 1. Save the configuration
35 | 1. Click the _Update Payment Limits_ button to retrieve the Minimum and Maximum Afterpay Order values
36 |
37 | ## 1.4 Afterpay Display Configuration
38 |
39 | 1. Inside the Magento Admin, navigate to "System > Configuration > Sales > Afterpay"
40 | 1. Enable _Debug Mode_ to log transactions and additional valuable data
41 | 1. Configure the display of the Afterpay elements presented on Product Detail Pages (PDP), the cart page and at the checkout
42 | 1. After saving any changes, navigate to "System > Cache Management"
43 | 1. Flush the cache storage by selecting _Flush Cache Storage_
44 |
45 | ## 1.5 Upgrade Of Afterpay Installation
46 |
47 | This section outlines the steps to upgrade an existing installation of the Afterpay plugin to a new version.
48 |
49 | The process of upgrading the Afterpay plugin for Magento 1 involves the complete removal of all plugin files, followed by copying the new files.
50 |
51 | `[MAGENTO]` will refer to the root folder where you have installed your version of Magento.
52 |
53 | 1. Remove folder: `[MAGENTO]/app/code/community/Afterpay`
54 | 1. Remove folder: `[MAGENTO]/app/design/adminhtml/default/default/template/afterpay`
55 | 1. Remove file: `[MAGENTO]/app/design/frontend/base/default/layout/afterpay.xml`
56 | 1. Remove folder: `[MAGENTO]/app/design/frontend/base/default/template/afterpay`
57 | 1. Remove file: `[MAGENTO]/app/etc/modules/Afterpay_Afterpay.xml`
58 | 1. Remove folder: `[MAGENTO]/js/Afterpay`
59 | 1. Remove folder: `[MAGENTO]/skin/frontend/base/default/afterpay`
60 | 1. The Afterpay plugin for Magento 1 is available as a `.zip` or `tar.gz` file from the Afterpay GitHub repository
61 | 1. Unzip the file and copy everything in `/src/` to `[MAGENTO]/`
62 | 1. Login to the Magento Admin and navigate to "System > Cache Management"
63 | 1. Flush the cache storage by selecting _Flush Cache Storage_
64 |
--------------------------------------------------------------------------------
/src/app/code/community/Afterpay/Afterpay/Block/Catalog/Installments.php:
--------------------------------------------------------------------------------
1 | _getData('product');
23 | if (!$product) {
24 | $product = Mage::registry('product');
25 | }
26 | return $product;
27 | }
28 |
29 | public function isEnabled()
30 | {
31 | $product = $this->getProduct();
32 | return Mage::getStoreConfigFlag(self::XML_CONFIG_PREFIX . 'enable_' . $this->getPageType())
33 | && Mage::helper('afterpay/checkout')->noConflict()
34 | && Mage::getModel('afterpay/method_payovertime')->canUseForProduct($product)
35 | && !$product->isGrouped();
36 | }
37 |
38 | public function getCssSelectors()
39 | {
40 | $selectors = Mage::getStoreConfig(self::XML_CONFIG_PREFIX . $this->getPageType() . '_price_block_selectors');
41 | return explode("\n", $selectors);
42 | }
43 |
44 | public function getHtmlTemplate()
45 | {
46 | ob_start();
47 | ?>
48 |
53 |
54 | $this->getCssSelectors(),
97 | 'template' => $this->getHtmlTemplate(),
98 | 'priceSubstitution' => '{price_here}',
99 | 'minPriceLimit' => $this->getMinPriceLimit(),
100 | 'maxPriceLimit' => $this->getMaxPriceLimit(),
101 | 'installmentsAmount' => $this->getInstallmentsAmount(),
102 | 'afterpayEnabled' => $this->getStoreConfigEnabled(),
103 | 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(),
104 | 'currencySymbol' => Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(),
105 | 'className' => 'afterpay-installments-amount'
106 | );
107 | }
108 |
109 | protected function _toHtml()
110 | {
111 | if (!$this->isEnabled()) {
112 | return '';
113 | } else {
114 | return parent::_toHtml();
115 | }
116 | }
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/src/app/code/community/Afterpay/Afterpay/Helper/Checkout.php:
--------------------------------------------------------------------------------
1 | isAheadworksCheckout()) {
28 | return false;
29 | }
30 |
31 | if ($this->isIwdCheckout()) {
32 | return false;
33 | }
34 |
35 | if ($this->isTmFireCheckout()) {
36 | return false;
37 | }
38 |
39 | // has an extension we don't recognise changed the checkout URL?
40 | if ($this->isDifferentUrl()) {
41 | return true;
42 | }
43 |
44 | // has an extension rewritten the onepage checkout controller
45 | if ($this->defaultUrlExtended()) {
46 | return true;
47 | }
48 |
49 | // probably we are using the default checkout
50 | return false;
51 | }
52 |
53 | /**
54 | * Determine if the current site checkout URL is different to the default
55 | *
56 | * This is achieved by comparing the result of Mage_Checkout_Helper_Url::getCheckoutUrl() with the result of the
57 | * checkout/url helper's same method. In default Magento, these will be the same method and so will return the same
58 | * URL. However, almost all checkout extensions that use a custom URL rewrite this class to themselves and change
59 | * the return value of this method.
60 | *
61 | * This class extends Mage_Checkout_Helper_Url specifically so that it can have easy access to this default method.
62 | *
63 | * @return bool
64 | */
65 | public function isDifferentUrl()
66 | {
67 | $defaultUrl = $this->getCheckoutUrl();
68 | $actualUrl = Mage::helper('checkout/url')->getCheckoutUrl();
69 |
70 | return $defaultUrl != $actualUrl;
71 | }
72 |
73 | /**
74 | * Determine if we are using the Aheadworks one step checkout.
75 | *
76 | * This checks that the global setting added by the extension is enabled and set to true
77 | *
78 | * @return bool
79 | */
80 | public function isAheadworksCheckout()
81 | {
82 | return Mage::helper('core')->isModuleEnabled('AW_Onestepcheckout');
83 | }
84 |
85 | /**
86 | * Determine if we are using the IWD one step checkout
87 | *
88 | * This checks the global IWD checkout setting
89 | *
90 | * @return bool
91 | */
92 | public function isIwdCheckout()
93 | {
94 | return Mage::helper('core')->isModuleEnabled('IWD_Opc');
95 | }
96 |
97 | /**
98 | * Determine if we are using the TM FireCheckout
99 | *
100 | * This checks the global TM Firecheckout setting
101 | *
102 | * @return bool
103 | */
104 | public function isTmFireCheckout()
105 | {
106 | return Mage::helper('core')->isModuleEnabled('TM_FireCheckout');
107 | }
108 |
109 | /**
110 | * Determine if anything is rewriting the default onepage controller
111 | *
112 | * This is not a foolproof way of determining that we are using a custom checkout, on the default URL, but it's
113 | * a reasonably accurate one.
114 | *
115 | * @return bool
116 | */
117 | public function defaultUrlExtended()
118 | {
119 | $config = Mage::getConfig()->getNode('frontend/routers/checkout/args/modules');
120 |
121 | if ($config) {
122 | foreach ($config->children() as $override) {
123 | if ($override->getAttribute('before') == 'Mage_Checkout_OnepageController') {
124 | return true;
125 | }
126 | }
127 | }
128 |
129 | return false;
130 | }
131 |
132 | public function noConflict()
133 | {
134 | $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
135 | $base = Mage::app()->getStore()->getBaseCurrencyCode();
136 | return $currency == $base && in_array($currency, Afterpay_Afterpay_Model_Method_Base::SUPPORTED_CURRENCIES);
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/src/js/Afterpay/Installments.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Afterpay Installments JS library
3 | *
4 | * @package Afterpay_Afterpay
5 | * @author VEN Development Team 157 | Four interest-free payments totalling {order_amount} 158 |
159 |