Skip to content

Commit 613fc37

Browse files
committed
Release 1.3.7
1 parent 843591c commit 613fc37

16 files changed

+108
-19
lines changed

Model/ApiClient.php

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
use Magento\Framework\App\Config\ScopeConfigInterface;
1414
use Magento\Framework\Encryption\EncryptorInterface;
15+
use PostFinanceCheckout\Payment\Model\ApiClientHeaders;
1516

1617
/**
1718
* Service to provide PostFinance Checkout API client.
@@ -84,6 +85,8 @@ public function getApiClient()
8485
$client = new \PostFinanceCheckout\Sdk\ApiClient($userId, $this->encrypter->decrypt($applicationKey));
8586
$client->setBasePath($this->getBaseGatewayUrl() . '/api');
8687
$this->apiClient = $client;
88+
$apiClientHeaders = new ApiClientHeaders();
89+
$apiClientHeaders->addHeaders($this->apiClient);
8790
} else {
8891
throw new \PostFinanceCheckout\Payment\Model\ApiClientException(
8992
'The PostFinance Checkout API user data are incomplete.');

Model/ApiClientHeaders.php

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* PostFinance Checkout Magento 2
4+
*
5+
* This Magento 2 extension enables to process payments with PostFinance Checkout (https://postfinance.ch/en/business/products/e-commerce/postfinance-checkout-all-in-one.html/).
6+
*
7+
* @package PostFinanceCheckout_Payment
8+
* @author wallee AG (http://www.wallee.com/)
9+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Software License (ASL 2.0)
10+
*/
11+
namespace PostFinanceCheckout\Payment\Model;
12+
13+
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
use Magento\Framework\Encryption\EncryptorInterface;
15+
use PostFinanceCheckout\Sdk\ApiClient;
16+
17+
/**
18+
* Service to provide PostFinance Checkout API client.
19+
*/
20+
class ApiClientHeaders
21+
{
22+
23+
/**
24+
* @var SHOP_SYSTEM
25+
*/
26+
public const SHOP_SYSTEM = 'x-meta-shop-system';
27+
28+
/**
29+
* @var SHOP_SYSTEM_VERSION
30+
*/
31+
public const SHOP_SYSTEM_VERSION = 'x-meta-shop-system-version';
32+
33+
/**
34+
* @var SHOP_SYSTEM_AND_VERSION
35+
*/
36+
public const SHOP_SYSTEM_AND_VERSION = 'x-meta-shop-system-and-version';
37+
38+
/**
39+
* Sets the headers.
40+
*
41+
* @param \PostFinanceCheckout\Sdk\ApiClient $apiClient
42+
*/
43+
public function addHeaders(ApiClient &$apiClient)
44+
{
45+
$data = self::getDefaultData();
46+
foreach ($data as $key => $value) {
47+
$apiClient->addDefaultHeader($key, $value);
48+
}
49+
}
50+
51+
/**
52+
* @return array
53+
*/
54+
protected static function getDefaultData()
55+
{
56+
57+
// todo refactor using DI: https://www.rohanhapani.com/how-to-find-out-version-of-magento-2-programmatically/;
58+
$om = \Magento\Framework\App\ObjectManager::getInstance();
59+
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
60+
$productMetadata = $objectManager->get('\Magento\Framework\App\ProductMetadataInterface');
61+
$shop_version = $productMetadata->getVersion();
62+
63+
[$major_version, $minor_version, $rest] = explode('.', $shop_version, 3);
64+
return [
65+
self::SHOP_SYSTEM => 'magento',
66+
self::SHOP_SYSTEM_VERSION => $shop_version,
67+
self::SHOP_SYSTEM_AND_VERSION => 'magento-' . $major_version . '.' . $minor_version,
68+
];
69+
}
70+
}

Observer/CollectAmastyCheckoutLineItems.php

+18-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
use PostFinanceCheckout\Payment\Helper\Data as Helper;
2121
use PostFinanceCheckout\Sdk\Model\LineItemCreate;
2222
use PostFinanceCheckout\Sdk\Model\LineItemType;
23+
use Magento\Framework\App\Helper\Context;
24+
use Magento\Framework\Module\ModuleListInterface;
2325

