From cc0350e76eddb3f0af52159e11a230e8b3d09847 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Sep 2015 11:42:19 -0500 Subject: [PATCH 1/3] Using microtime() instead of time() for the $timestamp in hmacAuthorizationToken() --- payeezy_php/example/src/Payeezy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/payeezy_php/example/src/Payeezy.php b/payeezy_php/example/src/Payeezy.php index 96d1db4..bf8d038 100755 --- a/payeezy_php/example/src/Payeezy.php +++ b/payeezy_php/example/src/Payeezy.php @@ -391,7 +391,7 @@ public function hmacAuthorizationToken($payload) $nonce = strval(hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong)))); - $timestamp = strval(time()*1000); //time stamp in milli seconds + $timestamp = sprintf("%.0f", microtime(true) * 1000); $data = self::$apiKey . $nonce . $timestamp . self::$merchantToken . $payload; From 155f20bef80e55dc707eb5f3afcce42f72d8564c Mon Sep 17 00:00:00 2001 From: "C. M. Garvin" Date: Fri, 1 Apr 2016 11:06:19 -0500 Subject: [PATCH 2/3] Timestamp: microtime() instead of microtime(true) Instead of using microtime(true) to generate a millisecond timestamp, switched to a more accurate microtime() method (although for milliseconds, microtime(true) and microtime() methods were always the same in my testing). --- payeezy_php/example/src/Payeezy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/payeezy_php/example/src/Payeezy.php b/payeezy_php/example/src/Payeezy.php index bf8d038..6e520af 100755 --- a/payeezy_php/example/src/Payeezy.php +++ b/payeezy_php/example/src/Payeezy.php @@ -391,7 +391,7 @@ public function hmacAuthorizationToken($payload) $nonce = strval(hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong)))); - $timestamp = sprintf("%.0f", microtime(true) * 1000); + $timestamp = sprintf('%.0f', array_sum(explode(' ', microtime())) * 1000); $data = self::$apiKey . $nonce . $timestamp . self::$merchantToken . $payload; From 38842e0f5f7f5f959bef45faf5b2624ea356e480 Mon Sep 17 00:00:00 2001 From: "C. M. Garvin" Date: Fri, 1 Apr 2016 11:11:20 -0500 Subject: [PATCH 3/3] Added "timestamp in milliseconds" comment Left it off in previous commits and shouldn't have. --- payeezy_php/example/src/Payeezy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/payeezy_php/example/src/Payeezy.php b/payeezy_php/example/src/Payeezy.php index 6e520af..b37ec30 100755 --- a/payeezy_php/example/src/Payeezy.php +++ b/payeezy_php/example/src/Payeezy.php @@ -391,7 +391,7 @@ public function hmacAuthorizationToken($payload) $nonce = strval(hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong)))); - $timestamp = sprintf('%.0f', array_sum(explode(' ', microtime())) * 1000); + $timestamp = sprintf('%.0f', array_sum(explode(' ', microtime())) * 1000); // timestamp in milliseconds $data = self::$apiKey . $nonce . $timestamp . self::$merchantToken . $payload;