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.54k stars 9.32k forks source link

Unable to checkout using Braintree PayPal and Virtual product #25906

Closed sebi-p closed 4 years ago

sebi-p commented 4 years ago

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: `Fatal error: 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->execute(NULL)

    1 /magento2/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Braintree\Plugin\OrderCancellation->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->Magento\Framework\I in /magento2/vendor/magento/module-braintree/Model/Paypal/OrderCancellationService.php on line 47

    {"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.
m2-assistant[bot] commented 4 years ago

Hi @sebi-p. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@sebi-p do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?


sebi-p commented 4 years ago

@magento give me 2.3-develop instance

magento-engcom-team commented 4 years ago

Hi @sebi-p. Thank you for your request. I'm working on Magento 2.3-develop instance for you

magento-engcom-team commented 4 years ago

Hi @sebi-p, here is your Magento instance. Admin access: https://i-25906-2-3-develop.instances.magento-community.engineering/admin Login: admin Password: 123123q Instance will be terminated in up to 3 hours.

sebi-p commented 4 years ago

I cannot reproduce the issue on 2.3-develop. Is there a specific PR that addressed this?

m2-assistant[bot] commented 4 years ago

Hi @engcom-Echo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

magento-engcom-team commented 4 years ago

:white_check_mark: Confirmed by @engcom-Echo Thank you for verifying the issue. Based on the provided information internal tickets MC-29445 were created

Issue Available: @engcom-Echo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] commented 4 years ago

Hi @ajithkumar-maragathavel. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:


ajithkumar-maragathavel commented 4 years ago

@magento give me 2.2 instance

ajithkumar-maragathavel commented 4 years ago

@magento give me 2.4-develop instance

magento-engcom-team commented 4 years ago

Hi @ajithkumar-maragathavel. Thank you for your request. I'm working on Magento 2.4-develop instance for you

magento-engcom-team commented 4 years ago

Hi @ajithkumar-maragathavel, here is your Magento instance. Admin access: https://i-25906-2-4-develop.instances.magento-community.engineering/admin Login: admin Password: 123123q Instance will be terminated in up to 3 hours.

ajithkumar-maragathavel commented 4 years ago

@magento give me 2.4-develop instance

magento-engcom-team commented 4 years ago

Hi @ajithkumar-maragathavel. Thank you for your request. I'm working on Magento 2.4-develop instance for you

magento-engcom-team commented 4 years ago

Hi @ajithkumar-maragathavel, here is your Magento instance. Admin access: https://i-25906-2-4-develop.instances.magento-community.engineering/admin Login: admin Password: 123123q Instance will be terminated in up to 3 hours.

ajithkumar-maragathavel commented 4 years ago

Closing this issue, since It is not reproducible in 2.4-develop branch. I can able to place order using Paypal through Braintree using a Virtual product.

I have attached screenshot for reference SS-1 SS-2

chris-pook commented 4 years ago

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

chris-pook commented 2 years ago

@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.

ClintTec commented 2 years ago

@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.

Agreed.

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 Stack trace:

0 \vendor\paypal\module-braintree-core\Plugin\OrderCancellation.php(75): PayPal\Braintree\Model\Paypal\OrderCancellationService->execute(NULL)

chris-pook commented 2 years ago

Hi @magento-engcom-team, please can this be reopened?

n2diving-dgx commented 2 years ago

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

florinm8 commented 1 year ago

I'm having this issue on m2.4.5 if the $quote->getHasErrors() is true. Instead of throwing the quote validation exception and receive the message in frontend the type error is raised because of $incrementId is null

xaevik commented 1 year ago

We are also experiencing this on 2.4.5 EE during QA testing, the bug was never resolved in the enterprise edition. We're making a composer patch to resolve it.

image