2426
/**
2527
* Observer to collect the line items for the amasty checkout.
@@ -45,17 +47,25 @@ class CollectAmastyCheckoutLineItems implements ObserverInterface
4547
*/
4648
private $helper;
4749

50+
/**
51+
*
52+
* @var ModuleListInterface
53+
*/
54+
protected $_moduleList;
55+
4856
/**
4957
*
5058
* @param ObjectManagerInterface $objectManager
5159
* @param ModuleManager $moduleManager
5260
* @param Helper $helper
61+
* @param ModuleListInterface $moduleList
5362
*/
54-
public function __construct(ObjectManagerInterface $objectManager, ModuleManager $moduleManager, Helper $helper)
63+
public function __construct(ObjectManagerInterface $objectManager, ModuleManager $moduleManager, Helper $helper, ModuleListInterface $moduleList)
5564
{
5665
$this->objectManager = $objectManager;
5766
$this->moduleManager = $moduleManager;
5867
$this->helper = $helper;
68+
$this->_moduleList = $moduleList;
5969
}
6070

6171
public function execute(Observer $observer)
@@ -92,7 +102,13 @@ protected function convertAmastyCheckoutLineItems($entity)
92102
*/
93103
protected function convertGiftWrapLineItem($entity)
94104
{
95-
$feeRepository = $this->objectManager->get('Amasty\Checkout\Api\FeeRepositoryInterface');
105+
$moduleInfo = $this->_moduleList->getOne('Amasty_Checkout');
106+
107+
if (version_compare($moduleInfo['setup_version'], '4.0.0', '>=')) {
108+
$feeRepository = $this->objectManager->get('Amasty\CheckoutCore\Api\FeeRepositoryInterface');
109+
} else {
110+
$feeRepository = $this->objectManager->get('Amasty\Checkout\Api\FeeRepositoryInterface');
111+
}
96112

97113
$currency = null;
98114
$fee = null;

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This repository contains the Magento 2 extension that enables to process payment
1212

1313
## Documentation
1414

15-
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html)
15+
* [Documentation](https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html)
1616

1717

1818
## Support
@@ -30,4 +30,4 @@ We do provide special integrations for the following one step checkouts:
3030

3131
## License
3232

