globalpayments / php-sdk

GNU General Public License v2.0
49 stars 66 forks source link

3DS curl requests have Boolean FALSE values omitted #32

Closed footfish closed 2 years ago

footfish commented 5 years ago

If a boolean value is FALSE the parameter is not sent in the curl request. This problem happens when data is translated to request. This will may lead to some requests failing, for example authorisation would fail if java_enabled was missing because browser has value set to false ($browserData->javaEnabled = false).

Take example of collected browser data field javaScriptEnabled. Below is dump of translation (see)

object(GlobalPayments\Api\Entities\BrowserData)#10 (11) {
  ["acceptHeader"]=>
  string(13) "92.251.152.49"
  ["colorDepth"]=>
  string(16) "TWENTY_FOUR_BITS"
  ["ipAddress"]=>
  string(13) "92.251.152.49"
  ["javaEnabled"]=>
  bool(true)
["javaScriptEnabled"]=> ** <---- MISSING IN REQUEST TRANSLATION  ** 
  bool(false)
  ["language"]=>
  string(5) "en-US"
  ["screenHeight"]=>
  int(1050)
  ["screenWidth"]=>
  int(1680)
  ["challengWindowSize"]=>
  string(16) "WINDOWED_600X400"
  ["timeZone"]=>
  int(-1)
  ["userAgent"]=>
  string(114) "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"
}
//TRANSLATED TO REQUEST ARRAY
array(10) {
  ["accept_header"]=>
  string(13) "92.251.152.49"
  ["color_depth"]=>
  string(16) "TWENTY_FOUR_BITS"
  ["ip"]=>
  string(13) "92.251.152.49"
  ["java_enabled"]=>
  bool(true)
  ["language"]=>
  string(5) "en-US"
  ["screen_height"]=>
  int(1050)
  ["screen_width"]=>
  int(1680)
  ["challenge_window_size"]=>
  string(16) "WINDOWED_600X400"
  ["timezone"]=>
  int(-1)
  ["user_agent"]=>
  string(114) "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"
}

Suggested fix /src/Gateways/Gp3DSProvider.php

change Line 75# if ($value != null) { to Line 75# if(!is_null($value) {