Adyen / adyen-magento2

Adyen Payment plugin for Magento2
MIT License
150 stars 196 forks source link

Unable to get payment creation date #2647

Open RomanMoshchytskiy opened 1 month ago

RomanMoshchytskiy commented 1 month ago

Describe the bug In our custom code, we try to get the payment created date, but we encounter this TypeError:

TypeError: Adyen\Payment\Model\Order\Payment::getCreatedAt(): Return value must be of type DateTime, string returned in /vendor/adyen/module-payment/Model/Order/Payment.php:122

Magento version 2.4.5-p7

Plugin version 9.5.0

RokPopov commented 1 month ago

Hi @RomanMoshchytskiy,

Thank you for raising this issue with us. Investigating on this, our plugin is setting the createdAt field in adyen_order_payment table here, and the type being passed to the DB is DateTime. Checking the value stored in the database while testing this flow, I can indeed confirm it to be a DateTime. I would suggest checking whether there are any customizations on your end that are interfering with how our plugin is storing this field in the database.

Kind regards, Rok

RomanMoshchytskiy commented 4 weeks ago

@RokPopov Yes, it is stored as a DateTime in the database, but when it was fetched from the database, it was returned as a string.

Here is the \Adyen\Payment\Model\Order\Payment object taken from the database image

As you can see the dates here are in string format.

So, at least for \Adyen\Payment\Model\Order\Payment::getCreatedAt() the return type of the function must be string.