Skip to content

Commit

Permalink
Merge pull request #70 from afterpay/feature/more-dm-data-to-checkout…
Browse files Browse the repository at this point in the history
…-EIT-3646

Feature: EIT-3646
  • Loading branch information
benfterpay authored Jan 18, 2024
2 parents 898f5d0 + 22b2c20 commit dd139a5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 15 additions & 2 deletions src/HTTP/Response/CreateCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down

0 comments on commit dd139a5

Please sign in to comment.