从事务对象访问属性数组

时间:2015-12-01 08:30:58

标签: php arrays object

来自braintree的回应。从事务对象访问属性数组 哪种方式可以访问它?

Braintree\Transaction Object (
        [_attributes:protected] => Array (
                [id] => 3ytqkd
                [status] => authorized
                [type] => sale
                [currencyIsoCode] => USD
                [amount] => 100.00
                [merchantAccountId] => arvaan
                [orderId] => 
                [createdAt] => DateTime Object
                    (
                        [date] => 2015-12-01 07:15:40
                        [timezone_type] => 3
                        [timezone] => UTC
                    )

                [updatedAt] => DateTime Object
                    (
                        [date] => 2015-12-01 07:15:40
                        [timezone_type] => 3
                        [timezone] => UTC
                    )

                [customer] => Array
                    (
                        [id] => 
                        [firstName] => 
                        [lastName] => 
                        [company] => 
                        [email] => 
                        [website] => 
                        [phone] => 
                        [fax] => 
                    )

                [billing] => Array
                    (
                        [id] => 
                        [firstName] => 
                        [lastName] => 
                        [company] => 
                        [streetAddress] => 
                        [extendedAddress] => 
                        [locality] => 
                        [region] => 
                        [postalCode] => 
                        [countryName] => 
                        [countryCodeAlpha2] => 
                        [countryCodeAlpha3] => 
                        [countryCodeNumeric] => 
                    )

                [refundId] => 
                [refundIds] => Array
                    (
                    )

                [refundedTransactionId] => 
                [partialSettlementTransactionIds] => Array
                    (
                    )

                [authorizedTransactionId] => 
                [settlementBatchId] => 
                [shipping] => Array
                    (
                        [id] => 
                        [firstName] => 
                        [lastName] => 
                        [company] => 
                        [streetAddress] => 
                        [extendedAddress] => 
                        [locality] => 
                        [region] => 
                        [postalCode] => 
                        [countryName] => 
                        [countryCodeAlpha2] => 
                        [countryCodeAlpha3] => 
                        [countryCodeNumeric] => 
                    )

                [customFields] => 
                [avsErrorResponseCode] => 
                [avsPostalCodeResponseCode] => I
                [avsStreetAddressResponseCode] => I
                [cvvResponseCode] => M
                [gatewayRejectionReason] => 
                [processorAuthorizationCode] => DHYKZ3
                [processorResponseCode] => 1000
                [processorResponseText] => Approved
                [additionalProcessorResponse] => 
                [voiceReferralNumber] => 
                [purchaseOrderNumber] => 
                [taxAmount] => 
                [taxExempt] => 
                [creditCard] => Array
                    (
                        [token] => 
                        [bin] => 555555
                        [last4] => 4444
                        [cardType] => MasterCard
                        [expirationMonth] => 12
                        [expirationYear] => 2017
                        [customerLocation] => US
                        [cardholderName] => 
                        [imageUrl] => https://assets.braintreegateway.com/payment_method_logo/mastercard.png?environment=sandbox
                        [prepaid] => Unknown
                        [healthcare] => Unknown
                        [debit] => Unknown
                        [durbinRegulated] => Unknown
                        [commercial] => Unknown
                        [payroll] => Unknown
                        [issuingBank] => Unknown
                        [countryOfIssuance] => Unknown
                        [productId] => Unknown
                        [uniqueNumberIdentifier] => 
                        [venmoSdk] => 
                    )

                [statusHistory] => Array
                    (
                        [0] => Braintree\Transaction\StatusDetails Object
                            (
                                [_attributes:protected] => Array
                                    (
                                        [timestamp] => DateTime Object
                                            (
                                                [date] => 2015-12-01 07:15:40
                                                [timezone_type] => 3
                                                [timezone] => UTC
                                            )

                                        [status] => authorized
                                        [amount] => 100.00
                                        [user] => jitendra.arvaan
                                        [transactionSource] => api
                                    )

                            )

                    )

                [planId] => 
                [subscriptionId] => 
                [subscription] => Array
                    (
                        [billingPeriodEndDate] => 
                        [billingPeriodStartDate] => 
                    )

                [addOns] => Array
                    (
                    )

                [discounts] => Array
                    (
                    )

                [descriptor] => Braintree\Descriptor Object
                    (
                        [_attributes:protected] => Array
                            (
                                [name] => 
                                [phone] => 
                                [url] => 
                            )

                    )

                [recurring] => 
                [channel] => 
                [serviceFeeAmount] => 
                [escrowStatus] => 
                [disbursementDetails] => Braintree\DisbursementDetails Object
                    (
                        [_attributes:protected] => Array
                            (
                                [disbursementDate] => 
                                [settlementAmount] => 
                                [settlementCurrencyIsoCode] => 
                                [settlementCurrencyExchangeRate] => 
                                [fundsHeld] => 
                                [success] => 
                            )

                    )

                [disputes] => Array
                    (
                    )

                [paymentInstrumentType] => credit_card
                [processorSettlementResponseCode] => 
                [processorSettlementResponseText] => 
                [threeDSecureInfo] => 
                [creditCardDetails] => Braintree\Transaction\CreditCardDetails Object
                    (
                        [_attributes:protected] => Array
                            (
                                [token] => 
                                [bin] => 555555
                                [last4] => 4444
                                [cardType] => MasterCard
                                [expirationMonth] => 12
                                [expirationYear] => 2017
                                [customerLocation] => US
                                [cardholderName] => 
                                [imageUrl] => https://assets.braintreegateway.com/payment_method_logo/mastercard.png?environment=sandbox
                                [prepaid] => Unknown
                                [healthcare] => Unknown
                                [debit] => Unknown
                                [durbinRegulated] => Unknown
                                [commercial] => Unknown
                                [payroll] => Unknown
                                [issuingBank] => Unknown
                                [countryOfIssuance] => Unknown
                                [productId] => Unknown
                                [uniqueNumberIdentifier] => 
                                [venmoSdk] => 
                                [expirationDate] => 12/2017
                                [maskedNumber] => 555555******4444
                            )

                    )

                [customerDetails] => Braintree\Transaction\CustomerDetails Object
                    (
                        [_attributes:protected] => Array
                            (
                                [id] => 
                                [firstName] => 
                                [lastName] => 
                                [company] => 
                                [email] => 
                                [website] => 
                                [phone] => 
                                [fax] => 
                            )

                    )

                [billingDetails] => Braintree\Transaction\AddressDetails Object
                    (
                        [_attributes:protected] => Array
                            (
                                [id] => 
                                [firstName] => 
                                [lastName] => 
                                [company] => 
                                [streetAddress] => 
                                [extendedAddress] => 
                                [locality] => 
                                [region] => 
                                [postalCode] => 
                                [countryName] => 
                                [countryCodeAlpha2] => 
                                [countryCodeAlpha3] => 
                                [countryCodeNumeric] => 
                            )

                    )

                [shippingDetails] => Braintree\Transaction\AddressDetails Object
                    (
                        [_attributes:protected] => Array
                            (
                                [id] => 
                                [firstName] => 
                                [lastName] => 
                                [company] => 
                                [streetAddress] => 
                                [extendedAddress] => 
                                [locality] => 
                                [region] => 
                                [postalCode] => 
                                [countryName] => 
                                [countryCodeAlpha2] => 
                                [countryCodeAlpha3] => 
                                [countryCodeNumeric] => 
                            )

                    )

                [subscriptionDetails] => Braintree\Transaction\SubscriptionDetails Object
                    (
                        [_attributes:protected] => Array
                            (
                                [billingPeriodEndDate] => 
                                [billingPeriodStartDate] => 
                            )

                    )

            )

    )

2 个答案:

答案 0 :(得分:0)

您需要使用foreach()

循环完成您的回复
foreach($reas->_attributes as $key => $val) {
    echo $key;// will give you the attribute name
    is_array($val) ? print_r($val) : echo $val;// will give you the attribute value
}

答案 1 :(得分:0)

可以使用魔术方法访问对象

$transaction_id = $result->transaction->__get('id');