Skip to content

Commit ef7ee97

Browse files
Merge pull request #613 from mollie/release/2.21.1
Release/2.21.1
2 parents 88b57e9 + 405139d commit ef7ee97

File tree

12 files changed

+72
-28
lines changed

12 files changed

+72
-28
lines changed

.github/workflows/templates/magento/configure-mollie.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ if [ -z "$MOLLIE_API_KEY_TEST" ]; then
44
fi
55

66
# General configuration
7+
bin/magento config:set payment/mollie_general/profileid pfl_8yCABHRz37 &
78
magerun2 config:store:set payment/mollie_general/apikey_test $MOLLIE_API_KEY_TEST --encrypt &
89
bin/magento config:set payment/mollie_general/enabled 1 &
910
bin/magento config:set payment/mollie_general/type test &
@@ -27,6 +28,9 @@ bin/magento config:set payment/mollie_methods_paymentlink/active 1 &
2728
bin/magento config:set payment/mollie_methods_paysafecard/active 1 &
2829
bin/magento config:set payment/mollie_methods_sofort/active 1 &
2930

31+
# Enable Components
32+
bin/magento config:set payment/mollie_methods_creditcard/use_components 1 &
33+
3034
# Enable QR
3135
bin/magento config:set payment/mollie_methods_ideal/add_qr 1 &
3236

Controller/ApplePay/PlaceOrder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function execute()
114114
$this->checkoutSession
115115
->setLastQuoteId($cart->getId())
116116
->setLastSuccessQuoteId($cart->getId())
117-
->setLastRealOrderId($order->getId())
117+
->setLastRealOrderId($order->getIncrementId())
118118
->setLastOrderId($order->getId());
119119

120120
$response = $this->resultFactory->create(ResultFactory::TYPE_JSON);

Controller/Checkout/Redirect.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
namespace Mollie\Payment\Controller\Checkout;
88

