globalpayments / php-sdk

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

MERCHANT_RESPONSE_URL supposed to be optional, but being enforced #122

Closed johnrix closed 9 months ago

johnrix commented 10 months ago

This new code in Services\HostedService.php introduced on September 7th 2023 is causing me some problems at the minute. Essentially, if I don't supply a merchantResponseUrl in my HostedPaymentData object when initiating a charge, the code below corrupts the already successfully decoded response, precipitating the error message "SHA hash is missing. Please check your code and the Developers Documentation."

        if (!isset($response['MERCHANT_RESPONSE_URL'])) {
            $response = $this->mapTransactionStatusResponse($response);
        }

Given that the MERCHANT_RESPONSE_URL field is optional, the above logic seems flawed to me. Without knowing fully the reason for the new code and just reading between the lines, it seems like the if-condition is not specifically related to the MERCHANT_RESPONSE_URL field but rather perhaps is just intended to check if the decoded field list is in upper snake case or in camel case, and so should instead be comparing one of the mandatory fields instead.

ahumulescu commented 9 months ago

Hello,

Thank you for raising this issue!

It has been fixed in the latest version: https://github.com/globalpayments/php-sdk/blob/master/src/Services/HostedService.php#L140