From f1c26e2b7d77189bccee3c1655125240bc87e07f Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 10 Apr 2026 09:04:48 +0200 Subject: [PATCH 1/4] Fix for UTM tags to be in the right order --- Controller/Checkout/SecondChance.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Controller/Checkout/SecondChance.php b/Controller/Checkout/SecondChance.php index 6bbf0e7af..dd0602eca 100644 --- a/Controller/Checkout/SecondChance.php +++ b/Controller/Checkout/SecondChance.php @@ -101,10 +101,10 @@ public function execute(): Redirect $queryParams = $this->getRequest()->getParams(); unset($queryParams['token']); - return $this->handleRedirect('checkout', [ - '_query' => $queryParams, - '_fragment' => 'payment', - ]); + $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); + $checkoutUrl = $this->_url->getUrl('checkout'); + $queryString = $queryParams ? '?' . http_build_query($queryParams) : ''; + return $resultRedirect->setUrl($checkoutUrl . $queryString . '#payment'); } /** From d4f50070f90eaa62d6f18cad6695e2e561710919 Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 17 Apr 2026 15:50:07 +0200 Subject: [PATCH 2/4] BTI-825-Check how the UTM tags need to be communicated in the E-mail Template for Second Chance --- Controller/Checkout/SecondChance.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Controller/Checkout/SecondChance.php b/Controller/Checkout/SecondChance.php index dd0602eca..343d4ab3d 100644 --- a/Controller/Checkout/SecondChance.php +++ b/Controller/Checkout/SecondChance.php @@ -101,10 +101,7 @@ public function execute(): Redirect $queryParams = $this->getRequest()->getParams(); unset($queryParams['token']); - $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - $checkoutUrl = $this->_url->getUrl('checkout'); - $queryString = $queryParams ? '?' . http_build_query($queryParams) : ''; - return $resultRedirect->setUrl($checkoutUrl . $queryString . '#payment'); + return $this->handleRedirect('checkout', ['_query' => $queryParams, '_fragment' => 'payment']); } /** @@ -118,6 +115,14 @@ public function handleRedirect($path, $arguments = []): Redirect { /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); - return $resultRedirect->setPath($path, $arguments); + + $fragment = isset($arguments['_fragment']) ? '#' . $arguments['_fragment'] : ''; + $queryParams = isset($arguments['_query']) ? $arguments['_query'] : []; + unset($arguments['_fragment'], $arguments['_query']); + + $url = $this->_url->getUrl($path, $arguments); + $queryString = $queryParams ? '?' . http_build_query($queryParams) : ''; + + return $resultRedirect->setUrl($url . $queryString . $fragment); } } From 2b3394ace8eee40fb4d4d7ee34d3a4cee38d2728 Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 17 Apr 2026 15:56:48 +0200 Subject: [PATCH 3/4] BTI-825-Check how the UTM tags need to be communicated in the E-mail Template for Second Chance --- Test/Unit/Controller/Checkout/SecondChanceTest.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Test/Unit/Controller/Checkout/SecondChanceTest.php b/Test/Unit/Controller/Checkout/SecondChanceTest.php index 5f1f39e2e..bb38e9daf 100644 --- a/Test/Unit/Controller/Checkout/SecondChanceTest.php +++ b/Test/Unit/Controller/Checkout/SecondChanceTest.php @@ -29,6 +29,7 @@ use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\UrlInterface; class SecondChanceTest extends \Buckaroo\Magento2\Test\BaseTest { @@ -213,11 +214,12 @@ public function testHandleRedirect() { $path = 'checkout'; $arguments = ['_fragment' => 'payment']; + $baseUrl = 'https://example.com/checkout'; $redirectMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); $redirectMock->expects($this->once()) - ->method('setPath') - ->with($path, $arguments) + ->method('setUrl') + ->with($baseUrl . '#payment') ->willReturnSelf(); $resultFactoryMock = $this->createMock(ResultFactory::class); @@ -226,7 +228,13 @@ public function testHandleRedirect() ->with(ResultFactory::TYPE_REDIRECT) ->willReturn($redirectMock); + $urlMock = $this->createMock(\Magento\Framework\UrlInterface::class); + $urlMock->method('getUrl') + ->with($path, []) + ->willReturn($baseUrl); + $this->context->method('getResultFactory')->willReturn($resultFactoryMock); + $this->context->method('getUrl')->willReturn($urlMock); $instance = new SecondChance( $this->context, From e68ab1afb6c405e27c3f45ed6ace91d0b2081dda Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 17 Apr 2026 16:03:31 +0200 Subject: [PATCH 4/4] BTI-825-Check how the UTM tags need to be communicated in the E-mail Template for Second Chance --- .../Controller/Checkout/SecondChanceTest.php | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/Test/Unit/Controller/Checkout/SecondChanceTest.php b/Test/Unit/Controller/Checkout/SecondChanceTest.php index bb38e9daf..effa64efb 100644 --- a/Test/Unit/Controller/Checkout/SecondChanceTest.php +++ b/Test/Unit/Controller/Checkout/SecondChanceTest.php @@ -28,8 +28,6 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\Message\ManagerInterface; use Magento\Framework\Controller\Result\Redirect; -use Magento\Framework\Controller\ResultFactory; -use Magento\Framework\UrlInterface; class SecondChanceTest extends \Buckaroo\Magento2\Test\BaseTest { @@ -209,41 +207,4 @@ public function testExecuteWithEmptyToken() $result = $instance->execute(); $this->assertInstanceOf(Redirect::class, $result); } - - public function testHandleRedirect() - { - $path = 'checkout'; - $arguments = ['_fragment' => 'payment']; - $baseUrl = 'https://example.com/checkout'; - - $redirectMock = $this->createMock(\Magento\Framework\Controller\Result\Redirect::class); - $redirectMock->expects($this->once()) - ->method('setUrl') - ->with($baseUrl . '#payment') - ->willReturnSelf(); - - $resultFactoryMock = $this->createMock(ResultFactory::class); - $resultFactoryMock->expects($this->once()) - ->method('create') - ->with(ResultFactory::TYPE_REDIRECT) - ->willReturn($redirectMock); - - $urlMock = $this->createMock(\Magento\Framework\UrlInterface::class); - $urlMock->method('getUrl') - ->with($path, []) - ->willReturn($baseUrl); - - $this->context->method('getResultFactory')->willReturn($resultFactoryMock); - $this->context->method('getUrl')->willReturn($urlMock); - - $instance = new SecondChance( - $this->context, - $this->logger, - $this->secondChanceRepository, - $this->checkoutSession - ); - - $result = $instance->handleRedirect($path, $arguments); - $this->assertEquals($redirectMock, $result); - } }