Magento2: Braintree Vault payments causing GET order API to throw error

Created on 18 Aug 2016  路  3Comments  路  Source: magento/magento2

Preconditions

  1. Magento CE or EE 2.1, PHP 7.0.8
  2. Payment Method Braintree Configured and Enabled, Vault Enabled: yes

    Steps to reproduce

  3. Create an order using Braintree payment method and save the card

  4. Create another order, this time using the saved card as the payment method
  5. Make a call to the rest API to GET /rest/V1/orders

    Expected result

  6. Order json returned

    Actual result

  7. Error is returned: Notice: Array to string conversion in vendor/magento/framework/Reflection/TypeCaster.php on line 34 with stack trace

The cause of this error is due to Vault payments storing an array within the additional_information field in the table sales_order_payment. The array within is token_metadata which is an array containing customer_id and public_hash.
This was added in https://github.com/magento/magento2/commit/16d049fa4117f562120a68927c8c30c6b1e758b5

The error is thrown in Magento\Framework\Reflection\DataObjectProcessor::buildOutputDataArray:
https://github.com/magento/magento2/blob/2.1/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php#L115

The code tries to cast the token_metadata field into a string, causing the array to string conversion error.

The error occurs when processing the getAdditionalInformation method
Magento\Sales\Api\Data\OrderPaymentInterface::getAdditionalInformation:
https://github.com/magento/magento2/blob/2.1/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php#L266
The method is marked with a return type of string[], so all values in the additional_information attribute should be of class string or Phrase.

There either needs to be a way of handling when the additional_information attribute has an array value within it, or the additional_information needs to be enforced to only have string values.

Payment Sales Ready for Work bug report

Most helpful comment

@alena-marchenko @joni-jones Do you know when this is fix is going to be released? You mentioned 2.1.3, but do you have any release date for this version?

All 3 comments

Hi, @phirunson, thanks for reporting and detailed description, this issue also reproducible on the latest develop. I've created internal MAGETWO-57115.

Hi @phirunson,

Fix for MAGETWO-57115 ticket is already merged to develop branch.
Closing the issue, please feel free to reopen if the issue still reproducible for you.

@alena-marchenko @joni-jones Do you know when this is fix is going to be released? You mentioned 2.1.3, but do you have any release date for this version?

Was this page helpful?
0 / 5 - 0 ratings