Skip to content

Commit

Permalink
Merge branch 'bugfix/issuer-list-type-default' into release-week-45
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed Nov 6, 2023
2 parents b8e4830 + c03b4ec commit c4b4c46
Show file tree
Hide file tree
Showing 8 changed files with 925 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/end-2-end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ jobs:
MAGENTO_URL=$(docker exec magento-project-community-edition /bin/bash -c "curl -s ngrok:4040/api/tunnels |jq -r \".tunnels[0].public_url\"")
echo "magento_url=$MAGENTO_URL" >> $GITHUB_ENV
# Note the `mollie-pwa.html` file, as it is copied to the pub folder. This is so that it can be accessed by Cypress.
- name: Upload the code into the docker container
run: |
sed -i '/version/d' ./composer.json && \
docker cp $(pwd) magento-project-community-edition:/data/extensions/ && \
docker cp $(pwd)/Test/End-2-end/cypress/fixtures/mollie-pwa.html magento-project-community-edition:/data/pub/opt/ && \
docker exec magento-project-community-edition ./install-composer-package mollie/magento2:@dev
- name: Activate the extension
Expand Down
16 changes: 16 additions & 0 deletions Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Config
const PAYMENT_CREDITCARD_USE_COMPONENTS = 'payment/mollie_methods_creditcard/use_components';
const PAYMENT_CREDITCARD_ENABLE_CUSTOMERS_API = 'payment/mollie_methods_creditcard/enable_customers_api';
const PAYMENT_BANKTRANSFER_STATUS_PENDING = 'payment/mollie_methods_banktransfer/order_status_pending';
const PAYMENT_METHOD_ISSUER_LIST_TYPE = 'payment/mollie_methods_%s/issuer_list_type';
const PAYMENT_METHOD_PAYMENT_ACTIVE = 'payment/mollie_methods_%s/active';
const PAYMENT_METHOD_PAYMENT_DESCRIPTION = 'payment/mollie_methods_%s/payment_description';
const PAYMENT_METHOD_PAYMENT_SURCHARGE_FIXED_AMOUNT = 'payment/mollie_methods_%s/payment_surcharge_fixed_amount';
Expand All @@ -73,6 +74,7 @@ class Config
const PAYMENT_VOUCHER_CUSTOM_ATTRIBUTE = 'payment/mollie_methods_voucher/custom_attribute';
const CURRENCY_OPTIONS_DEFAULT = 'currency/options/default';


/**
* @var ScopeConfigInterface
*/
Expand Down Expand Up @@ -726,6 +728,20 @@ public function encryptPaymentDetails($storeId = null): bool
return $this->isSetFlag(static::GENERAL_ENCRYPT_PAYMENT_DETAILS, $storeId);
}

/**
* @param string $method
* @param null|int|string $storeId
*
* @return string
*/
public function getIssuerListType(string $method, $storeId = null): string
{
return $this->getPath(
$this->addMethodToPath(static::PAYMENT_METHOD_ISSUER_LIST_TYPE, $method),
$storeId
) ?? 'none';
}

/**
* @param $method
* @return string
Expand Down
4 changes: 3 additions & 1 deletion Helper/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,16 @@ public function useImage($storeId = null)
}

/**
* @deprecated See \Mollie\Payment\Config::getIssuerListType instead
*
* @param string $method
*
* @return mixed
*/
public function getIssuerListType(string $method): string
{
$methodXpath = str_replace('%method%', $method, self::XPATH_ISSUER_LIST_TYPE);
return $this->getStoreConfig($methodXpath);
return $this->getStoreConfig($methodXpath) ?? 'none';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Model/MollieConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function getActiveMethods(MollieApiClient $mollieApi, CartInterface $cart
*/
private function getIssuers(MollieApiClient $mollieApi, string $code, array $config): array
{
$issuerListType = $this->mollieHelper->getIssuerListType($code);
$issuerListType = $this->config->getIssuerListType($code, $this->storeManager->getStore()->getId());
$config['payment']['issuersListType'][$code] = $issuerListType;
$config['payment']['issuers'][$code] = $this->getIssuers->execute($mollieApi, $code, $issuerListType);

Expand Down
12 changes: 6 additions & 6 deletions Service/Mollie/GetIssuers.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\Locale\Resolver;
use Mollie\Api\MollieApiClient;
use Mollie\Payment\Config;
use Mollie\Payment\Helper\General;
use Mollie\Payment\Model\Mollie as MollieModel;

Expand All @@ -36,24 +37,23 @@ class GetIssuers
* @var Resolver
*/
private $resolver;

/**
* @var General
* @var Config
*/
private $general;
private $config;

public function __construct(
CacheInterface $cache,
SerializerInterface $serializer,
MollieModel $mollieModel,
Resolver $resolver,
General $general
Config $config
) {
$this->cache = $cache;
$this->serializer = $serializer;
$this->mollieModel = $mollieModel;
$this->resolver = $resolver;
$this->general = $general;
$this->config = $config;
}

/**
Expand Down Expand Up @@ -106,7 +106,7 @@ public function getForGraphql($storeId, string $method): ?array
$issuers = $this->execute(
$mollieApi,
$method,
$this->general->getIssuerListType($method)
$this->config->getIssuerListType($method)
);

if (!$issuers) {
Expand Down
50 changes: 50 additions & 0 deletions Test/End-2-end/cypress/e2e/magento/graphql/place-order.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright Magmodules.eu. All rights reserved.
* See COPYING.txt for license details.
*/

import Cookies from "Services/Cookies";
import MollieHostedPaymentPage from "Pages/mollie/MollieHostedPaymentPage";
import CheckoutSuccessPage from "Pages/frontend/CheckoutSuccessPage";
import OrdersPage from "Pages/backend/OrdersPage";

const cookies = new Cookies();
const mollieHostedPaymentPage = new MollieHostedPaymentPage();
const checkoutSuccessPage = new CheckoutSuccessPage();
const ordersPage = new OrdersPage();

describe('Check that the headless endpoints work as expected', () => {
it('C1835263: Validate that an order can be placed through GraphQL ', () => {
cy.visit('opt/mollie-pwa.html');

cy.get('[data-key="start-checkout-process"]').click();

cy.get('[data-key="mollie_methods_ideal"]').click();

cy.get('[data-key="mollie_methods_ideal-issuer"]').first().click();

cy.get('[data-key="place-order-action"]').click();

cy.get('[data-key="increment-id"]').then((element) => {
cy.wrap(element.text()).as('increment-id');
});

cookies.disableSameSiteCookieRestrictions();

cy.get('[data-key="redirect-url"]').then((element) => {
cy.visit(element.attr('href'));
});

mollieHostedPaymentPage.selectStatus('paid');

checkoutSuccessPage.assertThatOrderSuccessPageIsShown();

cy.backendLogin(false);

cy.get('@increment-id').then((incrementId) => {
ordersPage.openByIncrementId(incrementId);
});

ordersPage.assertOrderStatusIs('Processing');
});
})
Loading

0 comments on commit c4b4c46

Please sign in to comment.