magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.55k stars 9.32k forks source link

Braintree - server error - sandbox #10875

Closed McDev814 closed 7 years ago

McDev814 commented 7 years ago

After setting up a braintree sandbox account and entering merchant id, private and public keys, I tried to run a test transaction within the dollar range suggested in the braintree dev docs. The attempted transaction resulted with 'An error occurred on the server. Please try to place the order again.'

I know this issue has been raised before, but none of the suggested repairs worked.

Preconditions

  1. Magento 2.1.8 (developer mode)
  2. Ubuntu 16.04
  3. Apache 2.4
  4. MySQL 5.7
  5. PHP 7

Steps to reproduce

  1. Create Braintree Sandbox Account
  2. Enter merchant id, private key, and public key into magento braintree configuration and save.
  3. Browse store as guest, add an item into cart (between .01 and 999)
  4. Hover mouse over mini-cart and click 'Go to checkout'
  5. Enter Shipping information, using the same information as billing for card to be used, choose free shipping (only option enabled) and click 'Next'
  6. Enter credit card information and click 'Place Order'

Expected result

  1. Order should be placed successfully and transaction posted to braintree sandbox account.

Actual result

  1. An error is displayed to user: 'An error has occurred on the server. Please try to place the order again.'
  2. In error.log:
    [2017-09-13 15:22:22] main.CRITICAL: Braintree error response. [] []
    [2017-09-13 15:22:22] main.CRITICAL: Wrong transaction status [] []
  3. In debug.log:
    [2017-09-13 16:38:25] main.DEBUG: array (
    'request' =>
    array (
    'customer' =>
    array (
      'firstName' => 'Name',
      'lastName' => 'Removed',
      'company' => NULL,
      'phone' => '555-555-5555',
      'email' => 'user@mail.com',
    ),
    'amount' => '130.00',
    'paymentMethodNonce' => '7c859da8-fb21-039e-24bb-83f22439a13b',
    'orderId' => '000000010',
    'merchantAccountId' => 'qwpcmnn2h92p5yjk',
    'channel' => 'Magento2_Cart_Community_BT',
    'billing' =>
    array (
      'firstName' => 'Name',
      'lastName' => 'Removed',
      'company' => NULL,
      'streetAddress' => '1926 Address Changed',
      'extendedAddress' => '',
      'locality' => 'Erie',
      'region' => 'PA',
      'postalCode' => '16502',
      'countryCodeAlpha2' => 'US',
    ),
    'shipping' =>
    array (
      'firstName' => 'Name',
      'lastName' => 'Removed',
      'company' => NULL,
      'streetAddress' => '1926 Address Changed',
      'extendedAddress' => '',
      'locality' => 'Erie',
      'region' => 'PA',
      'postalCode' => '16502',
      'countryCodeAlpha2' => 'US',
    ),
    'options' =>
    array (
      'storeInVaultOnSuccess' => true,
      'submitForSettlement' => true,
    ),
    'descriptor' =>
    array (
      'name' => 'Andy\'s Equipment',
      'phone' => '(555) 555-5555',
      'url' => 'andysequipment.com',
    ),
    ),
    'client' => 'Magento\\Braintree\\Gateway\\Http\\Client\\TransactionSale',
    'response' =>
    array (
    ),
    ) {"is_exception":false} []
joni-jones commented 7 years ago

Hi, @McDev814, the outdated curl version might cause such problem. To find an original reason, you need to debug \Braintree\Http::_doUrlRequest method.

The dynamic descriptors are not enabled in the account by default https://developers.braintreepayments.com/reference/request/transaction/sale/php#descriptor and name should be separated by an asterisk (*) https://developers.braintreepayments.com/reference/request/transaction/sale/php#dynamic-descriptors.

McDev814 commented 7 years ago

I've updated curl from version 7.47 to 7.55, though that just broke it even further. After upgrading curl, the payment page is unable to load the payment options. I restored it back to 7.47

I requested from Braintree that they enable dynamic descriptors, though they informed me they were already enabled. After learning more about dynamic descriptors, I decided they were unnecessary in our case, especially if they were causing problems. I cleared all data from the dynamic descriptor settings under Stores->Configuration->Sales->Payment Methods->Braintree->Dynamic Descriptors and cleared the cache. The problem is still persisting, though the debug.log no longer has descriptor information included in the array on failed transactions.

I'm not sure where to start on debugging the \Braintree\Http::_doUrlRequest method, I'm not a php developer. I know enough about programming to know what a method is, but I've never studied or worked with php, do you have any suggestions on how to debug it in the least amount of time given my skill level?

joni-jones commented 7 years ago

You need to use some IDE like PHPStorm and enable xdebug extension for PHP https://www.jetbrains.com/help/phpstorm/2016.3/run-debug-configuration-php-remote-debug.html. After that, you need to set a breakpoint on https://github.com/braintree/braintree_php/blob/master/lib/Braintree/Http.php#L177 to find original error code and a message from curl response.

kervin commented 7 years ago

Try to see if it's related to street 2..

https://github.com/magento/magento2/issues/6929

McDev814 commented 7 years ago

Thank you kervin,

I had tried that before posting this, though the problem still persisted. We are having someone add Braintree error logging and are hoping it will be pulled upstream. I know we're not the first ones who could have benefited from knowing what errors are occurring, and I'm sure we won't be the last. I'll update this thread once that development is done and tested.

ausl commented 7 years ago

i think i have similar issue

magento-engcom-team commented 7 years ago

@McDev814, thank you for your report. We were not able to reproduce this issue by following the steps you provided. If you'd like to update it, please reopen the issue. We tested the issue on 2.3.0-dev, 2.2.0, 2.1.9

dipesh-spinx commented 6 years ago

I am having the same issue, Any solution?

amcguireweb commented 1 month ago

2.4.6 and I'm experiencing the same errors. Still.

[2024-09-24T02:51:27.510781+00:00] report.CRITICAL: Braintree error response. [] [] [2024-09-24T02:51:27.510781+00:00] report.CRITICAL: Braintree error response. [] [] [2024-09-24T02:51:27.511337+00:00] report.CRITICAL: Wrong transaction status [] [] [2024-09-24T02:51:27.511337+00:00] report.CRITICAL: Wrong transaction status [] [] [2024-09-24T02:52:03.137090+00:00] report.CRITICAL: Braintree error response. [] [] [2024-09-24T02:52:03.137090+00:00] report.CRITICAL: Braintree error response. [] [] [2024-09-24T02:52:03.137634+00:00] report.CRITICAL: Wrong transaction status [] [] [2024-09-24T02:52:03.137634+00:00] report.CRITICAL: Wrong transaction status [] []