Skip to content

Commit cc70022

Browse files
Merge pull request #815 from mollie/release/2.41.0
Release/2.41.0
2 parents 247d2cb + 98b325f commit cc70022

File tree

55 files changed

+685
-35
lines changed

Some content is hidden

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

55 files changed

+685
-35
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ bin/magento config:set payment/mollie_methods_kbc/active 1 &
2626
bin/magento config:set payment/mollie_methods_klarnasliceit/active 1 &
2727
bin/magento config:set payment/mollie_methods_paypal/active 1 &
2828
bin/magento config:set payment/mollie_methods_przelewy24/active 1 &
29+
bin/magento config:set payment/mollie_methods_payconiq/active 1 &
2930
bin/magento config:set payment/mollie_methods_alma/active 1 &
3031
bin/magento config:set payment/mollie_methods_bancontact/active 1 &
3132
bin/magento config:set payment/mollie_methods_bancomatpay/active 1 &

Api/Webapi/ResetCartInterface.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/*
3+
* Copyright Magmodules.eu. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Mollie\Payment\Api\Webapi;
8+
9+
interface ResetCartInterface
10+
{
11+
/**
12+
* @param string $hash
13+
* @return void
14+
*/
15+
public function byHash(string $hash): void;
16+
}

Controller/Checkout/Pointofsale.php

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
<?php
2+
/*
3+
* Copyright Magmodules.eu. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
26

37
declare(strict_types=1);
48

59
namespace Mollie\Payment\Controller\Checkout;
610

711
use Magento\Framework\App\Action\HttpGetActionInterface;
812
use Magento\Framework\App\RequestInterface;
13+
use Magento\Framework\Encryption\EncryptorInterface;
914
use Magento\Framework\Exception\AuthorizationException;
15+
use Magento\Framework\UrlInterface;
1016
use Magento\Framework\View\Result\PageFactory;
17+
use Magento\Sales\Api\Data\OrderInterface;
18+
use Magento\Sales\Api\OrderRepositoryInterface;
1119
use Magento\Store\Model\StoreManagerInterface;
20+
use Mollie\Payment\Api\Data\PaymentTokenInterface;
21+
use Mollie\Payment\Api\PaymentTokenRepositoryInterface;
22+
use Mollie\Payment\Service\PaymentToken\Generate;
1223

1324
class Pointofsale implements HttpGetActionInterface
1425
{
@@ -24,15 +35,45 @@ class Pointofsale implements HttpGetActionInterface
2435
* @var StoreManagerInterface
2536
*/
2637
private $storeManager;
38+
/**
39+
* @var UrlInterface
40+
*/
41+
private $url;
42+
/**
43+
* @var OrderRepositoryInterface
44+
*/
45+
private $orderRepository;
46+
/**
47+
* @var EncryptorInterface
48+
*/
49+
private $encryptor;
50+
/**
51+
* @var PaymentTokenRepositoryInterface
52+
*/
53+
private $paymentTokenRepository;
54+
/**
55+
* @var Generate
56+
*/
57+
private $generatePaymentToken;
2758

2859
public function __construct(
2960
PageFactory $resultPageFactory,
3061
RequestInterface $request,
31-
StoreManagerInterface $storeManager
62+
StoreManagerInterface $storeManager,
63+
UrlInterface $url,
64+
OrderRepositoryInterface $orderRepository,
65+
EncryptorInterface $encryptor,
66+
PaymentTokenRepositoryInterface $paymentTokenRepository,
67+
Generate $generatePaymentToken
3268
) {
3369
$this->resultPageFactory = $resultPageFactory;
3470
$this->request = $request;
3571
$this->storeManager = $storeManager;
72+
$this->url = $url;
73+
$this->orderRepository = $orderRepository;
74+
$this->encryptor = $encryptor;
75+
$this->paymentTokenRepository = $paymentTokenRepository;
76+
$this->generatePaymentToken = $generatePaymentToken;
3677
}
3778

3879
public function execute()
@@ -42,12 +83,35 @@ public function execute()
4283
throw new AuthorizationException(__('Invalid token'));
4384
}
4485

