Language, language version, and OS: php, 8.2, linux AWS EC2 instance
Issue description
foreach() argument must be of type array|object, null given is reported when CreditCardVerification with RiskData object/properties being null or Modification with properties being null.
Our logic tries to get string response using $braintreeErrorResponse->__toString() method call in case of BrainTree error is seen while validating/payment through braintree api
/*
* Turn all attributes into a string
*
* @param array $attributes to be turned into a string
*
* @return string|false
*/
public static function attributesToString($attributes)
{
$printableAttribs = [];
// error is here that too it is nested
--> foreach ($attributes as $key => $value) { <---
if (is_array($value)) {
--> // as this is called recursively here <---
$pAttrib = self::attributesToString($value);
} elseif ($value instanceof DateTime) {
$pAttrib = $value->format(DateTime::RFC850);
} else {
$pAttrib = $value;
}
$printableAttribs[$key] = sprintf('%s', $pAttrib);
}
return self::implodeAssociativeArray($printableAttribs);
}
General information
Issue description
foreach() argument must be of type array|object, null given
is reported when CreditCardVerification with RiskData object/properties being null or Modification with properties being null. Our logic tries to get string response using$braintreeErrorResponse->__toString()
method call in case ofBrainTree error
is seen while validating/payment through braintree api