0

i am trying to get the merchantAccountId value from given below array

Array
(
        [status] => 1
        [result] => __PHP_Incomplete_Class Object
        (
                [__PHP_Incomplete_Class_Name] => Braintree_Result_Successful
                [success] => 1
                [_returnObjectName:Braintree_Result_Successful:private] => transaction
                [transaction] => __PHP_Incomplete_Class Object
                (
                        [__PHP_Incomplete_Class_Name] => Braintree_Transaction
                        [_attributes] => Array
                        (
                                [id] => 6vk28p
                                [status] => submitted_for_settlement
                                [type] => sale
                                [currencyIsoCode] => USD
                                [amount] => 800.00
                                [merchantAccountId] => contentorganisation
                                [orderId] =>
                                [createdAt] => DateTime Object
                                (
                                        [date] => 2015-07-24 11:51:42
                                        [timezone_type] => 3
                                        [timezone] => UTC
                                )

                        )

                )

        )

)

my code is $result['result']['transaction'] . when i print this i got this error

Fatal error: Cannot use object of type __PHP_Incomplete_Class as array in.
Viru
  • 165
  • 1
  • 8
  • 1
    `$result['result']->transaction` – splash58 Jul 24 '15 at 12:22
  • Try this: `$result['result']->transaction->_attributes['merchantAccountId']` But i think that `_attributes` is private or protected. – Webice Jul 24 '15 at 12:22
  • 2
    check this http://stackoverflow.com/questions/965611/forcing-access-to-php-incomplete-class-object-properties – mahieddine Jul 24 '15 at 12:26
  • 1
    You should probably be **loading your classes** beforehand so you have proper instances instead of `__PHP_Incomplete` instances, then call the appropriate methods on the class to get your results. – deceze Jul 24 '15 at 12:34

2 Answers2

0

The result is OBJECT not array, so you have to call it by:

Array['result']->transaction->_attributes['id']
Tariq
  • 2,853
  • 3
  • 22
  • 29
0

I work at Braintree. You should be able to access the merchant account ID by calling $result->transaction->merchantAccountId, (see Braintree docs).