Skip to content

Commit 87dcf71

Browse files
authored
Merge pull request #73 from unzerdev/develop
[Release 3.3.0 - 2024-11-29]
2 parents 1bd5c4e + 6dcf99e commit 87dcf71

File tree

19 files changed

+477
-4
lines changed

19 files changed

+477
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
55

6+
## [3.3.0](https://github.com/unzerdev/magento2/compare/3.2.2..3.3.0)
7+
### Added
8+
* ApplePay V2
9+
610
## [3.2.2](https://github.com/unzerdev/magento2/compare/3.2.1..3.2.2)
711
### Fixed
812
* bank name not needed anymore for eps payment method

Model/Config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class Config extends \Magento\Payment\Gateway\Config\Config
5555
public const METHOD_BANCONTACT = 'unzer_bancontact';
5656
public const METHOD_PREPAYMENT = 'unzer_prepayment';
5757
public const METHOD_APPLEPAY = 'unzer_applepay';
58+
public const METHOD_APPLEPAYV2 = 'unzer_applepayv2';
5859
public const METHOD_GOOGLEPAY = 'unzer_googlepay';
5960
public const METHOD_TWINT = 'unzer_twint';
6061

Model/Config/Provider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class Provider implements ConfigProviderInterface
4444
Config::METHOD_BANCONTACT,
4545
Config::METHOD_PREPAYMENT,
4646
Config::METHOD_APPLEPAY,
47+
Config::METHOD_APPLEPAYV2,
4748
Config::METHOD_GOOGLEPAY,
4849
Config::METHOD_TWINT,
4950
];

