Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/2.42.1 #838

Merged
merged 10 commits into from
Dec 4, 2024
14 changes: 13 additions & 1 deletion .github/workflows/end-2-end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,20 @@ jobs:
include:
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.3.7-p4
NO_API_KEY_TEST: false
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6-p5
NO_API_KEY_TEST: false
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.3.7-p4
NO_API_KEY_TEST: true
runs-on: ubuntu-latest
env:
PHP_VERSION: ${{ matrix.PHP_VERSION }}
MAGENTO_VERSION: ${{ matrix.MAGENTO_VERSION }}
MOLLIE_API_KEY_TEST: ${{ secrets.MOLLIE_API_KEY_TEST }}
NGROK_AUTHTOKEN: ${{ secrets.NGROK_AUTHTOKEN }}
NO_API_KEY_TEST: ${{ matrix.NO_API_KEY_TEST }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CYPRESS_TESTRAIL_DOMAIN: ${{ secrets.TESTRAIL_DOMAIN }}
CYPRESS_TESTRAIL_USERNAME: ${{ secrets.TESTRAIL_USERNAME }}
Expand Down Expand Up @@ -92,11 +98,17 @@ jobs:
run: |
docker exec magento-project-community-edition php /data/merge-config.php
docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment"
docker exec magento-project-community-edition ./retry "php bin/magento setup:upgrade --no-interaction"
docker exec magento-project-community-edition ./retry "php bin/magento setup:upgrade --keep-generated --no-interaction"
docker exec magento-project-community-edition /bin/bash /data/configure-mollie.sh
docker exec magento-project-community-edition ./retry "bin/magento config:set payment/mollie_general/use_webhooks custom_url"
docker exec magento-project-community-edition ./retry "bin/magento config:set payment/mollie_general/custom_webhook_url ${{ env.magento_url }}/mollie/checkout/webhook"

- name: Configure Mollie
run: |
if [ ${{ matrix.NO_API_KEY_TEST }} == 'false' ]; then
docker exec magento-project-community-edition /bin/bash /data/configure-mollie.sh
fi

- name: Prepare Magento
run: |
docker exec magento-project-community-edition /bin/bash ./change-base-url https://magento.test/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev

- name: Activate the extension
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade"
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade --keep-generated"

- name: Run tests
run: docker exec magento-project-community-edition bash -c "cd /data/dev/tests/integration/ && /data/vendor/bin/phpunit -c /data/dev/tests/integration/phpunit.xml"
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev

- name: Activate the extension
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade && php bin/magento setup:di:compile"
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade --keep-generated && php bin/magento setup:di:compile"

- name: Run PHPStan
continue-on-error: ${{ matrix.PHPSTAN_LEVEL == 2 }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/templates/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ services:
links:
- "nginx-proxy:magento.test"
environment:
- NO_API_KEY_TEST
- CYPRESS_TESTRAIL_DOMAIN
- CYPRESS_TESTRAIL_USERNAME
- CYPRESS_TESTRAIL_PASSWORD
Expand Down
86 changes: 39 additions & 47 deletions .github/workflows/templates/magento/configure-mollie.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,67 +9,59 @@ 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 &
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

# Enable all payment methods
bin/magento config:set payment/mollie_methods_applepay/active 1 &
bin/magento config:set payment/mollie_methods_banktransfer/active 1 &
bin/magento config:set payment/mollie_methods_billie/active 1 &
bin/magento config:set payment/mollie_methods_blik/active 1 &
bin/magento config:set payment/mollie_methods_creditcard/active 1 &
bin/magento config:set payment/mollie_methods_giftcard/active 1 &
bin/magento config:set payment/mollie_methods_ideal/active 1 &
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 &
bin/magento config:set payment/mollie_methods_belfius/active 1 &
bin/magento config:set payment/mollie_methods_eps/active 1 &
bin/magento config:set payment/mollie_methods_klarnapaylater/active 1 &
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_pointofsale/active 1 &
bin/magento config:set payment/mollie_methods_riverty/active 1 &
bin/magento config:set payment/mollie_methods_satispay/active 1 &
bin/magento config:set payment/mollie_methods_sofort/active 1 &
bin/magento config:set payment/mollie_methods_trustly/active 1 &
bin/magento config:set payment/mollie_methods_twint/active 1 &
bin/magento config:set payment/mollie_methods_applepay/active 1
bin/magento config:set payment/mollie_methods_banktransfer/active 1
bin/magento config:set payment/mollie_methods_billie/active 1
bin/magento config:set payment/mollie_methods_blik/active 1
bin/magento config:set payment/mollie_methods_creditcard/active 1
bin/magento config:set payment/mollie_methods_giftcard/active 1
bin/magento config:set payment/mollie_methods_ideal/active 1
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
bin/magento config:set payment/mollie_methods_belfius/active 1
bin/magento config:set payment/mollie_methods_eps/active 1
bin/magento config:set payment/mollie_methods_klarnapaylater/active 1
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_pointofsale/active 1
bin/magento config:set payment/mollie_methods_riverty/active 1
bin/magento config:set payment/mollie_methods_satispay/active 1
bin/magento config:set payment/mollie_methods_sofort/active 1
bin/magento config:set payment/mollie_methods_trustly/active 1
bin/magento config:set payment/mollie_methods_twint/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 &

# Disable webhooks
bin/magento config:set payment/mollie_general/use_webhooks disabled &
bin/magento config:set payment/mollie_methods_creditcard/use_components 1

# Configure currency for the swiss store view
bin/magento config:set currency/options/allow EUR,CHF,PLN &
bin/magento config:set currency/options/allow EUR,CHF,PLN

# Swiss scope
bin/magento config:set currency/options/default CHF --scope=ch &
bin/magento config:set payment/mollie_general/currency 0 --scope=ch &
bin/magento config:set currency/options/default CHF --scope=ch --scope-code=ch
bin/magento config:set payment/mollie_general/currency 0 --scope=ch --scope-code=ch

# Polish scope
bin/magento config:set currency/options/default PLN --scope=pl &
bin/magento config:set payment/mollie_general/currency 0 --scope=pl &
bin/magento config:set currency/options/default PLN --scope=pl --scope-code=pl
bin/magento config:set payment/mollie_general/currency 0 --scope=pl --scope-code=pl

# Disable the use of the base currency
bin/magento config:set payment/mollie_general/currency 0 &
bin/magento config:set payment/mollie_general/currency 0

# Insert rates, otherwise the currency switcher won't show
magerun2 db:query 'INSERT INTO `directory_currency_rate` (`currency_from`, `currency_to`, `rate`) VALUES ("EUR", "PLN", 1.0);' &
magerun2 db:query 'INSERT INTO `directory_currency_rate` (`currency_from`, `currency_to`, `rate`) VALUES ("EUR", "CHF", 1.0);' &

wait
magerun2 db:query 'INSERT INTO `directory_currency_rate` (`currency_from`, `currency_to`, `rate`) VALUES ("EUR", "PLN", 1.0);'
magerun2 db:query 'INSERT INTO `directory_currency_rate` (`currency_from`, `currency_to`, `rate`) VALUES ("EUR", "CHF", 1.0);'

if grep -q Magento_TwoFactorAuth "app/etc/config.php"; then
./retry "php bin/magento module:disable Magento_TwoFactorAuth -f"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/ && docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev

- name: Activate the extension
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade && php bin/magento setup:di:compile"
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Mollie_Payment && php bin/magento setup:upgrade --keep-generated && php bin/magento setup:di:compile"

- name: Run tests
run: docker exec magento-project-community-edition bash -c "vendor/bin/phpunit extensions/*/Test/Unit"
39 changes: 34 additions & 5 deletions Controller/ApplePay/PlaceOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Mollie\Payment\Api\Webapi\PaymentTokenRequestInterface;
use Mollie\Payment\Config;
use Mollie\Payment\Service\PaymentToken\Generate;
use Mollie\Payment\Service\Quote\SetRegionFromApplePayAddress;

class PlaceOrder extends Action
{
Expand Down Expand Up @@ -56,6 +58,14 @@ class PlaceOrder extends Action
* @var OrderRepositoryInterface
*/
private $orderRepository;
/**
* @var SetRegionFromApplePayAddress
*/
private $setRegionFromApplePayAddress;
/**
* @var Config
*/
private $config;

public function __construct(
Context $context,
Expand All @@ -64,7 +74,9 @@ public function __construct(
QuoteManagement $quoteManagement,
Session $checkoutSession,
Generate $paymentToken,
OrderRepositoryInterface $orderRepository
SetRegionFromApplePayAddress $setRegionFromApplePayAddress,
OrderRepositoryInterface $orderRepository,
Config $config
) {
parent::__construct($context);

Expand All @@ -74,6 +86,8 @@ public function __construct(
$this->checkoutSession = $checkoutSession;
$this->paymentToken = $paymentToken;
$this->orderRepository = $orderRepository;
$this->setRegionFromApplePayAddress = $setRegionFromApplePayAddress;
$this->config = $config;
}

public function execute()
Expand Down Expand Up @@ -104,8 +118,22 @@ public function execute()
$this->cartRepository->save($cart);
$cart->getPayment()->addData(['method' => 'mollie_methods_applepay']);

/** @var OrderInterface $order */
$order = $this->quoteManagement->submit($cart);
$response = $this->resultFactory->create(ResultFactory::TYPE_JSON);

try {
/** @var OrderInterface $order */
$order = $this->quoteManagement->submit($cart);
} catch (\Exception $exception) {
$this->config->addToLog('error', [
'message' => 'Error while try place Apple Pay order',
'quote_id' => $cart->getId(),
'exception' => $exception->getMessage(),
'trace' => $exception->getTraceAsString(),
]);

return $response->setData(['error' => true, 'error_message' => $exception->getMessage()]);
}

$order->getPayment()->setAdditionalInformation(
'applepay_payment_token',
$this->getRequest()->getParam('applePayPaymentToken')
Expand All @@ -126,8 +154,7 @@ public function execute()
->setLastRealOrderId($order->getIncrementId())
->setLastOrderId($order->getId());

$response = $this->resultFactory->create(ResultFactory::TYPE_JSON);
return $response->setData(['url' => $url]);
return $response->setData(['url' => $url, 'error' => false, 'error_message' => '']);
}

private function updateAddress(AddressInterface $address, array $input)
Expand All @@ -141,6 +168,8 @@ private function updateAddress(AddressInterface $address, array $input)
AddressInterface::KEY_POSTCODE => $input['postalCode'],
]);

$this->setRegionFromApplePayAddress->execute($address, $input);

if (isset($input['phoneNumber'])) {
$address->setTelephone($input['phoneNumber']);
}
Expand Down
17 changes: 17 additions & 0 deletions Model/Adminhtml/Source/PendingPaymentStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Mollie\Payment\Model\Adminhtml\Source;

use Magento\Sales\Model\Config\Source\Order\Status;

class PendingPaymentStatus extends Status
{
/**
* @var string
*/
protected $_stateStatuses = \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT;
}
12 changes: 9 additions & 3 deletions Model/MollieConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function getMethodInstance($code)
public function getConfig(): array
{
// Do not load the config when on the cart page.
if ($this->request->getControllerName() === 'cart') {
if (!$this->config->isModuleEnabled() || $this->request->getControllerName() === 'cart') {
return [];
}

Expand Down Expand Up @@ -223,10 +223,16 @@ public function getActiveMethods(CartInterface $cart = null): array

private function getIssuers(string $code, array $config): array
{
$mollieApi = $this->mollieApiClient->loadByStore();
$issuerListType = $this->config->getIssuerListType($code, $this->storeManager->getStore()->getId());
$config['payment']['issuersListType'][$code] = $issuerListType;
$config['payment']['issuers'][$code] = $this->getIssuers->execute($mollieApi, $code, $issuerListType);

try {
$mollieApi = $this->mollieApiClient->loadByStore();
$config['payment']['issuers'][$code] = $this->getIssuers->execute($mollieApi, $code, $issuerListType);
} catch (\Exception $exception) {
$this->config->addTolog('error', 'Unable to load issuers: ' . $exception->getMessage());
$config['payment']['issuers'][$code] = [];
}

return $config;
}
Expand Down
7 changes: 7 additions & 0 deletions Service/Mollie/Wrapper/MollieApiClientFallbackWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

namespace Mollie\Payment\Service\Mollie\Wrapper;

use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Exceptions\IncompatiblePlatform;
use Mollie\Api\MollieApiClient;

class MollieApiClientFallbackWrapper extends MollieApiClient
{
/**
* @throws ApiException If there's an API error during initialization.
* @throws IncompatiblePlatform If the platform is not compatible.
* @return void
*/
public function initializeEndpoints()
{
parent::initializeEndpoints();
Expand Down
Loading
Loading