braintree / braintree_php

Braintree PHP library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
547 stars 224 forks source link

PHP Warning "Array to string conversion" in Result\Error __toString() Method #343

Open bsatoris opened 1 month ago

bsatoris commented 1 month ago

General information

Issue description

When calling $result->toString() on a Braintree\Result\Error object, a PHP warning "Array to string conversion" is thrown. The issue may be caused by the presence of an array within the _attributes property, perhapsinternationalPhoneNumber=Array – which I see in the output of $result->toString().

Here is edited/redacted output of $result->toString():

[
  "Braintree\\Result\\Error[errors=, params=transaction=type=sale, amount=49.99, taxAmount=0, paymentMethodToken=czrtwvr, options=submitForSettlement=true, paypal=customField=1000261653, description=redacted, orderId=redacted, message=Processor Declined, transaction=Braintree\\Transaction[id=redacted, type=sale, amount=49.99, status=processor_declined, createdAt=Thursday, 06-Jun-24 10:25:13 UTC, creditCardDetails=Braintree\\Transaction\\CreditCardDetails[token=redacted, bin=redacted, last4=redacted, cardType=American Express, expirationMonth=06, expirationYear=2017, customerLocation=US, cardholderName=redacted, imageUrl=https://assets.braintreegateway.com/payment_method_logo/american_express.png?environment=production, isNetworkTokenized=, prepaid=No, healthcare=Unknown, debit=No, durbinRegulated=Unknown, commercial=No, payroll=Unknown, issuingBank=American Express, countryOfIssuance=USA, productId=Unknown, globalId=redacted, accountType=credit, uniqueNumberIdentifier=redacted, venmoSdk=, accountBalance=, expirationDate=06/2017, maskedNumber=redacted], customerDetails=Braintree\\Transaction\\CustomerDetails[id=redacted, firstName=, lastName=, company=, email=, website=, phone=, internationalPhone=Array, fax=, globalId=redacted]], creditCardVerification=, subscription=, merchantAccount=, verification=]"
]

Steps to Reproduce:

  1. Create a Braintree transaction that results in an error.
  2. Retrieve the Braintree\Result\Error object.
  3. Call $result->toString() on the Braintree\Result\Error object.
uzegonemad commented 1 month ago

I haven't made any changes to my Braintree implementation for several months and I started experiencing this error roughly 2 days ago.

I'm wondering if a recent change to POST /transactions is causing this? I'm not immediately seeing anything in the changelog though.