Skip to content

Commit

Permalink
Merge pull request #815 from mollie/release/2.41.0
Browse files Browse the repository at this point in the history
Release/2.41.0
  • Loading branch information
Marvin-Magmodules authored Sep 9, 2024
2 parents 247d2cb + 98b325f commit cc70022
Show file tree
Hide file tree
Showing 55 changed files with 685 additions and 35 deletions.
1 change: 1 addition & 0 deletions .github/workflows/templates/magento/configure-mollie.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ bin/magento config:set payment/mollie_methods_kbc/active 1 &
bin/magento config:set payment/mollie_methods_klarnasliceit/active 1 &
bin/magento config:set payment/mollie_methods_paypal/active 1 &
bin/magento config:set payment/mollie_methods_przelewy24/active 1 &
bin/magento config:set payment/mollie_methods_payconiq/active 1 &
bin/magento config:set payment/mollie_methods_alma/active 1 &
bin/magento config:set payment/mollie_methods_bancontact/active 1 &
bin/magento config:set payment/mollie_methods_bancomatpay/active 1 &
Expand Down
16 changes: 16 additions & 0 deletions Api/Webapi/ResetCartInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Api\Webapi;

interface ResetCartInterface
{
/**
* @param string $hash
* @return void
*/
public function byHash(string $hash): void;
}
70 changes: 67 additions & 3 deletions Controller/Checkout/Pointofsale.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Mollie\Payment\Controller\Checkout;

use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Encryption\EncryptorInterface;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Result\PageFactory;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Store\Model\StoreManagerInterface;
use Mollie\Payment\Api\Data\PaymentTokenInterface;
use Mollie\Payment\Api\PaymentTokenRepositoryInterface;
use Mollie\Payment\Service\PaymentToken\Generate;

class Pointofsale implements HttpGetActionInterface
{
Expand All @@ -24,15 +35,45 @@ class Pointofsale implements HttpGetActionInterface
* @var StoreManagerInterface
*/
private $storeManager;
/**
* @var UrlInterface
*/
private $url;
/**
* @var OrderRepositoryInterface
*/
private $orderRepository;
/**
* @var EncryptorInterface
*/
private $encryptor;
/**
* @var PaymentTokenRepositoryInterface
*/
private $paymentTokenRepository;
/**
* @var Generate
*/
private $generatePaymentToken;

public function __construct(
PageFactory $resultPageFactory,
RequestInterface $request,
StoreManagerInterface $storeManager
StoreManagerInterface $storeManager,
UrlInterface $url,
OrderRepositoryInterface $orderRepository,
EncryptorInterface $encryptor,
PaymentTokenRepositoryInterface $paymentTokenRepository,
Generate $generatePaymentToken
) {
$this->resultPageFactory = $resultPageFactory;
$this->request = $request;
$this->storeManager = $storeManager;
$this->url = $url;
$this->orderRepository = $orderRepository;
$this->encryptor = $encryptor;
$this->paymentTokenRepository = $paymentTokenRepository;
$this->generatePaymentToken = $generatePaymentToken;
}

public function execute()
Expand All @@ -42,12 +83,35 @@ public function execute()
throw new AuthorizationException(__('Invalid token'));
}

$id = $this->encryptor->decrypt(base64_decode($token));
$order = $this->orderRepository->get($id);

$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->set(__('Please finish the payment on the terminal.'));
$block = $resultPage->getLayout()->getBlock('mollie.pointofsale.wait');
$block->setData('token', $token);
$block->setData('storeCode', $this->storeManager->getStore()->getCode());
$block->setData(
'status_url',
'/rest/' . $this->storeManager->getStore()->getCode() . '/V1/mollie/get-order/' . $token
);
$block->setData(
'reset_url',
'/rest/' . $this->storeManager->getStore()->getCode() . '/V1/mollie/reset-cart/' . $token
);
$block->setData(
'retry_url',
$this->url->getUrl('mollie/checkout/redirect', ['paymentToken' => $this->getToken($order)])
);

return $resultPage;
}

