Skip to content

Commit

Permalink
Merge pull request #613 from mollie/release/2.21.1
Browse files Browse the repository at this point in the history
Release/2.21.1
Marvin-Magmodules authored Feb 7, 2023
2 parents 88b57e9 + 405139d commit ef7ee97
Showing 12 changed files with 72 additions and 28 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/templates/magento/configure-mollie.sh
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ if [ -z "$MOLLIE_API_KEY_TEST" ]; then
fi

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

# Enable Components
bin/magento config:set payment/mollie_methods_creditcard/use_components 1 &

# Enable QR
bin/magento config:set payment/mollie_methods_ideal/add_qr 1 &

2 changes: 1 addition & 1 deletion Controller/ApplePay/PlaceOrder.php
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ public function execute()
$this->checkoutSession
->setLastQuoteId($cart->getId())
->setLastSuccessQuoteId($cart->getId())
->setLastRealOrderId($order->getId())
->setLastRealOrderId($order->getIncrementId())
->setLastOrderId($order->getId());

$response = $this->resultFactory->create(ResultFactory::TYPE_JSON);
12 changes: 7 additions & 5 deletions Controller/Checkout/Redirect.php
Original file line number Diff line number Diff line change
@@ -7,7 +7,11 @@
namespace Mollie\Payment\Controller\Checkout;

use Exception;
use Magento\Checkout\Model\Session;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Result\PageFactory;
use Magento\Payment\Helper\Data as PaymentHelper;
use Magento\Payment\Model\MethodInterface;
use Magento\Sales\Api\Data\OrderInterface;
@@ -17,10 +21,6 @@
use Mollie\Payment\Api\PaymentTokenRepositoryInterface;
use Mollie\Payment\Config;
use Mollie\Payment\Helper\General as MollieHelper;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Checkout\Model\Session;
use Magento\Framework\View\Result\PageFactory;
use Mollie\Payment\Model\Methods\ApplePay;
use Mollie\Payment\Model\Methods\Creditcard;
use Mollie\Payment\Model\Methods\CreditcardVault;
@@ -126,7 +126,9 @@ public function execute()
$storeId = $order->getStoreId();
$redirectUrl = $this->startTransaction($methodInstance, $order);
// This is deprecated since 2.18.0 and will be removed in a future version.
if ($this->mollieHelper->useLoadingScreen($storeId)) {
if (!($methodInstance instanceof ApplePay) &&
$this->mollieHelper->useLoadingScreen($storeId)
) {
$resultPage = $this->resultPageFactory->create();
$resultPage->getLayout()->initMessages();
$resultPage->getLayout()->getBlock('mollie_loading')->setMollieRedirect($redirectUrl);
5 changes: 5 additions & 0 deletions Model/Client/Orders.php
Original file line number Diff line number Diff line change
@@ -282,6 +282,11 @@ public function startTransaction(Order $order, $mollieApi)
$mollieOrder = $mollieApi->orders->create($orderData, ['embed' => 'payments']);
$this->processResponse($order, $mollieOrder);

// Order is paid immediately (eg. Credit Card with Components, Apple Pay), process transaction
if ($mollieOrder->isPaid()) {
$this->processTransaction->execute($order, 'webhook');
}

return $mollieOrder->getCheckoutUrl();
}

16 changes: 15 additions & 1 deletion Model/Client/Payments.php
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
use Mollie\Api\Resources\Payment as MolliePayment;
use Mollie\Api\Types\PaymentStatus;
use Mollie\Payment\Helper\General as MollieHelper;
use Mollie\Payment\Model\Client\Payments\ProcessTransaction;
use Mollie\Payment\Service\Mollie\DashboardUrl;
use Mollie\Payment\Service\Mollie\Order\LinkTransactionToOrder;
use Mollie\Payment\Service\Mollie\TransactionDescription;
@@ -107,6 +108,11 @@ class Payments extends AbstractModel
*/
private $linkTransactionToOrder;

/**
* @var Payments\ProcessTransaction
*/
private $processTransaction;

/**
* Payments constructor.
*
@@ -125,6 +131,7 @@ class Payments extends AbstractModel
* @param SendOrderEmails $sendOrderEmails
* @param EventManager $eventManager
* @param LinkTransactionToOrder $linkTransactionToOrder
* @param ProcessTransaction $processTransaction
*/
public function __construct(
OrderRepository $orderRepository,
@@ -141,7 +148,8 @@ public function __construct(
PaymentTokenForOrder $paymentTokenForOrder,
SendOrderEmails $sendOrderEmails,
EventManager $eventManager,
LinkTransactionToOrder $linkTransactionToOrder
LinkTransactionToOrder $linkTransactionToOrder,
ProcessTransaction $processTransaction
) {
$this->orderRepository = $orderRepository;
$this->checkoutSession = $checkoutSession;
@@ -158,6 +166,7 @@ public function __construct(
$this->paymentTokenForOrder = $paymentTokenForOrder;
$this->sendOrderEmails = $sendOrderEmails;
$this->linkTransactionToOrder = $linkTransactionToOrder;
$this->processTransaction = $processTransaction;
}

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

// Order is paid immediately (eg. Credit Card with Components, Apple Pay), process transaction
if ($payment->isPaid()) {
$this->processTransaction->execute($order, 'webhook');
}

return $payment->getCheckoutUrl();
}

44 changes: 27 additions & 17 deletions Test/End-2-end/cypress/e2e/magento/checkout.cy.js
Original file line number Diff line number Diff line change
@@ -7,22 +7,32 @@ const checkoutPaymentPage = new CheckoutPaymentPage();
const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction();

describe('Check the checkout', () => {
it('Should have a payment method specific class', () => {
visitCheckoutPayment.visit();

checkoutPaymentPage.selectPaymentMethod('iDeal');

cy.get('.payment-method._active').should('have.class', 'payment-method-mollie_methods_ideal');

cy.get('.payment-method-mollie_methods_bancontact').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_banktransfer').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_belfius').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_creditcard').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_kbc').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_klarnapaylater').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_klarnapaynow').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_paypal').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_przelewy24').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_sofort').should('not.have.class', '_active');
it('Should have a payment method specific class', () => {
visitCheckoutPayment.visit();

checkoutPaymentPage.selectPaymentMethod('iDeal');

cy.get('.payment-method._active').should('have.class', 'payment-method-mollie_methods_ideal');

cy.get('.payment-method-mollie_methods_bancontact').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_banktransfer').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_belfius').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_creditcard').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_kbc').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_klarnapaylater').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_klarnapaynow').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_paypal').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_przelewy24').should('not.have.class', '_active');
cy.get('.payment-method-mollie_methods_sofort').should('not.have.class', '_active');
});

