Invalid Payment Authorized and Completed Dates

Created on 6 August 2022, over 2 years ago
Updated 19 September 2024, 2 months ago

Problem/Motivation

I've noticed that the "authorized" and "completed" dates are being displayed as "12/31/1969 - 19:33" for all of my completed orders. The value I see in my database for each of those dates is "2022", which doesn't correspond to the actual time value for the transaction. The issue appears to be that the response from Square returns formatted dates (like "2022-08-06T17:14:42.283Z") for the values of authorized_at and captured_at, instead of Unix time stamp values.

Steps to reproduce

Process an order.
Display the payment summary.

Proposed resolution

Convert the date-time values returned from Square to Unix time stamp values and store the converted values with the payment transaction. Would this work (in file src/Plugin/Commerce/PaymentGateway/Square.php)?

294          $payment->setAuthorizedTime(strtotime($payment_response->getPayment()->getCreatedAt()));
295          if ($capture) {
296            $payment->setCompletedTime(strtotime($payment_response->getPayment()->getCreatedAt()));
297          }
298          else {
299            $expires = $this->time->getRequestTime() + (3600 * 24 * 6) - 5;
300            $payment->setExpiresTime($expires);
301          }
🐛 Bug report
Status

Fixed

Version

1.5

Component

Code

Created by

🇺🇸United States sah62 US

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024