Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bsatoris opened this issue Jun 7, 2024 · 2 comments

Comments

@bsatoris
Copy link

bsatoris commented Jun 7, 2024

General information

  • SDK/Library version: 6.18.0
  • Environment: Production
  • Language, language version, and OS: PHP 8.1.2 on ubuntu 2.17

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
Copy link

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.

@nsrwork
Copy link

nsrwork commented Sep 3, 2024

Hi
I’m encountering the similar issue:
Warning: Array to string conversion

Stack Trace:

  • Braintree\Util::implodeAssociativeArray at line 370
  • Braintree\Instance::__toString at line 60
  • Braintree\Util::attributesToString at line 394
  • Braintree\Transaction::__toString at line 480
  • Braintree\Util::attributesToString at line 394
  • Braintree\Result\Error::__toString at line 110

Library Version: 6.19.0
PHP Version: 8.3
Environment: prod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants