emspay / magento2

Deprecation EMS Pay - Magento2 plugin
https://emspay.eu
BSD 2-Clause "Simplified" License
1 stars 1 forks source link

txndatetime and transaction not complete issue #13

Closed MagentoGuysProjects closed 4 years ago

MagentoGuysProjects commented 5 years ago

Hi,

I have installed and setup this module in my client Magento2 website but I am facing some issues which are below

  1. First I got error like date or timezone not OK

the txndatetime and timezone parameters are not valid, only current time information is supported. In many cases this is caused by an incorrect timezone parameter.

Please check below screenshot http://prntscr.com/nyp2nr

and after this I have debug and updated below code in app/code/EMS/Pay/Model/Method/EmsAbstractMethod.php

from return $this->timezone->date($this->_order->getCreatedAt())->format(Config::TXNDATE_ZEND_DATE_FORMAT);

to

$created = $this->_order->getCreatedAt();
return $this->timezone->date(new \DateTime($created))->format('Y:m:d-H:i:s');

but after that I started to get below error

Uw transactie is niet juist afgerond
De fout kan een van de volgende oorzaken hebben:

    Uw winkelnaam is niet in het systeem ingevoerd.
    De syntax van een of meer formuliervelden is onjuist.

Please check below screenshot. http://prntscr.com/nyp3g5

I am using the correct detail same as My Magento1 website and its working fine on Magento1 but not in Magento2.

So please check this issue asap. My Magento2 version is 2.3.1

Thanks

dligthart commented 5 years ago

Thanks for reporting the issue. We will look into it, meanwhile can you try to test the hash calculation using this tool https://developer.emspay.eu/hash-calculation-tool

dligthart commented 5 years ago

It seems there is something wrong the the formatting of the date on your end, can you please check if the code has been modified ?

From our tests: after updating code in

app/code/EMS/Pay/Model/Method/EmsAbstractMethod.php

from

return $this->timezone->date($this->_order->getCreatedAt())->format(Config::TXNDATE_ZEND_DATE_FORMAT);

to

$created = $this->_order->getCreatedAt();
return $this->timezone->date(new \DateTime($created))->format('Y:m:d-H:i:s');

we get the error.

This is may occur if the date format specified not correctly.

correct code

$created = $this->_order->getCreatedAt();
return $this->timezone->date(new \DateTime($created))->format(Config::TXNDATE_ZEND_DATE_FORMAT);

For a more accurate definition of the problem with the txndatetime, please provide data (txndatetime and timezone parameter) or logs (var/log/ems_pay*.log)

williankeller commented 4 years ago

HI @dligthart, Is there any plan to apply this fix it at the release level? I just cloned the repository with the source code:

/**
 * @return string
 */
protected function _getTransactionTime()
{
    return $this->timezone->date($this->_order->getCreatedAt())->format(Config::TXNDATE_ZEND_DATE_FORMAT);
}

And it's returning the error and building the wrong date: 2021:04:10-07:26:00. When I apply the changes you propose it work like a charm:

/**
 * Overriding default code because it's returning wrong date value.
 *
 * @see https://github.com/emspay/magento2/issues/13
 * @return string
 * @throws \Exception
 */
protected function _getTransactionTime()
{
    $created = $this->_order->getCreatedAt();
    return $this->timezone->date(new \DateTime($created))->format(Config::TXNDATE_ZEND_DATE_FORMAT);
}

But ideal, it should be part of the source code, isn't it?