从查询中检索属性

时间:2015-12-30 06:48:15

标签: php braintree

我如何从这个结果中获得平衡?

Braintree_Customer Object
(
[_attributes:protected] => Array
    (
        [id] => 425865
        [merchantId] => abcddeff
        [firstName] => Waka
        [lastName] => Flaka
        [company] => Waka Flaka Co.
        [email] => demoemail@gmail.com
        [phone] => 281.330.8004
        [fax] => 419.555.1235
        [website] => http://example.com
        [createdAt] => DateTime Object
            (
                [date] => 2015-11-17 17:57:44.000000
                [timezone_type] => 3
                [timezone] => UTC
            )

        [updatedAt] => DateTime Object
            (
                [date] => 2015-11-17 17:57:44.000000
                [timezone_type] => 3
                [timezone] => UTC
            )

        [customFields] => 
        [creditCards] => Array
            (
                [0] => Braintree_CreditCard Object
                    (
                        [_attributes] => Array
                            (
                                [bin] => 400551
                                [expirationMonth] => 09
                                [expirationYear] => 2020
                                [last4] => 0004
                                [billingAddress] => Braintree_Address Object
                                    (
                                        [_attributes] => Array
                                            (
                                                [id] => gx
                                                [customerId] => 30007705
                                                [firstName] => Flaka
                                                [lastName] => Waka
                                                [company] => 
                                                [streetAddress] => 
                                                [extendedAddress] => 
                                                [locality] => 
                                                [region] => 
                                                [postalCode] => 
                                                [countryCodeAlpha2] => 
                                                [countryCodeAlpha3] => 
                                                [countryCodeNumeric] => 
                                                [countryName] => 
                                                [createdAt] => DateTime Object
                                                    (
                                                        [date] => 2015-11-17 17:57:44.000000
                                                        [timezone_type] => 3
                                                        [timezone] => UTC
                                                    )

                                                [updatedAt] => DateTime Object
                                                    (
                                                        [date] => 2015-11-17 17:57:44.000000
                                                        [timezone_type] => 3
                                                        [timezone] => UTC
                                                    )

                                            )

                                    )

                                [cardType] => Visa
                                [cardholderName] => Flaka Waka
                                [commercial] => Unknown
                                [countryOfIssuance] => 
                                [createdAt] => DateTime Object
                                    (
                                        [date] => 2015-11-17 17:57:44.000000
                                        [timezone_type] => 3
                                        [timezone] => UTC
                                    )

                                [customerId] => 30007705
                                [customerLocation] => US
                                [debit] => Yes
                                [default] => 1
                                [durbinRegulated] => Yes
                                [expired] => 
                                [healthcare] => Unknown
                                [imageUrl] => https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=sandbox
                                [issuingBank] => Unknown
                                [payroll] => Unknown
                                [prepaid] => No
                                [subscriptions] => Array
                                    (
                                        [0] => Braintree_Subscription Object
                                            (
                                                [_attributes] => Array
                                                    (
                                                        [addOns] => Array
                                                            (
                                                            )

                                                        [balance] => 0.00

我收到cardType的代码是

$cardtype = $customer->creditCards[0]->cardType;

1 个答案:

答案 0 :(得分:0)

你可以试试这个

$balance = $customer->creditCards[0]->subscriptions[0]->balance;