Skip to content

Commit 751228c

Browse files
Merge pull request #121 from Paazl/release/1.19.0
Release/1.19.0
2 parents e9f0b2e + 2d358bd commit 751228c

File tree

24 files changed

+150
-91
lines changed

24 files changed

+150
-91
lines changed

.github/workflows/linting.yml

+15-11
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,24 @@ jobs:
55
php-74:
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: StephaneBour/[email protected]
9-
with:
10-
dir: './'
8+
- uses: prestashop/github-action-php-lint/[email protected]
119

12-
php-80:
10+
php-81:
1311
runs-on: ubuntu-latest
1412
steps:
15-
- uses: StephaneBour/[email protected]
16-
with:
17-
dir: './'
13+
- uses: prestashop/github-action-php-lint/[email protected]
1814

19-
php-81:
15+
php-82:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: prestashop/github-action-php-lint/[email protected]
19+
20+
php-83:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: prestashop/github-action-php-lint/[email protected]
24+
25+
php-84:
2026
runs-on: ubuntu-latest
2127
steps:
22-
- uses: StephaneBour/[email protected]
23-
with:
24-
dir: './'
28+
- uses: prestashop/github-action-php-lint/[email protected]

.github/workflows/setup-di-compile.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ jobs:
1212
MAGENTO_VERSION: 2.4.4
1313
- PHP_VERSION: php82-fpm
1414
MAGENTO_VERSION: 2.4.6
15+
- PHP_VERSION: php83-fpm
16+
MAGENTO_VERSION: 2.4.7
17+
- PHP_VERSION: php84-fpm
18+
MAGENTO_VERSION: 2.4.8
1519
runs-on: ubuntu-latest
1620
steps:
1721
- uses: actions/checkout@v1
@@ -29,4 +33,4 @@ jobs:
2933
run: docker exec magento-project-community-edition composer require paazl/magento2-checkout-widget:@dev --no-plugins
3034

3135
- name: Run setup:di:compile
32-
run: docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile"
36+
run: docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile"

.github/workflows/templates/docker-compose.yml

-18
This file was deleted.

Api/Data/Quote/QuoteReferenceInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,5 @@ public function getTokenExpiresAt();
7979
*
8080
* @return bool
8181
*/
82-
public function isTokenExpired(\DateTime $now = null);
82+
public function isTokenExpired(?\DateTime $now = null);
8383
}

GraphQL/Resolver/ConfigurationResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function __construct(
5151
$this->quoteIdMaskResource = $quoteIdMaskResource;
5252
}
5353

54-
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
54+
public function resolve(Field $field, $context, ResolveInfo $info, ?array $value = null, ?array $args = null)
5555
{
5656
if (!isset($args['cart_id']) || empty($args['cart_id'])) {
5757
throw new GraphQlInputException(__('"cart_id" is required'));

Logger/PaazlHandler.php

+2-13
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,17 @@
11
<?php
22
/**
3-
* Copyright © 2019 Paazl. All rights reserved.
3+
* Copyright © Paazl. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Paazl\CheckoutWidget\Logger;
89

910
use Monolog\Logger;
1011
use Magento\Framework\Logger\Handler\Base;
1112

12-
/**
13-
* Class PaazlHandler
14-
*
15-
* @package Paazl\CheckoutWidget\Logger
16-
*/
1713
class PaazlHandler extends Base
1814
{
19-
20-
/**
21-
* @var int
22-
*/
2315
protected $loggerType = Logger::DEBUG;
24-
/**
25-
* @var string
26-
*/
2716
protected $fileName = '/var/log/paazl.log';
2817
}

Logger/PaazlLogger.php

+10-30
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,27 @@
88
namespace Paazl\CheckoutWidget\Logger;
99

1010
use Magento\Framework\Serialize\Serializer\Json;
11-
use Monolog\Logger;
11+
use Monolog\Logger as MonologLogger;
1212

13-
/**
14-
* DebugLogger logger class
15-
*/
16-
class PaazlLogger extends Logger
13+
class PaazlLogger
1714
{
15+
private MonologLogger $logger;
16+
private Json $json;
1817

19-
/**
20-
* @var Json
21-
*/
22-
private $json;
23-
24-
/**
25-
* DebugLogger constructor.
26-
*
27-
* @param Json $json
28-
* @param string $name
29-
* @param array $handlers
30-
* @param array $processors
31-
*/
3218
public function __construct(
33-
Json $json,
34-
string $name,
35-
array $handlers = [],
36-
array $processors = []
19+
MonologLogger $logger,
20+
Json $json
3721
) {
22+
$this->logger = $logger;
3823
$this->json = $json;
39-
parent::__construct($name, $handlers, $processors);
4024
}
4125

42-
/**
43-
* @param string $type
44-
* @param mixed $data
45-
*/
46-
public function add($type, $data)
26+
public function add(string $type, $data): void
4727
{
4828
if (is_array($data) || is_object($data)) {
49-
$this->addRecord(static::INFO, $type . ': ' . $this->json->serialize($data));
29+
$this->logger->info( $type . ': ' . $this->json->serialize($data));
5030
} else {
51-
$this->addRecord(static::INFO, $type . ': ' . $data);
31+
$this->logger->info( $type . ': ' . $data);
5232
}
5333
}
5434
}

Model/Admin/Order/Create/PaazlConfigProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function getConfig()
7878
$config['googleMapKey'] = $this->config->getGoogleMapKey($storeId);
7979
$config['widgetConfig'] = $this->widgetConfigProvider->getConfig();
8080
$config['mode'] = $this->config->isProductionApiMode($storeId) ? 'live' : 'test';
81+
$config['version'] = $this->config->getApiVersion($storeId);
8182

8283
if (empty($config['widgetConfig']['token'])) {
8384
// We were unable to obtain a token - enabling other methods if they're available

Model/Api/ApiException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ApiException extends \Exception
2020
public function __construct(
2121
$message = "",
2222
$code = 0,
23-
Throwable $previous = null,
23+
?Throwable $previous = null,
2424
$response = false
2525
) {
2626
if ($response) {

Model/Api/UrlProviderFactory.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public function __construct(
4646
*/
4747
public function create($storeId = null): UrlProvider
4848
{
49-
return $this->objectManager->create(UrlProvider::class, ['mode' => $this->config->getApiMode($storeId)]);
49+
return $this->objectManager->create(
50+
UrlProvider::class,
51+
[
52+
'mode' => $this->config->getApiMode($storeId),
53+
'version' => $this->config->getApiVersion($storeId)
54+
]
55+
);
5056
}
5157
}

Model/Checkout/PaazlConfigProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public function getConfig()
7272
$config['googleMapKey'] = $this->config->getGoogleMapKey();
7373
$config['widgetConfig'] = $this->widgetConfigProvider->getConfig();
7474
$config['mode'] = $this->config->isProductionApiMode() ? 'live' : 'test';
75+
$config['version'] = $this->config->getApiVersion();
7576
$config['showOnFirstLoad'] = $this->config->showWidgetOnFirstLoad();
7677
$config['useLocalCopyOfWidgetJs'] = $this->config->isUseLocalCopyOfWidgetJs();
7778

Model/Checkout/WidgetConfigProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public function getQuote()
258258
* @param Quote|null $quote
259259
* @return $this
260260
*/
261-
public function setQuote(Quote $quote = null)
261+
public function setQuote(?Quote $quote = null)
262262
{
263263
$this->quote = $quote;
264264
return $this;

Model/Config.php

+16
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Store\Model\Store;
1212
use Paazl\CheckoutWidget\Model\Carrier\Paazlshipping;
1313
use Paazl\CheckoutWidget\Model\System\Config\Source\ApiMode;
14+
use Paazl\CheckoutWidget\Model\System\Config\Source\ApiVersion;
1415

1516
/**
1617
* Class Config
@@ -120,6 +121,21 @@ public function getApiMode($store = null)
120121
return (int)$mode;
121122
}
122123

124+
/**
125+
* @param null|Store|int|string $store
126+
*
127+
* @return string
128+
*/
129+
public function getApiVersion($store = null)
130+
{
131+
$mode = $this->getValue(self::API_CONFIG_PATH . '/api_version', $store);
132+
if ($mode != ApiVersion::VERSION_STABLE) {
133+
$mode = ApiVersion::VERSION_LATEST;
134+
}
135+
136+
return $mode;
137+
}
138+
123139
/**
124140
* @param null|Store|int|string $store
125141
*

Model/Quote/QuoteReference.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function getTokenExpiresAt()
103103
/**
104104
* @inheritDoc
105105
*/
106-
public function isTokenExpired(\DateTime $now = null)
106+
public function isTokenExpired(?\DateTime $now = null)
107107
{
108108
$result = true;
109109
$expiresAt = $this->getTokenExpiresAt();
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright © Paazl. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Paazl\CheckoutWidget\Model\System\Config\Source;
8+
9+
use Magento\Framework\Option\ArrayInterface;
10+
11+
/**
12+
* Class ApiMode
13+
*
14+
* @package Paazl\CheckoutWidget\Model\System\Config\Source
15+
*/
16+
class ApiVersion implements ArrayInterface
17+
{
18+
19+
public const VERSION_STABLE = 'stable';
20+
public const VERSION_LATEST = 'latest';
21+
22+
/**
23+
* @var array
24+
*/
25+
public $options;
26+
27+
/**
28+
* @return array
29+
*/
30+
public function toOptionArray()
31+
{
32+
if (!$this->options) {
33+
$this->options = [
34+
['value' => self::VERSION_STABLE, 'label' => __('Stable')],
35+
['value' => self::VERSION_LATEST, 'label' => __('Latest')]
36+
];
37+
}
38+
39+
return $this->options;
40+
}
41+
}

Plugin/ExcludeFromMinification.php

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public function afterGetExcludes(Minification $subject, array $result, $contentT
3131
$result[] = 'Paazl_CheckoutWidget/js/checkout';
3232
$result[] = 'https://widget-acc.paazl.com/v1/checkout.js';
3333
$result[] = 'https://widget.paazl.com/v1/checkout.js';
34+
$result[] = 'https://widget-acc.paazl.com/v1/stable/checkout.js';
35+
$result[] = 'https://widget-acc.paazl.com/v1/latest/checkout.js';
36+
$result[] = 'https://widget.paazl.com/v1/stable/checkout.js';
37+
$result[] = 'https://widget.paazl.com/v1/latest/checkout.js';
3438
}
3539

3640
return $result;

Plugin/Quote/CartManagementPlugin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(
5858
public function beforePlaceOrder(
5959
CartManagementInterface $subject,
6060
$cartId,
61-
PaymentInterface $paymentMethod = null
61+
?PaymentInterface $paymentMethod = null
6262
) {
6363
$quote = $this->quoteRepository->getActive($cartId);
6464
if ($quote->getIsVirtual()) {

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "paazl/magento2-checkout-widget",
33
"description": "Paazl checkoutWidget for Magento 2",
44
"type": "magento2-module",
5-
"version": "1.18.0",
5+
"version": "1.19.0",
66
"keywords": [
77
"Paazl",
88
"Magento 2",

etc/adminhtml/system.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@
3535
<field id="api_modus" translate="label" type="select" sortOrder="13" showInDefault="1" showInWebsite="1" showInStore="1">
3636
<label>Environment</label>
3737
<source_model>Paazl\CheckoutWidget\Model\System\Config\Source\ApiMode</source_model>
38-
<comment>Choose whether you want to use the Paazl Checkout Widget in Paazl's staging or production environment.</comment>
38+
<comment>Select the Paazl Widget invironment to use: Staging or Production.</comment>
39+
</field>
40+
<field id="api_version" translate="label" type="select" sortOrder="14" showInDefault="1" showInWebsite="1" showInStore="1">
41+
<label>Version</label>
42+
<source_model>Paazl\CheckoutWidget\Model\System\Config\Source\ApiVersion</source_model>
43+
<comment>Select the Paazl Widget version to use: Stable or Latest.</comment>
3944
</field>
4045
<field id="heading_widget" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
4146
<label>Widget</label>

etc/config.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
<default>
99
<carriers>
1010
<paazlshipping>
11-
<version>v1.18.0</version>
11+
<version>v1.19.0</version>
1212
<active>0</active>
1313
<sallowspecific>0</sallowspecific>
1414
<price>0</price>
1515
<api_key backend_model="Magento\Config\Model\Config\Backend\Encrypted" />
1616
<api_secret backend_model="Magento\Config\Model\Config\Backend\Encrypted" />
17+
<api_version>stable</api_version>
1718
<sync_method>0</sync_method>
1819
<api_timeout>300</api_timeout>
1920
<model>Paazl\CheckoutWidget\Model\Carrier\Paazlshipping</model>

etc/di.xml

+7-8
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,17 @@
3737
<preference for="Magento\Framework\HTTP\Client\Curl"
3838
type="Paazl\CheckoutWidget\Model\Api\CurlExtra"/>
3939

40-
<type name="Paazl\CheckoutWidget\Logger\PaazlHandler">
40+
<virtualType name="PaazlDebugMonolog" type="Monolog\Logger">
4141
<arguments>
42-
<argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
42+
<argument name="name" xsi:type="string">PaazlDebug</argument>
43+
<argument name="handlers" xsi:type="array">
44+
<item name="debug" xsi:type="object">Paazl\CheckoutWidget\Logger\PaazlHandler</item>
45+
</argument>
4346
</arguments>
44-
</type>
45-
47+
</virtualType>
4648
<type name="Paazl\CheckoutWidget\Logger\PaazlLogger">
4749
<arguments>
48-
<argument name="name" xsi:type="string">Magento2</argument>
49-
<argument name="handlers" xsi:type="array">
50-
<item name="system" xsi:type="object">Paazl\CheckoutWidget\Logger\PaazlHandler</item>
51-
</argument>
50+
<argument name="logger" xsi:type="object">PaazlDebugMonolog</argument>
5251
</arguments>
5352
</type>
5453

0 commit comments

Comments
 (0)