Braintree Payments Error

Hi All

I am using Braintree payments and have just updated the php api library to version 6.16.0 and am now getting this error when processing payments:

Notice : Undefined property on Braintree\Result\Successful: message in /home/accpunt/public_html/master/braintree/braintree-php-6.16.0/lib/Braintree/Instance.php** on line 35

The code on line 35 is:

trigger_error('Undefined property on ’ . get_class($this) . ': ’ . $name, E_USER_NOTICE);

And the whole function is:

public function __get($name)
    {
        // phpcs:ignore
        if (array_key_exists($name, $this->_attributes)) {
            return $this->_attributes[$name];
        } else {
            trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
            return null;
        }
    }

What am I missing?

You forgot to format your code. I’ve done it for you. :biggrin:

1 Like

Going by the method code, this suggests that ther is no array key in the object’s attributes that matches the $name parameter that was passed in.
You shold be able to see futher up the stack trace where the method was called and what $name parameter was passed to it.

You can remove the else.

public function __get($name)
    {
        // phpcs:ignore
        if (array_key_exists($name, $this->_attributes)) {
            return $this->_attributes[$name];
        }
            trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE);
            return null;
    }

Thanks guys… I am still having this issue… I can’t find anything in the documentation that refers to just $name… I tried updating the Instance.php code with above but still get the error and it is not a good idea to update a third-party API… any other ideas?

With some help from ChatGPT I worked this out… the error was with a call that is no longer used in the new version of the API - $cardError = $result->message;

I removed that and the error is gone.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.