From f045e2e18b0b60288376445c69a35f53ef487308 Mon Sep 17 00:00:00 2001 From: Jason Gillman Jr Date: Sat, 12 Jan 2019 00:40:14 -0500 Subject: [PATCH 1/3] Convert Paypal Standard IPN payment_date to system's time zone --- CRM/Core/Payment/PayPalIPN.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index e854095b902a..3784a1cfdb4c 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -394,6 +394,8 @@ public function getInput(&$input, &$ids) { $paymentDate = $this->retrieve('payment_date', 'String', FALSE); if (!empty($paymentDate)) { $receiveDateTime = new DateTime($paymentDate); + $systemTimeZone = new DateTimeZone(date_default_timezone_get()); + $receiveDateTime->setTimezone($systemTimeZone); $input['receive_date'] = $receiveDateTime->format('YmdHis'); } } From e8780288b31e6d2583b93a85e652b3e19613a708 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 12 Jan 2019 17:41:43 -0500 Subject: [PATCH 2/3] Utilize getTimeZoneString() method Co-Authored-By: jgillmanjr --- CRM/Core/Payment/PayPalIPN.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index 3784a1cfdb4c..4248d1c84865 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -394,7 +394,7 @@ public function getInput(&$input, &$ids) { $paymentDate = $this->retrieve('payment_date', 'String', FALSE); if (!empty($paymentDate)) { $receiveDateTime = new DateTime($paymentDate); - $systemTimeZone = new DateTimeZone(date_default_timezone_get()); + $systemTimeZone = new DateTimeZone(CRM_Core_Config::singleton()->userSystem->getTimeZoneString()); $receiveDateTime->setTimezone($systemTimeZone); $input['receive_date'] = $receiveDateTime->format('YmdHis'); } From 6800eef17283b8065b9ab2bb51e90441bbba8301 Mon Sep 17 00:00:00 2001 From: Jason Gillman Jr Date: Mon, 14 Jan 2019 10:57:34 -0500 Subject: [PATCH 3/3] Quick comment describing need for IPN TZ adjustment --- CRM/Core/Payment/PayPalIPN.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index 4248d1c84865..6af63aaeeec3 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -394,6 +394,10 @@ public function getInput(&$input, &$ids) { $paymentDate = $this->retrieve('payment_date', 'String', FALSE); if (!empty($paymentDate)) { $receiveDateTime = new DateTime($paymentDate); + /** + * The `payment_date` that Paypal sends back is in their timezone. Example return: 08:23:05 Jan 11, 2019 PST + * Subsequently, we need to account for that, otherwise the recieve time will be incorrect for the local system + */ $systemTimeZone = new DateTimeZone(CRM_Core_Config::singleton()->userSystem->getTimeZoneString()); $receiveDateTime->setTimezone($systemTimeZone); $input['receive_date'] = $receiveDateTime->format('YmdHis');