33-
Please see the [license file](https://github.com/pfpayments/magento-2/blob/1.3.6/LICENSE) for more information.
33+
Please see the [license file](https://github.com/pfpayments/magento-2/blob/1.3.7/LICENSE) for more information.

Setup/Patch/Data/AddData.php renamed to Setup/Patch/Data/AddSetupData.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88

99
/**
10-
* Class AddData
10+
* Class AddSetupData
1111
* @package PostFinanceCheckout\Payment\Setup\Patch\Data
1212
*/
1313

14-
class AddData implements DataPatchInterface, PatchVersionInterface
14+
class AddSetupData implements DataPatchInterface, PatchVersionInterface
1515
{
1616
private $status;
1717

@@ -52,12 +52,12 @@ public static function getDependencies(){
5252
}
5353

5454
/**
55-
* @description: Under the version number, it will run
55+
* @description: Under the version number, it will run (if new version is 1.3.5, put 1.3.6)
5656
* @return int:
5757
*/
5858

5959
public static function getVersion(){
60-
return '1.2.8';
60+
return '1.3.8';
6161
}
6262

6363
/**

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"type" : "magento2-module",
19-
"version" : "1.3.6",
19+
"version" : "1.3.7",
2020
"require" : {
2121
"php" : "~7.1.3||~7.2.0||~7.3.0||~7.4.0||~8.0||~8.1",
2222
"magento/framework" : "^102.0.0||^103.0.0",

docs/en/documentation.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ <h2>Documentation</h2> </div>
2222
</a>
2323
</li>
2424
<li>
25-
<a href="https://github.com/pfpayments/magento-2/releases/tag/1.3.6/">
25+
<a href="https://github.com/pfpayments/magento-2/releases/tag/1.3.7/">
2626
Source
2727
</a>
2828
</li>

etc/adminhtml/system.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<resource>PostFinanceCheckout_Payment::config</resource>
1919
<group id="information" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
2020
<label>Information</label>
21-
<comment><![CDATA[If you need help setting up the PostFinance Checkout extension, check out the <a href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html" target="_blank">documentation</a>.]]></comment>
21+
<comment><![CDATA[If you need help setting up the PostFinance Checkout extension, check out the <a href="https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html" target="_blank">documentation</a>.]]></comment>
2222
<field id="version" translate="label" type="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
2323
<label>Module Version</label>
2424
</field>

etc/config.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<default>
1515
<postfinancecheckout_payment>
1616
<information>
17-
<version>1.3.6</version>
17+
<version>1.3.7</version>
1818
<sdk_version>3.1.1</sdk_version>
1919
</information>
2020
<general>

etc/module.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
-->
1313
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
14-
<module name="PostFinanceCheckout_Payment" setup_version="1.3.6">
14+
<module name="PostFinanceCheckout_Payment" setup_version="1.3.7">
1515
<sequence>
1616
<module name="Magento_Sales"/>
1717
<module name="Magento_Payment"/>

i18n/de_DE.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Geschenkverpackung"
5151
"Hold Delivery","Lieferung halten"
5252
"ID required","ID erforderlich"
53-
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Falls Sie Hilfe benötigen beim Einrichten der PostFinance Checkout-Erweiterung, sehen Sie sich die <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html"" target=""_blank"">Dokumentation</a> an."
53+
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Falls Sie Hilfe benötigen beim Einrichten der PostFinance Checkout-Erweiterung, sehen Sie sich die <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html"" target=""_blank"">Dokumentation</a> an."
5454
"Inactive","Inaktiv"
5555
"Information","Informationen"
5656
"Invoice","Rechnung"

i18n/en_US.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Gift Wrap"
5151
"Hold Delivery","Hold Delivery"
5252
"ID required","ID required"
53-
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html"" target=""_blank"">documentation</a>.","If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html"" target=""_blank"">documentation</a>."
53+
"If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html"" target=""_blank"">documentation</a>.","If you need help setting up the PostFinance Checkout extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html"" target=""_blank"">documentation</a>."
5454
"Inactive","Inactive"
5555
"Information","Information"
5656
"Invoice","Invoice"

i18n/fr_CH.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Papier cadeau"
5151
"Hold Delivery","Suspendre la livraison"
5252
"ID required","Pièce d'identité requise"
53-
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension wallee, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
53+
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension wallee, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
5454
"Inactive","Inactif"
5555
"Information","Information"
5656
"Invoice","Facture"

i18n/fr_FR.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Papier cadeau"
5151
"Hold Delivery","Suspendre la livraison"
5252
"ID required","Pièce d'identité requise"
53-
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension wallee, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
53+
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Si vous avez besoin d'aide pour configurer l'extension wallee, consultez la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html"" target=""_blank"">documentation</a> an."
5454
"Inactive","Inactif"
5555
"Information","Information"
5656
"Invoice","Facture"

i18n/it_CH.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Confezione regalo"
5151
"Hold Delivery","Sospendi la consegna"
5252
"ID required","ID richiesto"
53-
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione wallee, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
53+
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione wallee, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
5454
"Inactive","Inattivo"
5555
"Information","Informazione"
5656
"Invoice","Fattura"

i18n/it_IT.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"Gift Wrap","Confezione regalo"
5151
"Hold Delivery","Sospendi la consegna"
5252
"ID required","ID richiesto"
53-
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione wallee, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.6/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
53+
"If you need help setting up the wallee extension, check out the <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html"" target=""_blank"">documentation</a>.","Se hai bisogno di aiuto per configurare l'estensione wallee, consulta la <a href=""https://plugin-documentation.postfinance-checkout.ch/pfpayments/magento-2/1.3.7/docs/en/documentation.html"" target=""_blank"">documentazione</a> an."
5454
"Inactive","Inattivo"
5555
"Information","Informazione"
5656
"Invoice","Fattura"

0 commit comments

Comments
 (0)