Skip to content
This repository has been archived by the owner on Sep 3, 2022. It is now read-only.

Commit

Permalink
Release version 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
afterpayplugins committed Sep 2, 2020
1 parent 6eb3efa commit 85402d4
Show file tree
Hide file tree
Showing 30 changed files with 197 additions and 431 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Afterpay Magento 1 Extension Changelog

## Version 3.1.0

_Wed 2 Sep 2020 (AEST)_

### Supported Editions & Versions

- Magento Community Edition (CE) version 1.7 and later.
- Magento Enterprise Edition (EE) version 1.13 and later.

### Highlights

- Added support for Canadian merchants/consumers and CAD.
- Standardized modal content by using Afterpay Global JS Library.
- Fixed a defect where API Mode could be read from default scope instead of website scope.

---

## Version 3.0.5

_Wed 17 Jun 2020 (AEST)_
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Magento can be installed in any folder on your server. For the purposes of this

Afterpay operates under a list of assumptions based on Magento configurations. To align with these assumptions, the Magento configurations must reflect the below.

1. **Website Currency must be set to AUD, NZD or USD**
1. **Website Currency must be set to AUD, NZD, USD or CAD**

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.

Expand Down
49 changes: 29 additions & 20 deletions src/app/code/community/Afterpay/Afterpay/Block/Banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* @author Afterpay
* @copyright 2016-2018 Afterpay https://www.afterpay.com
*/

use Afterpay_Afterpay_Model_Method_Base as Afterpay_Base;

class Afterpay_Afterpay_Block_Banner extends Mage_Core_Block_Template
{
const XML_CONFIG_PREFIX = 'afterpay/banner/';
Expand All @@ -17,26 +20,6 @@ public function isEnabled()
return Mage::getStoreConfigFlag(self::XML_CONFIG_PREFIX . 'enabled');
}

/**
* @return array
*/
public function getCssSelector()
{
$selectors = Mage::getStoreConfig(self::XML_CONFIG_PREFIX . 'banner_block_selector');
return explode("\n", $selectors);
}

/**
* @return array
*/
public function getJsConfig()
{
return array(
'selector' => $this->getCssSelector(),
'className' => 'afterpay-banner'
);
}