Model/Method/ApplepayV2.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Unzer\PAPI\Model\Method;
5+
6+
/**
7+
* Apple Pay V2 payment method
8+
*
9+
* @link https://docs.unzer.com/
10+
*/
11+
class ApplepayV2 extends Base
12+
{
13+
/**
14+
* @inheritDoc
15+
*/
16+
public function getFrontendConfig(): array
17+
{
18+
$supportedNetworks = (string) $this->_scopeConfig->getValue('payment/unzer/applepayv2/supported_networks');
19+
$supportedNetworks = explode(',', $supportedNetworks);
20+
21+
return [
22+
'supportedNetworks' => $supportedNetworks,
23+
'merchantCapabilities' => ['supports3DS'],
24+
'label' => $this->_scopeConfig->getValue('payment/unzer_applepayv2/display_name') //label
25+
];
26+
}
27+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Unzer\PAPI\Model\Source\ApplepayV2;
5+
6+
use Magento\Framework\Data\OptionSourceInterface;
7+
8+
/**
9+
* @link https://docs.unzer.com/
10+
*/
11+
class SupportedNetworks implements OptionSourceInterface
12+
{
13+
/**
14+
* Supported Networks
15+
*
16+
* @var array
17+
*/
18+
protected static array $networks = [
19+
//'amex',
20+
//'bancomat',
21+
//'bancontact',
22+
//'cartesBancaires',
23+
//'chinaUnionPay',
24+
//'dankort',
25+
//'discover',
26+
//'eftpos',
27+
//'electron',
28+
//'elo',
29+
//'girocard',
30+
//'interac',
31+
//'jcb',
32+
//'mada',
33+
//'maestro',
34+
'masterCard',
35+
//'mir',
36+
//'privateLabel',
37+
'visa',
38+
//'vPay'
39+
];
40+
41+
/**
42+
* Return Supported Networks
43+
*
44+
* @return array
45+
*/
46+
public function toOptionArray(): array
47+
{
48+
$options = [];
49+
foreach (self::$networks as $network) {
50+
$options[] = [
51+
'value' => $network,
52+
'label' => ucfirst($network),
53+
];
54+
}
55+
return $options;
56+
}
57+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Unzer\PAPI\Model\System\Config\Backend\ApplepayV2;
5+
6+
use Exception;
7+
use Magento\Config\Model\Config\Backend\File;
8+
use Magento\Framework\App\Filesystem\DirectoryList;
9+
use Magento\Framework\Exception\FileSystemException;
10+
use Magento\Framework\Exception\LocalizedException;
11+
12+
/**
13+
* @link https://docs.unzer.com/
14+
*/
15+
class Upload extends File
16+
{
17+
/**
18+
* Retrieve upload directory path
19+
*
20+
* @param string $uploadDir
21+
* @return string
22+
* @throws FileSystemException
23+
*/
24+
protected function getUploadDirPath($uploadDir): string
25+
{
26+
$this->_mediaDirectory = $this->_filesystem->getDirectoryWrite(DirectoryList::PUB);
27+
28+
$path = $this->_mediaDirectory->getAbsolutePath($uploadDir);
29+
30+
if (!$this->_mediaDirectory->isDirectory($path)) {
31+
$this->_mediaDirectory->create($path);
32+
}
33+
34+
return $path;
35+
}
36+
37+
/**
38+
* Save uploaded file before saving config value
39+
*
40+
* @return $this
41+
* @throws LocalizedException
42+
*/
43+
public function beforeSave(): Upload
44+
{
45+
$value = $this->getValue();
46+
$file = $this->getFileData();
47+
48+
if (!empty($file)) {
49+
$uploadDir = $this->getUploadDirPath('.well-known/');
50+
try {
51+
$uploader = $this->_uploaderFactory->create(['fileId' => $file]);
52+
$uploader->setAllowRenameFiles(false);
53+
$uploader->addValidateCallback('size', $this, 'validateMaxSize');
54+
$uploader->setFilesDispersion(false);
55+
56+
$domainAssocFileName = 'apple-developer-merchantid-domain-association';
57+
58+
$result = $uploader->save($uploadDir, $domainAssocFileName);
59+
} catch (Exception $e) {
60+
throw new LocalizedException(__('%1', $e->getMessage()));
61+
}
62+
if ($result !== false) {
63+
if ($this->_addWhetherScopeInfo()) {
64+
$domainAssocFileName = $this->_prependScopeInfo($domainAssocFileName);
65+
}
66+
$this->setValue($domainAssocFileName);
67+
}
68+
} else {
69+
if (is_array($value) && !empty($value['delete'])) {
70+
$this->setValue('');
71+
} elseif (is_array($value) && !empty($value['value'])) {
72+
$this->setValue($value['value']);
73+
} else {
74+
$this->unsValue();
75+
}
76+
}
77+
78+
return $this;
79+
}
80+
}

etc/adminhtml/system.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<include path="Unzer_PAPI::system/bancontact.xml"/>
7171
<include path="Unzer_PAPI::system/prepayment.xml"/>
7272
<include path="Unzer_PAPI::system/applepay.xml"/>
73+
<include path="Unzer_PAPI::system/applepayv2.xml"/>
7374
<include path="Unzer_PAPI::system/googlepay.xml"/>
7475
<include path="Unzer_PAPI::system/twint.xml"/>
7576
</group>

etc/adminhtml/system/applepay.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
<group id="applepay" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1"
44
showInStore="1">
55
<label>UNZER_APPLEPAY</label>
6+
<field id="applepay_info_text" type="note" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
7+
<comment>
8+
<![CDATA[
9+
<div style="background-color: #d4edda; padding: 15px; border-radius: 4px;">
10+
<span style="content: `\e60e`;"></span>
11+
<h3><strong>Existing merchants:</strong></h3>
12+
<p>We have updated our integration with Apple Pay, but since you already have it set up, you don't need to do anything just now.</p>
13+
<p>However, when your Apple Pay certificates are about to expire, you can change to the new integration.</p>
14+
<p>You can of course change to the new integration now, if you want, and then you don't have to worry about expiring certificates, changing integration, etc. in the future.</p>
15+
</br>
16+
<h3><strong>Existing and new both:</strong></h3>
17+
<p>Before you activate Apple Pay, please make sure you have read our <a href="https://docs.unzer.com/payment-methods/applepay/applepay-prerequisites/#prerequisites-for-accepting-apple-pay-transactions" target="_blank">checklist</a>.</p>
18+
</div>
19+
]]>
20+
</comment>
21+
</field>
622
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1"
723
showInWebsite="1" showInStore="1">
824
<label>Enabled</label>

etc/adminhtml/system/applepayv2.xml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0"?>
2+
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
3+
<group id="applepayv2" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1"
4+
showInStore="1">
5+
<label>UNZER_APPLEPAYV2</label>
6+
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1"
7+
showInWebsite="1" showInStore="1">
8+
<label>Enabled</label>
9+
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
10+
<config_path>payment/unzer_applepayv2/active</config_path>
11+
</field>
12+
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1"
13+
showInStore="1">
14+
<label>Title</label>
15+
<config_path>payment/unzer_applepayv2/title</config_path>
16+
</field>
17+
<field id="order_payment_action" translate="label" type="select" sortOrder="25" showInDefault="1"
18+
showInWebsite="1" showInStore="1">
19+
<label>Booking Mode</label>
20+
<config_path>payment/unzer_applepayv2/order_payment_action</config_path>
21+
<source_model>Unzer\PAPI\Model\System\Config\Source\PaymentAction</source_model>
22+
</field>
23+
<field id="min_order_total" translate="label" type="text" sortOrder="27" showInDefault="1"
24+
showInWebsite="1" showInStore="1">
25+
<label>Minimum Order Total</label>
26+
<config_path>payment/unzer_applepayv2/min_order_total</config_path>
27+
</field>
28+
<field id="max_order_total" translate="label" type="text" sortOrder="28" showInDefault="1"
29+
showInWebsite="1" showInStore="1">
30+
<label>Maximum Order Total</label>
31+
<config_path>payment/unzer_applepayv2/max_order_total</config_path>
32+
<comment>Insert 0 to disable limit.</comment>
33+
</field>
34+
<field id="supported_networks" translate="label" type="multiselect" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
35+
<label>Supported Networks</label>
36+
<source_model>Unzer\PAPI\Model\Source\ApplepayV2\SupportedNetworks</source_model>
37+
</field>
38+
<field id="apple_merchantid_association_upload" translate="label" type="Magento\Config\Block\System\Config\Form\Field\File" sortOrder="56" showInDefault="1" showInWebsite="1" showInStore="1">
39+
<label>Apple Merchant ID Domain Association</label>
40+
<backend_model>Unzer\PAPI\Model\System\Config\Backend\ApplepayV2\Upload</backend_model>
41+
</field>
42+
<field id="sort_order" translate="label" type="text" sortOrder="100" showInDefault="1"
43+
showInWebsite="1" showInStore="1">
44+
<label>Sort Order</label>
45+
<config_path>payment/unzer_applepayv2/sort_order</config_path>
46+
</field>
47+
</group>
48+
</include>

etc/config.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,22 @@
402402
<can_use_internal>0</can_use_internal>
403403
<model>Unzer\PAPI\Model\Method\Applepay</model>
404404
</unzer_applepay>
405+
<unzer_applepayv2>
406+
<active>0</active>
407+
<payment_action>order</payment_action>
408+
<order_payment_action>authorize_capture</order_payment_action>
409+
<title><![CDATA[Apple Pay]]></title>
410+
<allowspecific>0</allowspecific>
411+
<min_order_total>0</min_order_total>
412+
<max_order_total>0</max_order_total>
413+
<can_authorize>1</can_authorize>
414+
<can_capture>1</can_capture>
415+
<can_order>1</can_order>
416+
<can_void>1</can_void>
417+
<can_use_checkout>1</can_use_checkout>
418+
<can_use_internal>0</can_use_internal>
419+
<model>Unzer\PAPI\Model\Method\ApplepayV2</model>
420+
</unzer_applepayv2>
405421
<unzer_googlepay>
406422
<active>0</active>
407423
<payment_action>order</payment_action>

etc/di.xml

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,6 @@
13301330
<argument name="commandPool" xsi:type="object">UnzerCaptureCommandPool</argument>
13311331
</arguments>
13321332
</type>
1333-
13341333
<!-- Define types for Apple Pay payment method -->
13351334
<virtualType name="UnzerApplepayConfig" type="Unzer\PAPI\Model\Config">
13361335
<arguments>
@@ -1382,6 +1381,57 @@
13821381
</arguments>
13831382
</type>
13841383

1384+
<!-- Define types for Apple Pay V2payment method-->
1385+
<virtualType name="UnzerApplepayV2Config" type="Unzer\PAPI\Model\Config">
1386+
<arguments>
1387+
<argument name="methodCode" xsi:type="const">Unzer\PAPI\Model\Config::METHOD_APPLEPAYV2</argument>
1388+
</arguments>
1389+
</virtualType>
1390+
1391+
<virtualType name="UnzerApplepayV2ConfigValueHandler" type="Magento\Payment\Gateway\Config\ConfigValueHandler">
1392+
<arguments>
1393+
<argument name="configInterface" xsi:type="object">UnzerApplepayV2Config</argument>
1394+
</arguments>
1395+
</virtualType>
1396+
1397+
<virtualType name="UnzerApplepayV2ValueHandlerPool" type="Magento\Payment\Gateway\Config\ValueHandlerPool">
1398+
<arguments>
1399+
<argument name="handlers" xsi:type="array">
1400+
<item name="default" xsi:type="string">UnzerApplepayV2ConfigValueHandler</item>
1401+
<item name="can_cancel" xsi:type="string">Unzer\PAPI\Model\Config\CanCancelHandler</item>
1402+
<item name="can_refund" xsi:type="string">Unzer\PAPI\Model\Config\CanRefundHandler</item>
1403+
<item name="can_refund_partial_per_invoice" xsi:type="string">Unzer\PAPI\Model\Config\CanRefundHandler
1404+
</item>
1405+
<item name="can_void" xsi:type="string">Unzer\PAPI\Model\Config\CanVoidHandler</item>
1406+
</argument>
1407+
</arguments>
1408+
</virtualType>
1409+
1410+
<virtualType name="UnzerApplepayV2ValidatorCountry" type="Unzer\PAPI\Model\Validator\CountryRestrictionValidator">
1411+
<arguments>
1412+
<argument name="config" xsi:type="object">UnzerApplepayV2Config</argument>
1413+
</arguments>
1414+
</virtualType>
1415+
1416+
<virtualType name="UnzerApplepayV2ValidatorPool" type="Magento\Payment\Gateway\Validator\ValidatorPool">
1417+
<arguments>
1418+
<argument name="validators" xsi:type="array">
1419+
<item name="country" xsi:type="string">UnzerApplepayV2ValidatorCountry</item>
1420+
</argument>
1421+
</arguments>
1422+
</virtualType>
1423+
1424+
<type name="Unzer\PAPI\Model\Method\ApplepayV2">
1425+
<arguments>
1426+
<argument name="code" xsi:type="const">Unzer\PAPI\Model\Config::METHOD_APPLEPAYV2</argument>
1427+
<argument name="formBlockType" xsi:type="string">Magento\Payment\Block\Form</argument>
1428+
<argument name="infoBlockType" xsi:type="string">Magento\Payment\Block\Info</argument>
1429+
<argument name="valueHandlerPool" xsi:type="object">UnzerApplepayV2ValueHandlerPool</argument>
1430+
<argument name="validatorPool" xsi:type="object">UnzerApplepayV2ValidatorPool</argument>
1431+
<argument name="commandPool" xsi:type="object">UnzerAuthorizeAndCaptureCommandPool</argument>
1432+
</arguments>
1433+
</type>
1434+
13851435
<!-- Define types for Google Pay payment method-->
13861436
<virtualType name="UnzerGooglepayConfig" type="Unzer\PAPI\Model\Config">
13871437
<arguments>

etc/events.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
<event name="payment_method_assign_data_unzer_applepay">
6767
<observer name="unzer_applepay_data_assign" instance="Unzer\PAPI\Model\Method\Observer\BaseDataAssignObserver" />
6868
</event>
69+
<event name="payment_method_assign_data_unzer_applepayv2">
70+
<observer name="unzer_applepayv2_data_assign" instance="Unzer\PAPI\Model\Method\Observer\BaseDataAssignObserver" />
71+
</event>
6972
<event name="payment_method_assign_data_unzer_googlepay">
7073
<observer name="unzer_googlepay_data_assign" instance="Unzer\PAPI\Model\Method\Observer\BaseDataAssignObserver" />
7174
</event>

etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
4-
<module name="Unzer_PAPI" setup_version="3.2.2">
4+
<module name="Unzer_PAPI" setup_version="3.2.3">
55
<sequence>
66
<module name="Magento_Checkout"/>
77
<module name="Magento_Config" />

0 commit comments

Comments
 (0)