Skip to content

Commit

Permalink
Improve device data handling
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinDamyanovAmpeco committed Oct 16, 2024
1 parent e872abb commit 154d16d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ampeco/omnipay-wl-valina",
"description": "Omnipay plugin for Worldline Valina",
"version": "1.3.5",
"version": "1.3.6",
"type": "library",
"license": "MIT",
"autoload": {
Expand Down
34 changes: 20 additions & 14 deletions src/Message/InitialPurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,28 @@ public function getData(): array

public function getCustomerData(): array
{
$deviceData = [
'acceptHeader' => $this->getAcceptHeader(),
'browserData' => array_filter([
'colorDepth' => $this->getColorDepth(),
'javaEnabled' => true,
'javaScriptEnabled' => true,
'screenHeight' => $this->getScreenHeight(),
'screenWidth' => $this->getScreenWidth(),
], fn ($value) => true),
'ipAddress' => $this->getIpAddress(),
'locale' => $this->getLocale(),
'timezoneOffsetUtcMinutes' => $this->getTimezoneOffsetUtcMinutes(),
'userAgent' => $this->getUserAgent(),
];

if ($deviceData['ipAddress'] === null) {
unset($deviceData['ipAddress']);
}

return [
'customer' => [
'device' => [
'acceptHeader' => $this->getAcceptHeader(),
'browserData' => [
'colorDepth' => $this->getColorDepth(),
'javaEnabled' => true,
'javaScriptEnabled' => true,
'screenHeight' => $this->getScreenHeight(),
'screenWidth' => $this->getScreenWidth(),
],
'ipAddress' => $this->getIpAddress(),
'locale' => $this->getLocale(),
'timezoneOffsetUtcMinutes' => $this->getTimezoneOffsetUtcMinutes(),
'userAgent' => $this->getUserAgent(),
],
'device' => $deviceData,
'contactDetails' => [
'emailAddress' => $this->getEmail(),
],
Expand Down

0 comments on commit 154d16d

Please sign in to comment.