86+
$id = $this->encryptor->decrypt(base64_decode($token));
87+
$order = $this->orderRepository->get($id);
88+
4589
$resultPage = $this->resultPageFactory->create();
4690
$resultPage->getConfig()->getTitle()->set(__('Please finish the payment on the terminal.'));
4791
$block = $resultPage->getLayout()->getBlock('mollie.pointofsale.wait');
48-
$block->setData('token', $token);
49-
$block->setData('storeCode', $this->storeManager->getStore()->getCode());
92+
$block->setData(
93+
'status_url',
94+
'/rest/' . $this->storeManager->getStore()->getCode() . '/V1/mollie/get-order/' . $token
95+
);
96+
$block->setData(
97+
'reset_url',
98+
'/rest/' . $this->storeManager->getStore()->getCode() . '/V1/mollie/reset-cart/' . $token
99+
);
100+
$block->setData(
101+
'retry_url',
102+
$this->url->getUrl('mollie/checkout/redirect', ['paymentToken' => $this->getToken($order)])
103+
);
50104

51105
return $resultPage;
52106
}
107+
108+
private function getToken(OrderInterface $order): string
109+
{
110+
$token = $this->paymentTokenRepository->getByOrder($order);
111+
if ($token) {
112+
return $token->getToken();
113+
}
114+
115+
return $this->generatePaymentToken->forOrder($order)->getToken();
116+
}
53117
}