private function getToken(OrderInterface $order): string
{
$token = $this->paymentTokenRepository->getByOrder($order);
if ($token) {
return $token->getToken();
}

return $this->generatePaymentToken->forOrder($order)->getToken();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function process(OrderInterface $magentoOrder, Order $mollieOrder, string
$dashboardUrl = $this->dashboardUrl->forOrdersApi($magentoOrder->getStoreId(), $mollieOrder->id);
$magentoOrder->getPayment()->setAdditionalInformation('mollie_id', $mollieOrder->id);
$magentoOrder->getPayment()->setAdditionalInformation('dashboard_url', $dashboardUrl);
$magentoOrder->getPayment()->setAdditionalInformation('method', $mollieOrder->method);

$status = $mollieOrder->status;
$payment = $magentoOrder->getPayment();
Expand Down
1 change: 1 addition & 0 deletions Model/Client/Payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ public function processTransaction(Order $order, $mollieApi, $type = 'webhook',
$dashboardUrl = $this->dashboardUrl->forPaymentsApi($order->getStoreId(), $paymentData->id);
$order->getPayment()->setAdditionalInformation('dashboard_url', $dashboardUrl);
$order->getPayment()->setAdditionalInformation('mollie_id', $paymentData->id);
$order->getPayment()->setAdditionalInformation('method', $paymentData->method);

$status = $paymentData->status;
$payment = $order->getPayment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function process(
$dashboardUrl = $this->dashboardUrl->forPaymentsApi($order->getStoreId(), $molliePayment->id);
$magentoPayment->setAdditionalInformation('dashboard_url', $dashboardUrl);
$magentoPayment->setAdditionalInformation('mollie_id', $molliePayment->id);
$magentoPayment->setAdditionalInformation('method', $molliePayment->method);

$status = $molliePayment->status;
if ($type == 'webhook' && $magentoPayment->getAdditionalInformation('payment_status') != $status) {
Expand Down
18 changes: 18 additions & 0 deletions Model/Methods/Payconiq.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Model\Methods;

class Payconiq extends \Mollie\Payment\Model\Mollie
{

/**
* Payment method code
*
* @var string
*/
const CODE = 'mollie_methods_payconiq';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Mollie\Payment\Observer\SalesModelServiceQuoteSubmitSuccess;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderPaymentRepositoryInterface;
use Magento\Sales\Model\Order\PaymentAdapterInterface;
use Mollie\Payment\Model\Methods\Paymentlink;
use Mollie\Payment\Service\Magento\PaymentLinkUrl;

class SetCheckoutUrlForPaymentLink implements ObserverInterface
{
/**
* @var PaymentLinkUrl
*/
private $paymentLinkUrl;
/**
* @var OrderPaymentRepositoryInterface
*/
private $orderPaymentRepository;

public function __construct(
PaymentLinkUrl $paymentLinkUrl,
OrderPaymentRepositoryInterface $orderPaymentRepository
) {
$this->paymentLinkUrl = $paymentLinkUrl;
$this->orderPaymentRepository = $orderPaymentRepository;
}

public function execute(Observer $observer)
{
/** @var OrderInterface $order */
$order = $observer->getEvent()->getData('order');

$payment = $order->getPayment();
if ($payment->getMethod() != Paymentlink::CODE) {
return;
}

$payment->setAdditionalInformation(
'checkout_url',
$this->paymentLinkUrl->execute((int)$order->getEntityId())
);

$this->orderPaymentRepository->save($payment);
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Mollie requires no minimum costs, no fixed contracts, no hidden costs. At Mollie
- PayPal
- Paysafecard
- Point Of Sale (POS)
- Payconiq
- Przelewy24
- SEPA Direct Debit
- SOFORT Banking
Expand Down
4 changes: 3 additions & 1 deletion Service/Mollie/GetMollieStatusResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ public function __construct(
string $status,
string $method = null
) {
$method = str_replace('mollie_methods_', '', $method);
if ($method !== null) {
$method = str_replace('mollie_methods_', '', $method);
}

$this->status = $status;
$this->method = $method;
Expand Down
1 change: 1 addition & 0 deletions Service/Mollie/PaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class PaymentMethods
'mollie_methods_paypal',
'mollie_methods_paysafecard',
'mollie_methods_pointofsale',
'mollie_methods_payconiq',
'mollie_methods_przelewy24',
'mollie_methods_riverty',
'mollie_methods_sofort',
Expand Down
2 changes: 1 addition & 1 deletion Service/Mollie/ProcessTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function execute(int $orderId, string $transactionId, string $type = 'web

return $this->getMollieStatusResultFactory->create([
'status' => $result['status'],
'method' => $order->getPayment()->getMethod(),
'method' => $order->getPayment()->getAdditionalInformation('method') ?? $order->getPayment()->getMethod(),
]);
}

Expand Down
60 changes: 60 additions & 0 deletions Test/End-2-end/cypress/e2e/magento/methods/payconiq.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

import CheckoutPaymentPage from "Pages/frontend/CheckoutPaymentPage";
import VisitCheckoutPaymentCompositeAction from "CompositeActions/VisitCheckoutPaymentCompositeAction";
import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage";
import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage";
import OrdersPage from "Pages/backend/OrdersPage";
import CartPage from "Pages/frontend/CartPage";

const checkoutPaymentPage = new CheckoutPaymentPage();
const visitCheckoutPayment = new VisitCheckoutPaymentCompositeAction();
const mollieHostedPaymentPage = new MollieHostedPaymentPage();
const checkoutSuccessPage = new CheckoutSuccessPage();
const ordersPage = new OrdersPage();
const cartPage = new CartPage();

if (Cypress.env('mollie_available_methods').includes('payconiq')) {
describe('Check that payconiq behaves as expected', () => {
[
{status: 'paid', orderStatus: 'Processing', title: 'C3706886: Validate the submission of an order with Payconiq as payment method and payment mark as "Paid" '},
{status: 'failed', orderStatus: 'Canceled', title: 'C3706887: Validate the submission of an order with Payconiq as payment method and payment mark as "Failed"'},
{status: 'expired', orderStatus: 'Canceled', title: 'C3706888: Validate the submission of an order with Payconiq as payment method and payment mark as "Expired" '},
{status: 'canceled', orderStatus: 'Canceled', title: 'C3706889: Validate the submission of an order with Payconiq as payment method and payment mark as "Canceled" '},
].forEach((testCase) => {
it(testCase.title, () => {
visitCheckoutPayment.visit('BE');

cy.intercept('mollie/checkout/redirect/paymentToken/*').as('mollieRedirect');

checkoutPaymentPage.selectPaymentMethod('Payconiq');
checkoutPaymentPage.placeOrder();

mollieHostedPaymentPage.selectStatus(testCase.status);

if (testCase.status === 'paid') {
checkoutSuccessPage.assertThatOrderSuccessPageIsShown();
}

if (testCase.status === 'canceled') {
cartPage.assertCartPageIsShown();
}

cy.backendLogin();

cy.get('@order-id').then((orderId) => {
ordersPage.openOrderById(orderId);
});

if (testCase.status === 'expired') {
ordersPage.callFetchStatus();
}

ordersPage.assertOrderStatusIs(testCase.orderStatus);
});
});
})
}
15 changes: 15 additions & 0 deletions Test/End-2-end/cypress/fixtures/belgian-shipping-address.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"type": {
"username": "[email protected]",
"firstname": "Anna",
"company": "Acme Firma BVBA",
"lastname": "Schmidt",
"street[0]": "Voorbeeldstraat 1",
"city": "Brussel",
"postcode": "1000",
"telephone": "+32 2 XXXXXXX"
},
"select": {
"country_id": "BE"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ export default class VisitCheckoutPaymentCompositeAction {
}

fillAddress(fixture, asCustomer = false) {
if (asCustomer) {
checkoutShippingPage.skipUsername();
}
if (asCustomer) {
checkoutShippingPage.skipUsername();
}

if (fixture === 'BE') {
checkoutShippingPage.fillBelgianShippingAddress();
return;
}

if (fixture === 'DE') {
checkoutShippingPage.fillGermanShippingAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export default class CheckoutShippingPage {
});
}

fillBelgianShippingAddress() {
cy.fixture('belgian-shipping-address').then((address) => {
this.fillShippingAddress(address);
});
}

fillGermanShippingAddress() {
cy.fixture('german-shipping-address').then((address) => {
this.fillShippingAddress(address);
Expand Down
1 change: 1 addition & 0 deletions Test/Integration/Etc/Config/MethodsConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function methods(): array
['mollie_methods_paypal'],
['mollie_methods_paysafecard'],
['mollie_methods_pointofsale'],
['mollie_methods_payconiq'],
['mollie_methods_przelewy24'],
['mollie_methods_riverty'],
['mollie_methods_sofort'],
Expand Down
1 change: 1 addition & 0 deletions Test/Integration/Helper/GeneralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public function getMethodCodeDataProvider()
'paypal' => ['mollie_methods_paypal', 'paypal'],
'paysafecard' => ['mollie_methods_paysafecard', 'paysafecard'],
'pointofsale' => ['mollie_methods_pointofsale', 'pointofsale'],
'payconiq' => ['mollie_methods_payconiq', 'payconiq'],
'przelewy24' => ['mollie_methods_przelewy24', 'przelewy24'],
'riverty' => ['mollie_methods_riverty', 'riverty'],
'sofort' => ['mollie_methods_sofort', 'sofort'],
Expand Down
Loading

0 comments on commit cc70022

Please sign in to comment.