Skip to content

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

@bsatoris

Description

@bsatoris

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions