Skip to content

Commit 2c0d39a

Browse files
Merge pull request #692 from mollie/release/2.31.0
Release/2.31.0
2 parents cecd809 + 23c91dd commit 2c0d39a

File tree

46 files changed

+563
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+563
-295
lines changed

Block/Applepay/Shortcut/Button.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Magento\Framework\View\Element\Template;
88
use Magento\Store\Model\ScopeInterface;
99
use Mollie\Payment\Config;
10+
use Mollie\Payment\Service\Mollie\ApplePay\SupportedNetworks;
1011

1112
class Button extends Template implements ShortcutInterface
1213
{
@@ -16,21 +17,26 @@ class Button extends Template implements ShortcutInterface
1617
* @var Session
1718
*/
1819
private $checkoutSession;
19-
2020
/**
2121
* @var Config
2222
*/
2323
private $config;
24+
/**
25+
* @var SupportedNetworks
26+
*/
27+
private $supportedNetworks;
2428

2529
public function __construct(
2630
Template\Context $context,
2731
Session $checkoutSession,
2832
Config $config,
33+
SupportedNetworks $supportedNetworks,
2934
array $data = []
3035
) {
3136
parent::__construct($context, $data);
3237
$this->checkoutSession = $checkoutSession;
3338
$this->config = $config;
39+
$this->supportedNetworks = $supportedNetworks;
3440
}
3541

3642
/**
@@ -87,4 +93,9 @@ public function getButtonClasses(): string
8793

8894
return implode(' ', $classes);
8995
}
96+
97+
public function getSupportedNetworks(): array
98+
{
99+
return $this->supportedNetworks->execute((int)$this->_storeManager->getStore()->getId());
100+
}
90101
}

Block/Form/Pointofsale.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
use Magento\Framework\View\Element\Template\Context;
1010
use Magento\Payment\Block\Form;
11+
use Mollie\Api\Exceptions\ApiException;
1112
use Mollie\Api\Resources\Terminal;
12-
use Mollie\Payment\Logger\MollieLogger;
1313
use Mollie\Payment\Service\Mollie\MollieApiClient;
1414

1515
/**
@@ -27,21 +27,15 @@ class Pointofsale extends Form
2727
* @var MollieApiClient
2828
*/
2929
private $mollieApiClient;
30-
/**
31-
* @var MollieLogger
32-
*/
33-
private $logger;
3430

3531
public function __construct(
3632
Context $context,
3733
MollieApiClient $mollieApiClient,
38-
MollieLogger $logger,
3934
array $data = []
4035
) {
4136
parent::__construct($context, $data);
4237

4338
$this->mollieApiClient = $mollieApiClient;
44-
$this->logger = $logger;
4539
}
4640

4741
/**
@@ -62,8 +56,7 @@ public function getTerminals(): array
6256
try {
6357
$mollieApiClient = $this->mollieApiClient->loadByStore((int)$storeId);
6458
$terminals = $mollieApiClient->terminals->page();
65-
} catch (\Mollie\Api\Exceptions\ApiException $exception) {
66-
$this->logger->addErrorLog('terminals', $exception->getMessage());
59+
} catch (ApiException $exception) {
6760
return [];
6861
}
6962

Block/Info/Base.php

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ class Base extends Info
3434
* @var DateTime\TimezoneInterface
3535
*/
3636
private $timezone;
37-
3837
/**
3938
* @var Registry
4039
*/
4140
private $registry;
42-
4341
/**
4442
* @var PriceCurrencyInterface
4543
*/
@@ -66,23 +64,17 @@ public function __construct(
6664
$this->price = $price;
6765
}
6866

69-
/**
70-
* @return bool|string
71-
*/
72-
public function getCheckoutType()
67+
public function getCheckoutType(): ?string
7368
{
7469
try {
7570
return $this->getInfo()->getAdditionalInformation('checkout_type');
7671
} catch (\Exception $e) {
7772
$this->mollieHelper->addTolog('error', $e->getMessage());
78-
return false;
73+
return null;
7974
}
8075
}
8176

82-
/**
83-
* @return bool|string
84-
*/
85-
public function getExpiresAt()
77+
public function getExpiresAt(): ?string
8678
{
8779
try {
8880
if ($expiresAt = $this->getInfo()->getAdditionalInformation('expires_at')) {
@@ -92,80 +84,67 @@ public function getExpiresAt()
9284
$this->mollieHelper->addTolog('error', $e->getMessage());
9385
}
9486

95-
return false;
87+
return null;
9688
}
9789

9890
/**
99-
* @param int|null $storeId
100-
* @return bool|string
91+
* @param mixed $storeId
10192
*/
102-
public function getPaymentLink($storeId = null)
93+
public function getPaymentLink($storeId = null): ?string
10394
{
10495
if ($checkoutUrl = $this->getCheckoutUrl()) {
10596
return $this->mollieHelper->getPaymentLinkMessage($checkoutUrl, $storeId);
10697
}
10798

108-
return false;
99+
return null;
109100
}
110101

111-
/**
112-
* @return bool|string
113-
*/
114-
public function getCheckoutUrl()
102+
public function getCheckoutUrl(): ?string
115103
{
116104
try {
117105
return $this->getInfo()->getAdditionalInformation('checkout_url');
118106
} catch (\Exception $e) {
119107
$this->mollieHelper->addTolog('error', $e->getMessage());
120-
return false;
108+
return null;
121109
}
122110
}
123111

124-
/**
125-
* @return bool|string
126-
*/
127-
public function getPaymentStatus()
112+
public function getPaymentStatus(): ?string
128113
{
129114
try {
130115
return $this->getInfo()->getAdditionalInformation('payment_status');
131116
} catch (\Exception $e) {
132117
$this->mollieHelper->addTolog('error', $e->getMessage());
133-
return false;
118+
return null;
134119
}
135120
}
136121

137-
/**
138-
* @return bool|string
139-
*/
140-
public function getDashboardUrl()
122+
public function getDashboardUrl(): ?string
141123
{
142124
try {
143125
return $this->getInfo()->getAdditionalInformation('dashboard_url');
144126
} catch (\Exception $e) {
145127
$this->mollieHelper->addTolog('error', $e->getMessage());
146-
return false;
128+
return null;
147129
}
148130
}
149131

150-
public function getChangePaymentStatusUrl(): string
132+
public function getChangePaymentStatusUrl(): ?string
151133
{
152134
try {
153135
return (string)$this->getInfo()->getAdditionalInformation('mollie_change_payment_state_url');
154136
} catch (\Exception $exception) {
155-
return '';
137+
return null;
156138
}
157139
}
158140

159-
/**
160-
* @return bool|string
161-
*/
162-
public function getMollieId()
141+
public function getMollieId(): ?string
163142
{
164143
try {
165144
return $this->getInfo()->getAdditionalInformation('mollie_id');
166145
} catch (\Exception $e) {
167146
$this->mollieHelper->addTolog('error', $e->getMessage());
168-
return false;
147+
return null;
169148
}
170149
}
171150

@@ -189,10 +168,9 @@ public function isBuyNowPayLaterMethod(): bool
189168
}
190169

191170
/**
192-
* @return mixed
193171
* @throws \Magento\Framework\Exception\LocalizedException
194172
*/
195-
public function getPaymentImage()
173+
public function getPaymentImage(): string
196174
{
197175
$code = $this->getInfo()->getMethod();
198176
if (strpos($code, 'mollie_methods_') !== false) {
@@ -202,10 +180,7 @@ public function getPaymentImage()
202180
return $code . '.svg';
203181
}
204182

205-
/**
206-
* @return string|null
207-
*/
208-
public function getOrderId()
183+
public function getOrderId(): ?string
209184
{
210185
try {
211186
return $this->getInfo()->getParentId();
@@ -240,10 +215,7 @@ public function formatPrice($amount)
240215
return $this->price->format($amount);
241216
}
242217

243-
/**
244-
* @return OrderInterface|null
245-
*/
246-
private function getOrder()
218+
private function getOrder(): ?OrderInterface
247219
{
248220
return $this->registry->registry('current_order');
249221
}

Block/Product/View/ApplePay.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,34 @@
1111
use Magento\Framework\Registry;
1212
use Magento\Framework\View\Element\Template;
1313
use Mollie\Payment\Config;
14+
use Mollie\Payment\Service\Mollie\ApplePay\SupportedNetworks;
1415

1516
class ApplePay extends Template
1617
{
1718
/**
1819
* @var Registry
1920
*/
2021
private $registry;
21-
2222
/**
2323
* @var Config
2424
*/
2525
private $config;
26+
/**
27+
* @var SupportedNetworks
28+
*/
29+
private $supportedNetworks;
2630

2731
public function __construct(
2832
Template\Context $context,
2933
Registry $registry,
3034
Config $config,
35+
SupportedNetworks $supportedNetworks,
3136
array $data = []
3237
) {
3338
parent::__construct($context, $data);
3439
$this->registry = $registry;
3540
$this->config = $config;
41+
$this->supportedNetworks = $supportedNetworks;
3642
}
3743

3844
public function getProductName(): string
@@ -81,4 +87,9 @@ public function getButtonClasses()
8187

8288
return implode(' ', $classes);
8389
}
90+
91+
public function getSupportedNetworks(): array
92+
{
93+
return $this->supportedNetworks->execute((int)$this->_storeManager->getStore()->getId());
94+
}
8495
}

Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ public function pointofsaleAllowedCustomerGroups(int $storeId = null)
586586
* @param null|int|string $storeId
587587
* @return string
588588
*/
589-
public function getMethodTitle($method, $storeId = null)
589+
public function getMethodTitle($method, $storeId = null): string
590590
{
591591
return $this->getPath($this->addMethodToPath(static::PAYMENT_METHOD_PAYMENT_TITLE, $method), $storeId);
592592
}

Controller/ApplePay/ShippingMethods.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function execute()
110110
'shipping_methods' => array_map(function ($method) {
111111
return [
112112
'identifier' => $method->getCarrierCode() . '_' . $method->getMethodCode(),
113-
'label' => $method->getCarrierTitle(),
113+
'label' => $method->getMethodTitle() . ' - ' . $method->getCarrierTitle(),
114114
'amount' => number_format($method->getPriceInclTax(), 2, '.', ''),
115115
'detail' => '',
116116
];

Model/Client/Payments.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
use Magento\Framework\Model\AbstractModel;
1313
use Magento\Sales\Api\Data\OrderInterface;
1414
use Magento\Sales\Model\Order;
15-
use Magento\Sales\Model\Order\Invoice;
1615
use Magento\Sales\Model\OrderRepository;
1716
use Mollie\Api\MollieApiClient;
1817
use Mollie\Api\Resources\Payment as MolliePayment;
1918
use Mollie\Api\Types\PaymentStatus;
2019
use Mollie\Payment\Helper\General as MollieHelper;
21-
use Mollie\Payment\Model\Adminhtml\Source\InvoiceMoment;
2220
use Mollie\Payment\Model\Client\Payments\ProcessTransaction;
2321
use Mollie\Payment\Service\Mollie\DashboardUrl;
2422
use Mollie\Payment\Service\Mollie\Order\CanRegisterCaptureNotification;
@@ -386,9 +384,18 @@ public function processTransaction(Order $order, $mollieApi, $type = 'webhook',
386384
$payment->setCurrencyCode($order->getBaseCurrencyCode());
387385
$payment->setIsTransactionClosed(true);
388386

389-
if ($this->canRegisterCaptureNotification->execute($order) ||
387+
if ($this->canRegisterCaptureNotification->execute($order, $paymentData) ||
390388
$type != static::TRANSACTION_TYPE_WEBHOOK
391389
) {
390+
if ($paymentData->getAmountCaptured() != 0.0) {
391+
$order->addCommentToStatusHistory(
392+
__(
393+
'Successfully captured an amount of %1.',
394+
$order->getBaseCurrency()->formatTxt($paymentData->getAmountCaptured())
395+
)
396+
);
397+
}
398+
392399
$payment->registerCaptureNotification($order->getBaseGrandTotal(), true);
393400
}
394401

0 commit comments

Comments
 (0)