Giter Club home page Giter Club logo

Comments (7)

judgej avatar judgej commented on June 26, 2024 1

I suspect the issue is in the xml2array method, but need to explore a little further to see what is really happening. Between 7.1 and 7.2, this method behaves very differently. Whether it is this method, or the data passed to it, I don't know.

from omnipay-authorizenet.

judgej avatar judgej commented on June 26, 2024

https://github.com/thephpleague/omnipay-authorizenet/blob/master/src/Message/CIMAbstractResponse.php#L61

Is this about the changes to operator precedence? This is the line now:

$result = (string)$this->data['messages'][0]['resultCode'];

TBH I'm not sure why the value is cast to a string, since you can't cast an array to a string anyway. If you take out the (string) completely, does it work for you? I've not got PHP7.2 handy to try it on, though we could enable on travis.

Edit: Just noticed I have got 7.2 available to install. Just doing that now.

from omnipay-authorizenet.

judgej avatar judgej commented on June 26, 2024

Not sure where the problem is exactly, but it seems to be the way the XML is parsed. This is what the response looks like in 7.1:

array(2) {
  ["messages"]=>
  array(1) {
    [0]=>
    array(2) {
      ["resultCode"]=>
      string(2) "Ok"
      ["message"]=>
      array(1) {
        [0]=>
        array(2) {
          ["code"]=>
          string(6) "I00001"
          ["text"]=>
          string(11) "Successful."
        }
      }
    }
  }

Then in 7.2 the response looks like this:

array(2) {
  ["messages"]=>
  array(1) {
    [0]=>
    array(2) {
      ["resultCode"]=>
      array(1) {
        [0]=>
        array(0) {
        }
      }
      ["message"]=>
      array(1) {
        [0]=>
        array(2) {
          ["code"]=>
          array(1) {
            [0]=>
            array(0) {
            }
          }
          ["text"]=>
          array(1) {
            [0]=>
            array(0) {
            }
          }
        }
      }
    }
  }

Note all the string nodes have tuned into empty arrays :-/

from omnipay-authorizenet.

javabudd avatar javabudd commented on June 26, 2024

Good find, I'll try poking around as well.

from omnipay-authorizenet.

judgej avatar judgej commented on June 26, 2024

I won't have time to look until I get home (about 8 hours). I cannot find anything on SO or the docs that indicate SimpleXML has changed in 7.2, except for a few bug fixes. So that may point more towards where the XML is parsed. But I may be completely off there.

from omnipay-authorizenet.

judgej avatar judgej commented on June 26, 2024

There is a PR to play with here. It uses the much simpler json_decode of a json_encode to convert the parsed XML object to an array. This does change the structure of the resulting array slightly. It is failing all travis tests on 7.2 due to deprecated code in phpunit (3.9). I'm sure there will be a way to disable some cs code checks for PHP 7.2 only, or perhaps the travis config is not pointing phpcs at the correct directory to scan - not sure.

from omnipay-authorizenet.

judgej avatar judgej commented on June 26, 2024

A fix has been in place since January 2017 (for version 3.0.0) that changes the way the XML is decoded to an array. That was probably merged in accidentally, but it does not seem to have raised any issues, so I'm going to close this issue.

If I've overlooked anything here, please reopen or raise a new issue if there are other subsequent side-effects. The JSON encode/decode technique used to convert the XML to an array does have its limits (e.g. not properly handling attributes), but the XML supplied by this gateway does not seem to hit it.

from omnipay-authorizenet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.