magento2: Unable to checkout using Braintree PayPal and Virtual product

Preconditions (*)

  1. Clean install of Magento 2.3.3
  2. PHP 7.2
  3. Braintree PayPal enabled

Steps to reproduce (*)

  1. Create a Virtual Product
  2. Enable Braintree PayPal (any environment, Sandbox or Production) bS1
  3. Add virtual product to cart
  4. Start the guest checkout using the normal Magento2 checkout (https://www.magento2.dev/index.php/checkout/) and not the PayPal quick checkout which redirects to https://www.magento2.dev/index.php/braintree/paypal/review/
  5. Select the Braintree PayPal payment method
  6. Login to PayPal by clicking the “Pay with PayPal” checkout button
  7. Click “Place Order”

Expected result (*)

  1. Billing address is fetched from the logged in PayPal account
  2. Order successfully placed

Actual result (*)

  1. “Place Order” fails with the following error: image
  2. The API request to /index.php/rest/default/V1/guest-carts/***/payment-information fails with the following log: <b>Fatal error</b>: Uncaught TypeError: Argument 1 passed to Magento\Braintree\Model\Paypal\OrderCancellationService::execute() must be of the type string, null given, called in /magento2/vendor/magento/module-braintree/Plugin/OrderCancellation.php on line 81 and defined in /magento2/vendor/magento/module-braintree/Model/Paypal/OrderCancellationService.php:47 Stack trace: #0 /magento2/vendor/magento/module-braintree/Plugin/OrderCancellation.php(81): Magento\Braintree\Model\Paypal\OrderCancellationService-&gt;execute(NULL) #1 /magento2/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Braintree\Plugin\OrderCancellation-&gt;aroundPlaceOrder(Object(Magento\Quote\Model\QuoteManagement\Interceptor), Object(Closure), '2', Object(Magento\Quote\Model\Quote\Payment\Interceptor)) #2 /magento2/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Quote\Model\QuoteManagement\Interceptor-&gt;Magento\Framework\I in <b>/magento2/vendor/magento/module-braintree/Model/Paypal/OrderCancellationService.php</b> on line <b>47</b><br /> {"messages":{"error":[{"code":500,"message":"Server internal error. See details in report api\/***"}]}}
  3. The var/report/api/*** contains: Fatal Error: 'Uncaught TypeError: Argument 1 passed to Magento\\Braintree\\Model\\Paypal\\OrderCancellationService::execute() must be of the type string, null given

Additional information

  1. I’ve debugged the file module-braintree/Plugin/OrderCancellation.php and the exception thrown is this: Please check the billing address information. "firstname" is required. Enter and try again. "lastname" is required. Enter and try again. "street" is required. Enter and try again. "city" is required. Enter and try again. "telephone" is required. Enter and try again. "postcode" is required. Enter and try again. "countryId" is required. Enter and try again. {"exception":"[object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): Please check the billing address information. \"firstname\" is required. Enter and try again. \"lastname\" is required. Enter and try again. \"street\" is required. Enter and try again. \"city\" is required. Enter and try again. \"telephone\" is required. Enter and try again. \"postcode\" is required. Enter and try again. \"countryId\" is required. Enter and try again. at /magento2/vendor/magento/module-quote/Model/QuoteValidator.php:107)"}
  2. The PayPal quick checkout mentioned in “Steps to reproduce” step 4 (https://www.magento2.dev/index.php/braintree/paypal/review/) does not fail and the order is placed successfully
  3. The Magento2 default PayPal Express payment method (not the Braintree version) does not fail and the order is placed successfully
  4. The same errors appear if “PayPal through Braintree” is not enabled (step 5) and go to 7 step.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 23 (14 by maintainers)

Most upvoted comments

Yes, issue needs to be re-opened

My M2.4.4 (php7.4) system is logging the error as well, although I can’t figure out the condition required to trigger the error:

main.CRITICAL: TypeError: Argument 1 passed to PayPal\Braintree\Model\Paypal\OrderCancellationService::execute() must be of the type string, null given, called in /vendor/paypal/module-braintree-core/Plugin/OrderCancellation.php on line 75 and defined in /vendor/paypal/module-braintree-core/Model/Paypal/OrderCancellationService.php:47

@magento-engcom-team @ajithkumar-maragathavel Hi, I’m pretty sure the fix applied to the magento/module-braintree extension for this has not made it to the paypal/module-braintree-core extension now packaged in Magento 2.4.

Note the code in Magento/Braintree (no longer available in 2.4.x) is different to that in paypal/module-braintree-core:

https://github.com/magento/magento2/blob/2.3.7/app/code/Magento/Braintree/Plugin/OrderCancellation.php#L78 image

image

I’d say this needs reopening.

If anyone is looking for the cause of this issue in 2.3.3 or below, I believe the fix referred to above is an unchecked variable as fixed here:

https://github.com/magento/magento2/commit/18a83d6de6d850a732d16aed2c95fb99dbcd6702#diff-123aaca295c4956e7dc6076a2bac45d7L75-R75