99
use Exception;
10+
use Magento\Checkout\Model\Session;
11+
use Magento\Framework\App\Action\Action;
12+
use Magento\Framework\App\Action\Context;
1013
use Magento\Framework\Exception\LocalizedException;
14+
use Magento\Framework\View\Result\PageFactory;
1115
use Magento\Payment\Helper\Data as PaymentHelper;
1216
use Magento\Payment\Model\MethodInterface;
1317
use Magento\Sales\Api\Data\OrderInterface;
@@ -17,10 +21,6 @@
1721
use Mollie\Payment\Api\PaymentTokenRepositoryInterface;
1822
use Mollie\Payment\Config;
1923
use Mollie\Payment\Helper\General as MollieHelper;
20-
use Magento\Framework\App\Action\Action;
21-
use Magento\Framework\App\Action\Context;
22-
use Magento\Checkout\Model\Session;
23-
use Magento\Framework\View\Result\PageFactory;
2424
use Mollie\Payment\Model\Methods\ApplePay;
2525
use Mollie\Payment\Model\Methods\Creditcard;
2626
use Mollie\Payment\Model\Methods\CreditcardVault;
@@ -126,7 +126,9 @@ public function execute()
126126
$storeId = $order->getStoreId();
127127
$redirectUrl = $this->startTransaction($methodInstance, $order);
128128
// This is deprecated since 2.18.0 and will be removed in a future version.
129-
if ($this->mollieHelper->useLoadingScreen($storeId)) {
129+
if (!($methodInstance instanceof ApplePay) &&
130+
$this->mollieHelper->useLoadingScreen($storeId)
131+
) {
130132
$resultPage = $this->resultPageFactory->create();
131133
$resultPage->getLayout()->initMessages();
132134
$resultPage->getLayout()->getBlock('mollie_loading')->setMollieRedirect($redirectUrl);

Model/Client/Orders.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,11 @@ public function startTransaction(Order $order, $mollieApi)
282282
$mollieOrder = $mollieApi->orders->create($orderData, ['embed' => 'payments']);
283283
$this->processResponse($order, $mollieOrder);
284284

285+
// Order is paid immediately (eg. Credit Card with Components, Apple Pay), process transaction
286+
if ($mollieOrder->isPaid()) {
287+
$this->processTransaction->execute($order, 'webhook');
288+
}
289+
285290
return $mollieOrder->getCheckoutUrl();
286291
}
287292

Model/Client/Payments.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Mollie\Api\Resources\Payment as MolliePayment;
1818
use Mollie\Api\Types\PaymentStatus;
1919
use Mollie\Payment\Helper\General as MollieHelper;
20+
use Mollie\Payment\Model\Client\Payments\ProcessTransaction;
2021
use Mollie\Payment\Service\Mollie\DashboardUrl;
2122
use Mollie\Payment\Service\Mollie\Order\LinkTransactionToOrder;
2223
use Mollie\Payment\Service\Mollie\TransactionDescription;
@@ -107,6 +108,11 @@ class Payments extends AbstractModel
107108
*/
108109
private $linkTransactionToOrder;
109110

111+
/**
112+
* @var Payments\ProcessTransaction
113+
*/
114+
private $processTransaction;
115+
110116
/**
111117
* Payments constructor.
112118
*
@@ -125,6 +131,7 @@ class Payments extends AbstractModel
125131
* @param SendOrderEmails $sendOrderEmails
126132
* @param EventManager $eventManager
127133
* @param LinkTransactionToOrder $linkTransactionToOrder
134+
* @param ProcessTransaction $processTransaction
128135
*/
129136
public function __construct(
130137
OrderRepository $orderRepository,
@@ -141,7 +148,8 @@ public function __construct(
141148
PaymentTokenForOrder $paymentTokenForOrder,
142149
SendOrderEmails $sendOrderEmails,
143150
EventManager $eventManager,
144-
LinkTransactionToOrder $linkTransactionToOrder
151+
LinkTransactionToOrder $linkTransactionToOrder,
152+
ProcessTransaction $processTransaction
145153
) {
146154
$this->orderRepository = $orderRepository;
147155
$this->checkoutSession = $checkoutSession;
@@ -158,6 +166,7 @@ public function __construct(
158166
$this->paymentTokenForOrder = $paymentTokenForOrder;
159167
$this->sendOrderEmails = $sendOrderEmails;
160168
$this->linkTransactionToOrder = $linkTransactionToOrder;
169+
$this->processTransaction = $processTransaction;
161170
}
162171

163172
/**
@@ -215,6 +224,11 @@ public function startTransaction(Order $order, $mollieApi)
215224
$payment = $mollieApi->payments->create($paymentData);
216225
$this->processResponse($order, $payment);
217226

227+
// Order is paid immediately (eg. Credit Card with Components, Apple Pay), process transaction
228+
if ($payment->isPaid()) {
229+
$this->processTransaction->execute($order, 'webhook');
230+
}
231+
218232
return $payment->getCheckoutUrl();
219233
}
220234

Test/End-2-end/cypress/e2e/magento/checkout.cy.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,32 @@ const checkoutPaymentPage = new CheckoutPaymentPage();
77
const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction();
88

99
describe('Check the checkout', () => {
10-
it('Should have a payment method specific class', () => {
11-
visitCheckoutPayment.visit();
12-
13-
checkoutPaymentPage.selectPaymentMethod('iDeal');
14-
15-
cy.get('.payment-method._active').should('have.class', 'payment-method-mollie_methods_ideal');
16-
17-
cy.get('.payment-method-mollie_methods_bancontact').should('not.have.class', '_active');
18-
cy.get('.payment-method-mollie_methods_banktransfer').should('not.have.class', '_active');
19-
cy.get('.payment-method-mollie_methods_belfius').should('not.have.class', '_active');
20-
cy.get('.payment-method-mollie_methods_creditcard').should('not.have.class', '_active');
21-
cy.get('.payment-method-mollie_methods_kbc').should('not.have.class', '_active');
22-
cy.get('.payment-method-mollie_methods_klarnapaylater').should('not.have.class', '_active');
23-
cy.get('.payment-method-mollie_methods_klarnapaynow').should('not.have.class', '_active');
24-
cy.get('.payment-method-mollie_methods_paypal').should('not.have.class', '_active');
25-
cy.get('.payment-method-mollie_methods_przelewy24').should('not.have.class', '_active');
26-
cy.get('.payment-method-mollie_methods_sofort').should('not.have.class', '_active');
10+
it('Should have a payment method specific class', () => {
11+
visitCheckoutPayment.visit();
12+
13+
checkoutPaymentPage.selectPaymentMethod('iDeal');
14+
15+
cy.get('.payment-method._active').should('have.class', 'payment-method-mollie_methods_ideal');
16+
17+
cy.get('.payment-method-mollie_methods_bancontact').should('not.have.class', '_active');
18+
cy.get('.payment-method-mollie_methods_banktransfer').should('not.have.class', '_active');
19+
cy.get('.payment-method-mollie_methods_belfius').should('not.have.class', '_active');
20+
cy.get('.payment-method-mollie_methods_creditcard').should('not.have.class', '_active');
21+
cy.get('.payment-method-mollie_methods_kbc').should('not.have.class', '_active');
22+
cy.get('.payment-method-mollie_methods_klarnapaylater').should('not.have.class', '_active');
23+
cy.get('.payment-method-mollie_methods_klarnapaynow').should('not.have.class', '_active');
24+
cy.get('.payment-method-mollie_methods_paypal').should('not.have.class', '_active');
25+
cy.get('.payment-method-mollie_methods_przelewy24').should('not.have.class', '_active');
26+
cy.get('.payment-method-mollie_methods_sofort').should('not.have.class', '_active');
27+
});
28+
29+
it('Should render Mollie Components when selecting Credit Card', () => {
30+
visitCheckoutPayment.visit();
31+
32+
checkoutPaymentPage.selectPaymentMethod('Credit Card');
33+
34+
cy.get('.card-container').should('be.visible');
35+
cy.get('#card-holder').should('be.visible');
36+
cy.get('#card-holder .mollie-component').should('be.visible');
2737
});
2838
})

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "mollie/magento2",
33
"description": "Mollie Payment Module for Magento 2",
4-
"version": "2.21.0",
4+
"version": "2.21.1",
55
"keywords": [
66
"mollie",
77
"payment",

etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<default>
44
<payment>
55
<mollie_general>
6-
<version>v2.21.0</version>
6+
<version>v2.21.1</version>
77
<active>0</active>
88
<enabled>0</enabled>
99
<type>test</type>

etc/csp_whitelist.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@
1111
<value id="mollie-images" type="host">https://www.mollie.com</value>
1212
</values>
1313
</policy>
14+
<policy id="frame-src">
15+
<values>
16+
<value id="mollie-components" type="host">js.mollie.com</value>
17+
</values>
18+
</policy>
1419
</policies>
1520
</csp_whitelist>

etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291
<arguments>
292292
<argument name="processors" xsi:type="array">
293293
<item name="preprocess" xsi:type="array">
294-
<item name="add_additional_data" xsi:type="object">Mollie\Payment\Model\Client\Orders\Processors\AddAdditionalInformation</item>
294+
<item name="add_additional_data" xsi:type="object">Mollie\Payment\Model\Client\Payments\Processors\AddAdditionalInformation</item>
295295
</item>
296296
<item name="failed" xsi:type="array">
297297
<item name="failed" xsi:type="object">Mollie\Payment\Model\Client\Payments\Processors\FailedStatusProcessor</item>

view/frontend/web/js/view/applepay/minicart.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
define([
22
'jquery',
3+
'Magento_Customer/js/customer-data',
34
'../product/apple-pay-button',
45
'mage/url'
56
], function (
67
$,
8+
customerData,
79
Component,
810
url
911
) {
@@ -144,6 +146,8 @@ define([
144146

145147
this.session.completePayment(ApplePaySession.STATUS_SUCCESS);
146148

149+
customerData.invalidate(['cart']);
150+
147151
setTimeout( function () {
148152
location.href = result.url
149153
}, 1000);

view/frontend/web/template/payment/creditcard-with-components.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="payment-method" data-bind="css: getClassNames()">
1+
<div class="payment-method" data-bind="css: getClassNames(), afterRender: function () { rendered(true) },">
22
<div class="payment-method-title field choice">
33
<input type="radio"
44
name="payment[method]"

0 commit comments

Comments
 (0)