From c65d2f23b3abd3b79afa30df8a6e3386f3a71607 Mon Sep 17 00:00:00 2001 From: Ben Firth Date: Thu, 18 Jan 2024 14:13:10 +1030 Subject: [PATCH 1/2] EIT-3646: Allow custom alphanumeric data to be sent to checkout. Also change `deviceId` to `device_id`. --- src/HTTP/Response/CreateCheckout.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/HTTP/Response/CreateCheckout.php b/src/HTTP/Response/CreateCheckout.php index 7374909..596ed05 100644 --- a/src/HTTP/Response/CreateCheckout.php +++ b/src/HTTP/Response/CreateCheckout.php @@ -55,10 +55,23 @@ public function afterReceive() if ($decodedCookie) { $cookieObj = json_decode($decodedCookie, false); + $urlChanged = false; - if (isset($cookieObj->deviceId)) { - $bodyObj->redirectCheckoutUrl .= "&deviceId={$cookieObj->deviceId}"; + if (isset($cookieObj->deviceId) && preg_match('/^[0-9a-z-]*$/i', $cookieObj->deviceId)) { + $bodyObj->redirectCheckoutUrl .= "&device_id={$cookieObj->deviceId}"; + $urlChanged = true; + } + + if (isset($cookieObj->checkout) && is_object($cookieObj->checkout)) { + foreach ($cookieObj->checkout as $prop => $val) { + if (preg_match('/^[0-9a-z]+$/i', $prop) && preg_match('/^[0-9a-z-]*$/i', $val)) { + $bodyObj->redirectCheckoutUrl .= "&{$prop}={$val}"; + $urlChanged = true; + } + } + } + if ($urlChanged) { $this->setRawBody(json_encode($bodyObj, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); } } From 22b2c20c6e4b3e9a2de9416ee2f47d78c0d2056e Mon Sep 17 00:00:00 2001 From: Ben Firth Date: Thu, 18 Jan 2024 14:37:49 +1030 Subject: [PATCH 2/2] Updated version + changelog --- CHANGELOG.md | 8 +++++++- composer.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2628233..7653172 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,16 @@ # Changelog +## Version 1.8.0 + +_Fri 19 Jan 2024_ + +- Updated Create Checkout response to include custom checkout properties from DM if available (EIT-3646). + ## Version 1.7.0 _Tue 02 Jan 2024_ -- Updated Create Checkout response with device id if available (EIT-3456). +- Updated Create Checkout response with Device ID if available (EIT-3456). ## Version 1.6.2 diff --git a/composer.json b/composer.json index 574a373..7e9ebc0 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "afterpay-global/afterpay-sdk-php", "license": "Apache-2.0", "description": "Official Afterpay SDK for PHP", - "version": "1.7.0", + "version": "1.8.0", "authors": [ { "name": "Afterpay",