I’m working on Magento 2 upgrade from 2.2.9 to 2.4.3
and I’m having an issue with an on-line payment.
Here is the deal, after payment the following callback executes
public function execute()
{
$getData = $this->_request->getParams();
$quoteId = $this->helper->getQuoteId($getData['quoteId']);
$response = $this->helperConnect->getRequest($this->helperConnect->prepareRequest($getData));
if ($this->validator->validates($response)) {
if ($this->paymentProcessor->approveOrder($quoteId, $response)){
$this->logger->addInfo('Callback action before redirect to datafast success action');
$this->logger->addInfo('QuoteId: ' . $quoteId);
//$this->registry->register('datafast_lastSuccessQuoteId',$quoteId);
//$this->requestHelper->setLastQuoteId($quoteId);
//$this->logger->addInfo('checkout session last success quote ' . $this->checkoutSession->getLastSuccessQuoteId());
//$this->logger->addInfo('session Id: ' . $this->checkoutSession->getSessionId());
//return $this->_redirect(self::REDIRECT_TO_SUCCESS, ['_secure' => true]);
$this->resultRedirect->setPath(self::REDIRECT_TO_SUCCESS);
} else {
$this->resultRedirect->setPath(self::REDIRECT_TO_CART);
}
} else {
$this->logger->addCallbackLog("Payment was rejected and Datafast send this data",$response);
$incrementId = $this->paymentProcessor->cancelOrder($quoteId, $response);
if (isset($incrementId)) {
$this->resultRedirect->setPath(self::REDIRECT_TO_FAILED);
} else {
$this->resultRedirect->setPath(self::REDIRECT_TO_CART);
}
}
return $this->resultRedirect;
}
By this point, checkout session has a correct last success quote id.
But when it redirects to success page last success quote id is null, thus it fails validation and redirect to empty cart.
I have also made attemps to set it in registry (I know it’s not good practice but i’m desperate) and a custom helper class these are not present either when it get’s to
MagentoCheckoutModelSessionSuccessValidator
These are not set either. As further info, session seems to be the same since checkoutSession->getId() returns the same in controller and success validator.
Any ideas on how to solve this would be very appreciated.
Thanks in advance