globalpayments / php-sdk

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

HostedService::parseResponse generates warnings for non-existent array keys #50

Closed JeremySkinner closed 2 years ago

JeremySkinner commented 4 years ago

Hi,

The GlobalPayments\Api\Services\HostedService::parseResponse method is used to deserialize JSON coming from the HPP form. However, several of the array keys that it expects to find are optional. For example, if you're just using HPP to store a card for later and not actually charge it, or you aren't collecting the CVV number, the following warnings end up being generated:

PHP Notice:  Undefined index: PASREF in globalpayments/php-sdk/src/Services/HostedService.php on line 108
PHP Notice:  Undefined index: AUTHCODE in globalpayments/php-sdk/src/Services/HostedService.php on line 109
PHP Notice:  Undefined index: CVNRESULT in globalpayments/php-sdk/src/Services/HostedService.php on line 133
PHP Notice:  Undefined index: AVSPOSTCODERESULT in globalpayments/php-sdk/src/Services/HostedService.php on line 136

This was not an issue in the old rxp-hpp-php SDK, as that would correctly handle null/missing optional values.

Proposed solution

You should check the array keys exist before trying to access them.