globalpayments / php-sdk

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

Unexpected Gateway Response: 506 caused by incorrect IP address in test #67

Closed jszoja closed 2 years ago

jszoja commented 3 years ago

Getting the following exception when testing:

1) GlobalPayments\Api\Tests\Integration\Gateways\RealexConnector\Certifications\RealexSdkCertification::testManual031c1
GlobalPayments\Api\Entities\Exceptions\GatewayException: Unexpected Gateway Response: 506 - The line number 2 which contains 'request timestamp="20201130165922" type="auth"]  [merchantid] heartlandgpsandbox [/merchantid]  [account] api [/account]  [orderid] NDRjMzJjYTAtNzAzMzNkMA [/orderid]  [amount currency="USD"] 10001 [/amount]  [autosettle flag="1"/]  [card]  [number] XXXXXXXXXXXXXXXX [/number]  [expdate] 1221 [/expdate]  [chname] James Mason [/chname]  [type] VISA [/type]  [cvn]  [number] XXX [/number]  [presind] 1 [/presind]  [/cvn]  [/card]  [sha1hash] c8c981f7df27539a34c55b5ce277d8f27c9e6b7c [/sha1hash]  [comments]  [comment id="1"] JAVA-Manual-031c1 [/comment]  [/comments]  [tssinfo]  [custipaddress] 1234.123.123.123 [/custipaddress] ' does not conform to the schema

/home/jan/projects/global-payments-sdk/src/Gateways/RealexConnector.php:1067
/home/jan/projects/global-payments-sdk/src/Gateways/RealexConnector.php:957
/home/jan/projects/global-payments-sdk/src/Gateways/RealexConnector.php:475
/home/jan/projects/global-payments-sdk/src/Builders/AuthorizationBuilder.php:492
/home/jan/projects/global-payments-sdk/test/Integration/Gateways/RealexConnector/Certifications/SdkTest.php:16422
/home/jan/projects/global-payments-sdk/vendor/phpunit/phpunit/phpunit:52

I've noticed that it is caused by the incorrect IP set for the transaction:

 // request
        $response = $card->charge(100.01)
            ->withCurrency("USD")
            ->withCustomerIpAddress("1234.123.123.123")
            ->withDescription("JAVA-Manual-031c1")
            ->execute();

It passess when I call

$this->expectException(GatewayException::class);

before the ->execute() call.

Using

@expectedExceptionCode GlobalPayments\Api\Entities\Exceptions\GatewayException

in the methods phpdoc comment doesn't help. I suspect that the $this->tearDown(); call clears the expected exception flag for the test case.

I'm running tests on PHP 7.0.