Model/Client/Orders/Processors/AddAdditionalInformation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function process(OrderInterface $magentoOrder, Order $mollieOrder, string
4949
$dashboardUrl = $this->dashboardUrl->forOrdersApi($magentoOrder->getStoreId(), $mollieOrder->id);
5050
$magentoOrder->getPayment()->setAdditionalInformation('mollie_id', $mollieOrder->id);
5151
$magentoOrder->getPayment()->setAdditionalInformation('dashboard_url', $dashboardUrl);
52+
$magentoOrder->getPayment()->setAdditionalInformation('method', $mollieOrder->method);
5253

5354
$status = $mollieOrder->status;
5455
$payment = $magentoOrder->getPayment();

Model/Client/Payments.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ public function processTransaction(Order $order, $mollieApi, $type = 'webhook',
341341
$dashboardUrl = $this->dashboardUrl->forPaymentsApi($order->getStoreId(), $paymentData->id);
342342
$order->getPayment()->setAdditionalInformation('dashboard_url', $dashboardUrl);
343343
$order->getPayment()->setAdditionalInformation('mollie_id', $paymentData->id);
344+
$order->getPayment()->setAdditionalInformation('method', $paymentData->method);
344345

345346
$status = $paymentData->status;
346347
$payment = $order->getPayment();

Model/Client/Payments/Processors/AddAdditionalInformation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function process(
4343
$dashboardUrl = $this->dashboardUrl->forPaymentsApi($order->getStoreId(), $molliePayment->id);
4444
$magentoPayment->setAdditionalInformation('dashboard_url', $dashboardUrl);
4545
$magentoPayment->setAdditionalInformation('mollie_id', $molliePayment->id);
46+
$magentoPayment->setAdditionalInformation('method', $molliePayment->method);
4647

4748
$status = $molliePayment->status;
4849
if ($type == 'webhook' && $magentoPayment->getAdditionalInformation('payment_status') != $status) {

Model/Methods/Payconiq.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/*
3+
* Copyright Magmodules.eu. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Mollie\Payment\Model\Methods;
8+
9+
class Payconiq extends \Mollie\Payment\Model\Mollie
10+
{
11+
12+
/**
13+
* Payment method code
14+
*
15+
* @var string
16+
*/
17+
const CODE = 'mollie_methods_payconiq';
18+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/*
3+
* Copyright Magmodules.eu. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Mollie\Payment\Observer\SalesModelServiceQuoteSubmitSuccess;
10+
11+
use Magento\Framework\Event\Observer;
12+
use Magento\Framework\Event\ObserverInterface;
13+
use Magento\Sales\Api\Data\OrderInterface;
14+
use Magento\Sales\Api\OrderPaymentRepositoryInterface;
15+
use Magento\Sales\Model\Order\PaymentAdapterInterface;
16+
use Mollie\Payment\Model\Methods\Paymentlink;
17+
use Mollie\Payment\Service\Magento\PaymentLinkUrl;
18+
19+
class SetCheckoutUrlForPaymentLink implements ObserverInterface
20+
{
21+
/**
22+
* @var PaymentLinkUrl
23+
*/
24+
private $paymentLinkUrl;
25+
/**
26+
* @var OrderPaymentRepositoryInterface
27+
*/
28+
private $orderPaymentRepository;
29+
30+
public function __construct(
31+
PaymentLinkUrl $paymentLinkUrl,
32+
OrderPaymentRepositoryInterface $orderPaymentRepository
33+
) {
34+
$this->paymentLinkUrl = $paymentLinkUrl;
35+
$this->orderPaymentRepository = $orderPaymentRepository;
36+
}
37+
38+
public function execute(Observer $observer)
39+
{
40+
/** @var OrderInterface $order */
41+
$order = $observer->getEvent()->getData('order');
42+
43+
$payment = $order->getPayment();
44+
if ($payment->getMethod() != Paymentlink::CODE) {
45+
return;
46+
}
47+
48+
$payment->setAdditionalInformation(
49+
'checkout_url',
50+
$this->paymentLinkUrl->execute((int)$order->getEntityId())
51+
);
52+
53+
$this->orderPaymentRepository->save($payment);
54+
}
55+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Mollie requires no minimum costs, no fixed contracts, no hidden costs. At Mollie
4848
- PayPal
4949
- Paysafecard
5050
- Point Of Sale (POS)
51+
- Payconiq
5152
- Przelewy24
5253
- SEPA Direct Debit
5354
- SOFORT Banking

Service/Mollie/GetMollieStatusResult.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ public function __construct(
2323
string $status,
2424
string $method = null
2525
) {
26-
$method = str_replace('mollie_methods_', '', $method);
26+
if ($method !== null) {
27+
$method = str_replace('mollie_methods_', '', $method);
28+
}
2729

2830
$this->status = $status;
2931
$this->method = $method;

Service/Mollie/PaymentMethods.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class PaymentMethods
3939
'mollie_methods_paypal',
4040
'mollie_methods_paysafecard',
4141
'mollie_methods_pointofsale',
42+
'mollie_methods_payconiq',
4243
'mollie_methods_przelewy24',
4344
'mollie_methods_riverty',
4445
'mollie_methods_sofort',

Service/Mollie/ProcessTransaction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function execute(int $orderId, string $transactionId, string $type = 'web
7878

7979
return $this->getMollieStatusResultFactory->create([
8080
'status' => $result['status'],
81-
'method' => $order->getPayment()->getMethod(),
81+
'method' => $order->getPayment()->getAdditionalInformation('method') ?? $order->getPayment()->getMethod(),
8282
]);
8383
}
8484

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright Magmodules.eu. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage";
7+
import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction";
8+
import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage";
9+
import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage";
10+
import OrdersPage from "Pages/backend/OrdersPage";
11+
import CartPage from "Pages/frontend/CartPage";
12+
13+
const checkoutPaymentPage = new CheckoutPaymentPage();
14+
const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction();
15+
const mollieHostedPaymentPage = new MollieHostedPaymentPage();
16+
const checkoutSuccessPage = new CheckoutSuccessPage();
17+
const ordersPage = new OrdersPage();
18+
const cartPage = new CartPage();
19+
20+
if (Cypress.env('mollie_available_methods').includes('payconiq')) {
21+
describe('Check that payconiq behaves as expected', () => {
22+
[
23+
{status: 'paid', orderStatus: 'Processing', title: 'C3706886: Validate the submission of an order with Payconiq as payment method and payment mark as "Paid" '},
24+
{status: 'failed', orderStatus: 'Canceled', title: 'C3706887: Validate the submission of an order with Payconiq as payment method and payment mark as "Failed"'},
25+
{status: 'expired', orderStatus: 'Canceled', title: 'C3706888: Validate the submission of an order with Payconiq as payment method and payment mark as "Expired" '},
26+
{status: 'canceled', orderStatus: 'Canceled', title: 'C3706889: Validate the submission of an order with Payconiq as payment method and payment mark as "Canceled" '},
27+
].forEach((testCase) => {
28+
it(testCase.title, () => {
29+
visitCheckoutPayment.visit('BE');
30+
31+
cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect');
32+
33+
checkoutPaymentPage.selectPaymentMethod('Payconiq');
34+
checkoutPaymentPage.placeOrder();
35+
36+
mollieHostedPaymentPage.selectStatus(testCase.status);
37+
38+
if (testCase.status === 'paid') {
39+
checkoutSuccessPage.assertThatOrderSuccessPageIsShown();
40+
}
41+
42+
if (testCase.status === 'canceled') {
43+
cartPage.assertCartPageIsShown();
44+
}
45+
46+
cy.backendLogin();
47+
48+
cy.get('@order-id').then((orderId) => {
49+
ordersPage.openOrderById(orderId);
50+
});
51+
52+
if (testCase.status === 'expired') {
53+
ordersPage.callFetchStatus();
54+
}
55+
56+
ordersPage.assertOrderStatusIs(testCase.orderStatus);
57+
});
58+
});
59+
})
60+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"type": {
3+
"username": "[email protected]",
4+
"firstname": "Anna",
5+
"company": "Acme Firma BVBA",
6+
"lastname": "Schmidt",
7+
"street[0]": "Voorbeeldstraat 1",
8+
"city": "Brussel",
9+
"postcode": "1000",
10+
"telephone": "+32 2 XXXXXXX"
11+
},
12+
"select": {
13+
"country_id": "BE"
14+
}
15+
}

Test/End-2-end/cypress/support/actions/composite/VisitCheckoutPaymentCompositeAction.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ export default class VisitCheckoutPaymentCompositeAction {
3939
}
4040

4141
fillAddress(fixture, asCustomer = false) {
42-
if (asCustomer) {
43-
checkoutShippingPage.skipUsername();
44-
}
42+
if (asCustomer) {
43+
checkoutShippingPage.skipUsername();
44+
}
45+
46+
if (fixture === 'BE') {
47+
checkoutShippingPage.fillBelgianShippingAddress();
48+
return;
49+
}
4550

4651
if (fixture === 'DE') {
4752
checkoutShippingPage.fillGermanShippingAddress();

Test/End-2-end/cypress/support/pages/frontend/CheckoutShippingPage.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export default class CheckoutShippingPage {
1616
});
1717
}
1818

19+
fillBelgianShippingAddress() {
20+
cy.fixture('belgian-shipping-address').then((address) => {
21+
this.fillShippingAddress(address);
22+
});
23+
}
24+
1925
fillGermanShippingAddress() {
2026
cy.fixture('german-shipping-address').then((address) => {
2127
this.fillShippingAddress(address);

Test/Integration/Etc/Config/MethodsConfigurationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function methods(): array
3838
['mollie_methods_paypal'],
3939
['mollie_methods_paysafecard'],
4040
['mollie_methods_pointofsale'],
41+
['mollie_methods_payconiq'],
4142
['mollie_methods_przelewy24'],
4243
['mollie_methods_riverty'],
4344
['mollie_methods_sofort'],

Test/Integration/Helper/GeneralTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public function getMethodCodeDataProvider()
165165
'paypal' => ['mollie_methods_paypal', 'paypal'],
166166
'paysafecard' => ['mollie_methods_paysafecard', 'paysafecard'],
167167
'pointofsale' => ['mollie_methods_pointofsale', 'pointofsale'],
168+
'payconiq' => ['mollie_methods_payconiq', 'payconiq'],
168169
'przelewy24' => ['mollie_methods_przelewy24', 'przelewy24'],
169170
'riverty' => ['mollie_methods_riverty', 'riverty'],
170171
'sofort' => ['mollie_methods_sofort', 'sofort'],

0 commit comments

Comments
 (0)