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

Commit 85402d4

Browse files
Release version 3.1.0
1 parent 6eb3efa commit 85402d4

File tree

30 files changed

+197
-431
lines changed

30 files changed

+197
-431
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Afterpay Magento 1 Extension Changelog
22

3+
## Version 3.1.0
4+
5+
_Wed 2 Sep 2020 (AEST)_
6+
7+
### Supported Editions & Versions
8+
9+
- Magento Community Edition (CE) version 1.7 and later.
10+
- Magento Enterprise Edition (EE) version 1.13 and later.
11+
12+
### Highlights
13+
14+
- Added support for Canadian merchants/consumers and CAD.
15+
- Standardized modal content by using Afterpay Global JS Library.
16+
- Fixed a defect where API Mode could be read from default scope instead of website scope.
17+
18+
---
19+
320
## Version 3.0.5
421

522
_Wed 17 Jun 2020 (AEST)_

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Magento can be installed in any folder on your server. For the purposes of this
1313

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

16-
1. **Website Currency must be set to AUD, NZD or USD**
16+
1. **Website Currency must be set to AUD, NZD, USD or CAD**
1717

1818
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.
1919

src/app/code/community/Afterpay/Afterpay/Block/Banner.php

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* @author Afterpay
66
* @copyright 2016-2018 Afterpay https://www.afterpay.com
77
*/
8+
9+
use Afterpay_Afterpay_Model_Method_Base as Afterpay_Base;
10+
811
class Afterpay_Afterpay_Block_Banner extends Mage_Core_Block_Template
912
{
1013
const XML_CONFIG_PREFIX = 'afterpay/banner/';
@@ -17,26 +20,6 @@ public function isEnabled()
1720
return Mage::getStoreConfigFlag(self::XML_CONFIG_PREFIX . 'enabled');
1821
}
1922

20-
/**
21-
* @return array
22-
*/
23-
public function getCssSelector()
24-
{
25-
$selectors = Mage::getStoreConfig(self::XML_CONFIG_PREFIX . 'banner_block_selector');
26-
return explode("\n", $selectors);
27-
}
28-
29-
/**
30-
* @return array
31-
*/
32-
public function getJsConfig()
33-
{
34-
return array(
35-
'selector' => $this->getCssSelector(),
36-
'className' => 'afterpay-banner'
37-
);
38-
}
39-
4023
/**
4124
* @param string $scriptUrl
4225
* @param bool $addModuleVersion
@@ -61,4 +44,30 @@ public function getModuleVersion()
6144
$moduleConfig = Mage::getConfig()->getModuleConfig($this->getModuleName());
6245
return (string)$moduleConfig->version;
6346
}
47+
48+
public function getJsLibrary()
49+
{
50+
$apiMode = Mage::getStoreConfig('payment/afterpaypayovertime/' . Afterpay_Base::API_MODE_CONFIG_FIELD);
51+
52+
if ($apiMode == 'production') {
53+
$url = 'https://js.afterpay.com/afterpay-1.x.js';
54+
} else {
55+
$url = 'https://js.sandbox.afterpay.com/afterpay-1.x.js';
56+
}
57+
58+
return $url;
59+
}
60+
61+
public function getJsLocale()
62+
{
63+
$locale = 'en_AU';
64+
$currency = Mage::app()->getStore()->getCurrentCurrencyCode();
65+
66+
if (array_key_exists($currency, Afterpay_Base::CURRENCY_PROPERTIES)){
67+
$locale = Afterpay_Base::CURRENCY_PROPERTIES[$currency]['jsLocale'];
68+
}
69+
70+
return $locale;
71+
}
72+
6473
}

src/app/code/community/Afterpay/Afterpay/Block/Catalog/Installments.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,16 @@ public function getCssSelectors()
4343

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

5558
public function getMinPriceLimit()
@@ -87,25 +90,12 @@ public function getInstallmentsAmount()
8790
return (int)Mage::getStoreConfig('payment/afterpaypayovertime/installments_amount');
8891
}
8992

90-
public function getRegionSpecificText()
91-
{
92-
if(Mage::app()->getStore()->getCurrentCurrencyCode() == 'USD') {
93-
return 'bi-weekly with';
94-
} elseif(Mage::app()->getStore()->getCurrentCurrencyCode() == 'NZD') {
95-
return 'fortnightly with';
96-
} elseif(Mage::app()->getStore()->getCurrentCurrencyCode() == 'AUD') {
97-
return 'fortnightly with';
98-
}
99-
}
100-
10193
public function getJsConfig()
10294
{
10395
return array(
10496
'selectors' => $this->getCssSelectors(),
10597
'template' => $this->getHtmlTemplate(),
10698
'priceSubstitution' => '{price_here}',
107-
'regionSpecific' => '{region_specific_text}',
108-
'regionText' => $this->getRegionSpecificText(),
10999
'minPriceLimit' => $this->getMinPriceLimit(),
110100
'maxPriceLimit' => $this->getMaxPriceLimit(),
111101
'installmentsAmount' => $this->getInstallmentsAmount(),

src/app/code/community/Afterpay/Afterpay/Block/Form/Payovertime.php

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@ class Afterpay_Afterpay_Block_Form_Payovertime extends Afterpay_Afterpay_Block_F
1313

1414
const CONFIG_PATH_CHECKOUT_TITLE_TEMPLATE = 'afterpay/payovertime_checkout/checkout_headline_html_template';
1515

16-
const CONFIG_PATH_CHECKOUT_DETAILS_TEMPLATE = 'afterpay/payovertime_checkout/checkout_details_html_template';
17-
1816
const CONFIG_PATH_SHOW_DETAILS = 'afterpay/payovertime_checkout/show_checkout_details';
1917

20-
const TEMPLATE_OPTION_DETAILS_DEFAULT = 'afterpay/form/payovertime.phtml';
21-
2218
const TEMPLATE_OPTION_TITLE_CUSTOM = 'afterpay/checkout/title_custom.phtml';
2319

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

127-
public function getRegionSpecificText()
128-
{
129-
if(Mage::app()->getStore()->getCurrentCurrencyCode() == 'USD') {
130-
return 'bi-weekly with';
131-
} elseif(Mage::app()->getStore()->getCurrentCurrencyCode() == 'NZD') {
132-
return 'fortnightly with';
133-
} elseif(Mage::app()->getStore()->getCurrentCurrencyCode() == 'AUD') {
134-
return 'fortnightly with';
135-
}
136-
}
137-
138123
private function _getCommonConfiguration()
139124
{
140125
return array(
@@ -143,8 +128,6 @@ private function _getCommonConfiguration()
143128
'orderAmountSubstitution' => '{order_amount}',
144129
'orderAmount' => $this->getOrderTotal(),
145130
'orderAmountCreditUsed' => $this->getOrderTotalCreditUsed(),
146-
'regionSpecificSubstitution' => '{region_specific_text}',
147-
'regionText' => $this->getRegionSpecificText(),
148131
'installmentAmountSubstitution' => '{instalment_amount}',
149132
'installmentAmount' => $this->getInstalmentAmount(),
150133
'installmentAmountCreditUsed' => $this->getInstalmentAmountCreditUsed(),
@@ -165,7 +148,49 @@ private function _getCommonConfiguration()
165148

166149
private function _getCustomDetailTemplate()
167150
{
168-
return Mage::getStoreConfig(self::CONFIG_PATH_CHECKOUT_DETAILS_TEMPLATE);
151+
ob_start();
152+
?>
153+
<ul class="form-list">
154+
<li class="form-alt">
155+
<div class="instalments">
156+
<p class="header-text">
157+
Four interest-free payments totalling {order_amount}
158+
</p>
159+
<ul class="cost">
160+
<li>{instalment_amount}</li>
161+
<li>{instalment_amount}</li>
162+
<li>{instalment_amount}</li>
163+
<li>{instalment_amount_last}</li>
164+
</ul>
165+
<ul class="icon">
166+
<li>
167+
<img src="{img_circle_1}" alt="" />
168+
</li>
169+
<li>
170+
<img src="{img_circle_2}" alt="" />
171+
</li>
172+
<li>
173+
<img src="{img_circle_3}" alt="" />
174+
</li>
175+
<li>
176+
<img src="{img_circle_4}" alt="" />
177+
</li>
178+
</ul>
179+
<ul class="instalment">
180+
<li>First instalment</li>
181+
<li>2 weeks later</li>
182+
<li>4 weeks later</li>
183+
<li>6 weeks later</li>
184+
</ul>
185+
</div>
186+
<div class="instalment-footer">
187+
<p>You'll be redirected to the Afterpay website when you proceed to checkout.</p>
188+
<a href="http://www.afterpay.com/terms/" target="_blank">Terms & Conditions</a>
189+
</div>
190+
</li>
191+
</ul>
192+
<?php
193+
return ob_get_clean();
169194
}
170195

171196
private function _getCustomTitleTemplate()

src/app/code/community/Afterpay/Afterpay/Block/Modal.php

Lines changed: 0 additions & 88 deletions
This file was deleted.

src/app/code/community/Afterpay/Afterpay/Block/Redirect.php

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
* @method Afterpay_Afterpay_Block_Redirect setReturnUrl(string $url);
1717
* @method Afterpay_Afterpay_Block_Redirect setRedirectJsUrl(string $url)
1818
*/
19+
20+
use Afterpay_Afterpay_Model_Method_Base as Afterpay_Base;
21+
1922
class Afterpay_Afterpay_Block_Redirect extends Mage_Core_Block_Template
2023
{
2124
protected function _construct()
@@ -47,7 +50,7 @@ public function getReturnUrl()
4750
*/
4851
public function getRedirectJsUrl()
4952
{
50-
$apiMode = Mage::getStoreConfig('payment/afterpaypayovertime/' . Afterpay_Afterpay_Model_Method_Base::API_MODE_CONFIG_FIELD);
53+
$apiMode = Mage::getStoreConfig('payment/afterpaypayovertime/' . Afterpay_Base::API_MODE_CONFIG_FIELD);
5154
$settings = Afterpay_Afterpay_Model_System_Config_Source_ApiMode::getEnvironmentSettings($apiMode);
5255

5356
return $settings[Afterpay_Afterpay_Model_System_Config_Source_ApiMode::KEY_WEB_URL] . 'afterpay.js';
@@ -57,22 +60,13 @@ public function getRedirectJsUrl()
5760
*/
5861
public function getCountryCode()
5962
{
60-
$currencyCode = Afterpay_Afterpay_Model_System_Config_Source_ApiMode::getCurrencyCode();
61-
if ($currencyCode == "USD") {
62-
$country = "US";
63-
}
64-
else if ($currencyCode == "NZD") {
65-
$country = "NZ";
66-
}
67-
else if ($currencyCode == "AUD") {
68-
$country = "AU";
69-
}
63+
$countryCode = '';
64+
$currency = Afterpay_Afterpay_Model_System_Config_Source_ApiMode::getCurrencyCode();
7065

71-
$countryCode = array(
72-
"countryCode" => $country
73-
);
74-
66+
if (array_key_exists($currency, Afterpay_Base::CURRENCY_PROPERTIES)){
67+
$countryCode = Afterpay_Base::CURRENCY_PROPERTIES[$currency]['jsCountry'];
68+
}
7569

76-
return $countryCode;
70+
return array("countryCode" => $countryCode);
7771
}
7872
}

0 commit comments

Comments
 (0)