it('Should render Mollie Components when selecting Credit Card', () => {
visitCheckoutPayment.visit();

checkoutPaymentPage.selectPaymentMethod('Credit Card');

cy.get('.card-container').should('be.visible');
cy.get('#card-holder').should('be.visible');
cy.get('#card-holder .mollie-component').should('be.visible');
});
})
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mollie/magento2",
"description": "Mollie Payment Module for Magento 2",
"version": "2.21.0",
"version": "2.21.1",
"keywords": [
"mollie",
"payment",
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
<default>
<payment>
<mollie_general>
<version>v2.21.0</version>
<version>v2.21.1</version>
<active>0</active>
<enabled>0</enabled>
<type>test</type>
5 changes: 5 additions & 0 deletions etc/csp_whitelist.xml
Original file line number Diff line number Diff line change
@@ -11,5 +11,10 @@
<value id="mollie-images" type="host">https://www.mollie.com</value>
</values>
</policy>
<policy id="frame-src">
<values>
<value id="mollie-components" type="host">js.mollie.com</value>
</values>
</policy>
</policies>
</csp_whitelist>
2 changes: 1 addition & 1 deletion etc/di.xml
Original file line number Diff line number Diff line change
@@ -291,7 +291,7 @@
<arguments>
<argument name="processors" xsi:type="array">
<item name="preprocess" xsi:type="array">
<item name="add_additional_data" xsi:type="object">Mollie\Payment\Model\Client\Orders\Processors\AddAdditionalInformation</item>
<item name="add_additional_data" xsi:type="object">Mollie\Payment\Model\Client\Payments\Processors\AddAdditionalInformation</item>
</item>
<item name="failed" xsi:type="array">
<item name="failed" xsi:type="object">Mollie\Payment\Model\Client\Payments\Processors\FailedStatusProcessor</item>
4 changes: 4 additions & 0 deletions view/frontend/web/js/view/applepay/minicart.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
define([
'jquery',
'Magento_Customer/js/customer-data',
'../product/apple-pay-button',
'mage/url'
], function (
$,
customerData,
Component,
url
) {
@@ -144,6 +146,8 @@ define([

this.session.completePayment(ApplePaySession.STATUS_SUCCESS);

customerData.invalidate(['cart']);

setTimeout( function () {
location.href = result.url
}, 1000);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="payment-method" data-bind="css: getClassNames()">
<div class="payment-method" data-bind="css: getClassNames(), afterRender: function () { rendered(true) },">
<div class="payment-method-title field choice">
<input type="radio"
name="payment[method]"

0 comments on commit ef7ee97

Please sign in to comment.