/**
* @param string $scriptUrl
* @param bool $addModuleVersion
Expand All @@ -61,4 +44,30 @@ public function getModuleVersion()
$moduleConfig = Mage::getConfig()->getModuleConfig($this->getModuleName());
return (string)$moduleConfig->version;
}

public function getJsLibrary()
{
$apiMode = Mage::getStoreConfig('payment/afterpaypayovertime/' . Afterpay_Base::API_MODE_CONFIG_FIELD);

if ($apiMode == 'production') {
$url = 'https://js.afterpay.com/afterpay-1.x.js';
} else {
$url = 'https://js.sandbox.afterpay.com/afterpay-1.x.js';
}

return $url;
}

public function getJsLocale()
{
$locale = 'en_AU';
$currency = Mage::app()->getStore()->getCurrentCurrencyCode();

if (array_key_exists($currency, Afterpay_Base::CURRENCY_PROPERTIES)){
$locale = Afterpay_Base::CURRENCY_PROPERTIES[$currency]['jsLocale'];
}

return $locale;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ public function getCssSelectors()

public function getHtmlTemplate()
{
$result = Mage::getStoreConfig(self::XML_CONFIG_PREFIX . $this->getPageType() . '_html_template');
$result = str_replace(
'{skin_url}',
Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN),
$result
);
return $result;
ob_start();
?>
<div style="position: relative; font-style: italic; line-height: 1.4;" class="afterpay-installments">
or 4 interest-free payments of {price_here} with<br/>
<img src="https://static.afterpay.com/integration/[email protected]" style="width: 76px; vertical-align: middle; display: inline;" />
<a href="#afterpay-what-is-modal" class="afterpay-what-is-modal-trigger">Learn more</a>
</div>
<style type="text/css">.price-box.ciq_price_box .ciq_view_shipping{margin-top:35px}</style>
<?php
return ob_get_clean();
}

public function getMinPriceLimit()
Expand Down Expand Up @@ -87,25 +90,12 @@ public function getInstallmentsAmount()
return (int)Mage::getStoreConfig('payment/afterpaypayovertime/installments_amount');
}

public function getRegionSpecificText()
{
if(Mage::app()->getStore()->getCurrentCurrencyCode() == 'USD') {
return 'bi-weekly with';
} elseif(Mage::app()->getStore()->getCurrentCurrencyCode() == 'NZD') {
return 'fortnightly with';
} elseif(Mage::app()->getStore()->getCurrentCurrencyCode() == 'AUD') {
return 'fortnightly with';
}
}

public function getJsConfig()
{
return array(
'selectors' => $this->getCssSelectors(),
'template' => $this->getHtmlTemplate(),
'priceSubstitution' => '{price_here}',
'regionSpecific' => '{region_specific_text}',
'regionText' => $this->getRegionSpecificText(),
'minPriceLimit' => $this->getMinPriceLimit(),
'maxPriceLimit' => $this->getMaxPriceLimit(),
'installmentsAmount' => $this->getInstallmentsAmount(),
Expand Down
61 changes: 43 additions & 18 deletions src/app/code/community/Afterpay/Afterpay/Block/Form/Payovertime.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ class Afterpay_Afterpay_Block_Form_Payovertime extends Afterpay_Afterpay_Block_F

const CONFIG_PATH_CHECKOUT_TITLE_TEMPLATE = 'afterpay/payovertime_checkout/checkout_headline_html_template';

const CONFIG_PATH_CHECKOUT_DETAILS_TEMPLATE = 'afterpay/payovertime_checkout/checkout_details_html_template';

const CONFIG_PATH_SHOW_DETAILS = 'afterpay/payovertime_checkout/show_checkout_details';

const TEMPLATE_OPTION_DETAILS_DEFAULT = 'afterpay/form/payovertime.phtml';

const TEMPLATE_OPTION_TITLE_CUSTOM = 'afterpay/checkout/title_custom.phtml';

const TEMPLATE_OPTION_DETAILS_CUSTOM = 'afterpay/form/payovertime_custom.phtml';
Expand Down Expand Up @@ -124,17 +120,6 @@ public function getTitleTemplateId()
return self::TITLE_TEMPLATE_SELECTOR_ID;
}

public function getRegionSpecificText()
{
if(Mage::app()->getStore()->getCurrentCurrencyCode() == 'USD') {
return 'bi-weekly with';
} elseif(Mage::app()->getStore()->getCurrentCurrencyCode() == 'NZD') {
return 'fortnightly with';
} elseif(Mage::app()->getStore()->getCurrentCurrencyCode() == 'AUD') {
return 'fortnightly with';
}
}

private function _getCommonConfiguration()
{
return array(
Expand All @@ -143,8 +128,6 @@ private function _getCommonConfiguration()
'orderAmountSubstitution' => '{order_amount}',
'orderAmount' => $this->getOrderTotal(),
'orderAmountCreditUsed' => $this->getOrderTotalCreditUsed(),
'regionSpecificSubstitution' => '{region_specific_text}',
'regionText' => $this->getRegionSpecificText(),
'installmentAmountSubstitution' => '{instalment_amount}',
'installmentAmount' => $this->getInstalmentAmount(),
'installmentAmountCreditUsed' => $this->getInstalmentAmountCreditUsed(),
Expand All @@ -165,7 +148,49 @@ private function _getCommonConfiguration()

private function _getCustomDetailTemplate()
{
return Mage::getStoreConfig(self::CONFIG_PATH_CHECKOUT_DETAILS_TEMPLATE);
ob_start();
?>
<ul class="form-list">
<li class="form-alt">
<div class="instalments">
<p class="header-text">
Four interest-free payments totalling {order_amount}
</p>
<ul class="cost">
<li>{instalment_amount}</li>
<li>{instalment_amount}</li>
<li>{instalment_amount}</li>
<li>{instalment_amount_last}</li>
</ul>
<ul class="icon">
<li>
<img src="{img_circle_1}" alt="" />
</li>
<li>
<img src="{img_circle_2}" alt="" />
</li>
<li>
<img src="{img_circle_3}" alt="" />
</li>
<li>
<img src="{img_circle_4}" alt="" />
</li>
</ul>
<ul class="instalment">
<li>First instalment</li>
<li>2 weeks later</li>
<li>4 weeks later</li>
<li>6 weeks later</li>
</ul>
</div>
<div class="instalment-footer">
<p>You'll be redirected to the Afterpay website when you proceed to checkout.</p>
<a href="http://www.afterpay.com/terms/" target="_blank">Terms & Conditions</a>
</div>
</li>
</ul>
<?php
return ob_get_clean();
}

private function _getCustomTitleTemplate()
Expand Down
88 changes: 0 additions & 88 deletions src/app/code/community/Afterpay/Afterpay/Block/Modal.php

This file was deleted.

26 changes: 10 additions & 16 deletions src/app/code/community/Afterpay/Afterpay/Block/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* @method Afterpay_Afterpay_Block_Redirect setReturnUrl(string $url);
* @method Afterpay_Afterpay_Block_Redirect setRedirectJsUrl(string $url)
*/

use Afterpay_Afterpay_Model_Method_Base as Afterpay_Base;

class Afterpay_Afterpay_Block_Redirect extends Mage_Core_Block_Template
{
protected function _construct()
Expand Down Expand Up @@ -47,7 +50,7 @@ public function getReturnUrl()
*/
public function getRedirectJsUrl()
{
$apiMode = Mage::getStoreConfig('payment/afterpaypayovertime/' . Afterpay_Afterpay_Model_Method_Base::API_MODE_CONFIG_FIELD);
$apiMode = Mage::getStoreConfig('payment/afterpaypayovertime/' . Afterpay_Base::API_MODE_CONFIG_FIELD);
$settings = Afterpay_Afterpay_Model_System_Config_Source_ApiMode::getEnvironmentSettings($apiMode);

return $settings[Afterpay_Afterpay_Model_System_Config_Source_ApiMode::KEY_WEB_URL] . 'afterpay.js';
Expand All @@ -57,22 +60,13 @@ public function getRedirectJsUrl()
*/
public function getCountryCode()
{
$currencyCode = Afterpay_Afterpay_Model_System_Config_Source_ApiMode::getCurrencyCode();
if ($currencyCode == "USD") {
$country = "US";
}
else if ($currencyCode == "NZD") {
$country = "NZ";
}
else if ($currencyCode == "AUD") {
$country = "AU";
}
$countryCode = '';
$currency = Afterpay_Afterpay_Model_System_Config_Source_ApiMode::getCurrencyCode();

$countryCode = array(
"countryCode" => $country
);

if (array_key_exists($currency, Afterpay_Base::CURRENCY_PROPERTIES)){
$countryCode = Afterpay_Base::CURRENCY_PROPERTIES[$currency]['jsCountry'];
}

return $countryCode;
return array("countryCode" => $countryCode);
}
}
Loading

0 comments on commit 85402d4

Please sign in to comment.