From d5c7848fca2229af4d89cecc57cf57596af8b965 Mon Sep 17 00:00:00 2001 From: Christian Dangl Date: Tue, 28 Nov 2023 15:44:01 +0100 Subject: [PATCH] MOL-1278: fix ideal issuer reset leads to wrong url --- src/Controller/StoreApi/iDEAL/iDealControllerBase.php | 6 ++++++ src/Controller/Storefront/iDEAL/iDealControllerBase.php | 6 ++++++ src/Handler/Method/iDealPayment.php | 1 + .../src/mollie-payments/plugins/ideal-issuer.plugin.js | 8 +++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Controller/StoreApi/iDEAL/iDealControllerBase.php b/src/Controller/StoreApi/iDEAL/iDealControllerBase.php index aee0d3748..77e8560a5 100644 --- a/src/Controller/StoreApi/iDEAL/iDealControllerBase.php +++ b/src/Controller/StoreApi/iDEAL/iDealControllerBase.php @@ -5,6 +5,7 @@ use Kiener\MolliePayments\Controller\StoreApi\iDEAL\Response\IssuersResponse; use Kiener\MolliePayments\Controller\StoreApi\iDEAL\Response\StoreIssuerResponse; use Kiener\MolliePayments\Gateway\MollieGatewayInterface; +use Kiener\MolliePayments\Handler\Method\iDealPayment; use Kiener\MolliePayments\Service\CustomerService; use Shopware\Core\Checkout\Customer\CustomerEntity; use Shopware\Core\Framework\Routing\Annotation\RouteScope; @@ -83,6 +84,11 @@ public function saveIssuer(string $customerId, string $issuerId, SalesChannelCon throw new \Exception('Customer with ID ' . $customerId . ' not found in Shopware'); } + # if we have a "reset" value, then empty our stored issuer + if ($issuerId === iDealPayment::ISSUER_RESET_VALUE) { + $issuerId = ''; + } + $result = $this->customerService->setIDealIssuer( $customer, $issuerId, diff --git a/src/Controller/Storefront/iDEAL/iDealControllerBase.php b/src/Controller/Storefront/iDEAL/iDealControllerBase.php index 23ce1dfe3..1c764cca3 100644 --- a/src/Controller/Storefront/iDEAL/iDealControllerBase.php +++ b/src/Controller/Storefront/iDEAL/iDealControllerBase.php @@ -2,6 +2,7 @@ namespace Kiener\MolliePayments\Controller\Storefront\iDEAL; +use Kiener\MolliePayments\Handler\Method\iDealPayment; use Kiener\MolliePayments\Service\CustomerService; use Kiener\MolliePayments\Service\SettingsService; use Kiener\MolliePayments\Setting\MollieSettingStruct; @@ -45,6 +46,11 @@ public function storeIssuer(SalesChannelContext $context, string $customerId, st { $result = null; + # if we have a "reset" value, then empty our stored issuer + if ($issuerId === iDealPayment::ISSUER_RESET_VALUE) { + $issuerId = ''; + } + $customer = $this->customerService->getCustomer($customerId, $context->getContext()); if ($customer instanceof CustomerEntity) { diff --git a/src/Handler/Method/iDealPayment.php b/src/Handler/Method/iDealPayment.php index 3c30d2790..972311422 100644 --- a/src/Handler/Method/iDealPayment.php +++ b/src/Handler/Method/iDealPayment.php @@ -17,6 +17,7 @@ class iDealPayment extends PaymentHandler /** @var string */ protected $paymentMethod = self::PAYMENT_METHOD_NAME; + public const ISSUER_RESET_VALUE = 'ideal_reset'; /** * @param array $orderData diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js index c1d6dc043..fc4085199 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js @@ -204,8 +204,14 @@ export default class MollieIDealIssuer extends Plugin { const client = new HttpClient(); + var selectedIssuer = issuersDropdown.value; + + if (selectedIssuer === undefined || selectedIssuer === null || selectedIssuer === '') { + selectedIssuer = 'ideal_reset'; + } + client.get( - shopUrl + '/mollie/ideal/store-issuer/' + customerId + '/' + issuersDropdown.value, + shopUrl + '/mollie/ideal/store-issuer/' + customerId + '/' + selectedIssuer, function () { onCompleted('issuer updated successfully'); },