CyberSource / cybersource-rest-client-php

PHP client library for the CyberSource REST API
27 stars 65 forks source link

Method CyberSource\Model\CheckPayerAuthEnrollmentRequest::__toString() must return a string value #130

Closed lucianoob closed 11 months ago

lucianoob commented 1 year ago

Hi,

I have some transactions in use with the PHP SDK returning this message that shows an error inside the lib. What can be wrong in the implementation?

{
  "code": 0,
  "trace": "#0 /app/vendor/cybersource/rest-client-php/lib/Api/PayerAuthenticationApi.php(109): CyberSource\\Api\\PayerAuthenticationApi->checkPayerAuthEnrollmentWithHttpInfo()\n#1",
  "message": "Method CyberSource\\Model\\CheckPayerAuthEnrollmentRequest::__toString() must return a string value"
}

And my code just sends the requestObj: image

And then it performs payer authentication (line 204 where the error warns) : image

PS.: only a few transactions point to this error (~2% - ~4%), so the implementation works.

lucianoob commented 11 months ago

After some time researching, I understood the problem that was occurring. Here in Brazil, since we speak Portuguese, we have many words with accents, and this caused the issue when converting the object to a string due to a poorly prepared implementation within the SDK.

The starting point of the problem begins in the method below (highlighted line): Captura de tela de 2023-09-26 16-13-09

When executing this entire method, at the end, there is a deserialization in the "return" statement: image

When executing this "deserialize" operation, there is an automatic execution of the "__toString()" method of the "vendor/cybersource/rest-client-php/lib/Model/RiskV1AuthenticationsPost201Response.php" model: Captura de tela de 2023-09-26 16-22-48

This method fails to convert the "firstName," "lastName," "address1," and "address2" fields with accents to strings.

Well, the solution was to remove these special characters from these fields and send them without accents.

Thank you!

Note: The version of the SDK used was v0.0.40 (the current version still has this issue).