magento2: Unable to checkout with PayPal through Braintree
Preconditions and environment
Upon upgrading our production site from M2.4.5-p2 to M2.4.6 we discovered customers were unable to checkout via PayPal through Braintree.
We were unable to find any workaround.
Building Magento 2.4.6
+ cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
+ /usr/local/apache/bin/httpd -v
Server version: Apache/2.4.46 (Unix)
Server built: Jun 16 2021 21:29:21
+ mysql -V
mysql Ver 8.0.28 for Linux on x86_64 (MySQL Community Server - GPL)
+ php -v
PHP 8.1.17 (cli) (built: Mar 17 2023 09:39:39) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.17, Copyright (c) Zend Technologies
with Zend OPcache v8.1.17, Copyright (c), by Zend Technologies
+ php /usr/local/bin/composer -V
Composer version 2.3.5 2022-04-13 16:43:00
Steps to reproduce
Fresh Install of M2.4.6 in environment as above Open browser “incognito” window using Windows 11 and Google Chrome Login to Magento admin backend
Nav to Admin>Stores>Configure>General>Web>Default Cookie Settings If necessary, set the Cookie Domain to the appropriate domain value (so Demo Customer will be able to login on front end) Save Config Nav to Admin>Stores>Configure>Sales>Payment Methods Select Merchant Country as United States and Save Config Configure Braintree Payments (by GENE Commerce v4.5.0) Enter known valid sandbox credentials for Merchant ID, Public Key, Private Key and Validate Credentials In the Enable PayPal through Braintree section… Set Enable PayPal through Braintree = Yes Set Display on Shopping Cart = Yes Save Config Flush Magento Cache
Open separate tab on incognito browser and navigate to frontend Successfully Sign In using Demo Customer Access credentials Click Add-to-Cart for Affirm Water Bottle (or anyother product) Observe “spinner” remains over count box in upper right hand corner of page and does not clear NO message “You added the Affirm Water Bottle to your shopping cart.” appears Clicking cart icon displays “You have no items in your shopping cart” Add-to-Cart two or three more times for the Affirm Water Bottle Click the Luma Store icon to return to home page [ Although the website is not hung, it’s useless because nothing can successfully added to cart, this behavior appears to be related to the PayPal button appearing in the mini-cart ]
Return to backend Nav to Admin>Stores>Configure>Sales>Payment Methods Configure Braintree Payments (by GENE Commerce v4.5.0) In the Enable PayPal through Braintree section Set Display on Shopping Cart = No Save Config Flush Magento Cache
Return to frontend You should still be on the Luma store home page Use your web browser “refresh” function to reload the page The green circle with the check mark and the message “You added the Affirm Water Bottle to your shopping cart.” appears several times. The count box in the upper right corner will now equal the number of times add-to-cart was previously clicked. Click the cart icon and Proceed to Checkout Shipping Method select Fixed Flat Rate Payment Method select PayPal Click the large yellow PayPal button Rarely, the PayPal “modal box” zooms out surrounded by dark background, and remains open as normal, If the PayPal modal box remains open, close it and add another item to cart then Proceed to Checkout again In most tests the modal box zooms out for a moment and closes, then Message “PayPal Checkout could not be initialized. Please contact store owner.” appears. and you are unable to proceed to place an order.
Expected result
During checkout upon selecting PayPal as the Payment Method then clicking the large yellow PayPal button the PayPal modal box appears and the customer is able to successfully make payment and checkout.
Actual result
During checkout upon selecting PayPal as the Payment Method then clicking the large yellow PayPal button the PayPal modal box appears for a moment before automatically closing and the customer is unable to make payment or complete the order.
Additional information
Tested with both our sandbox and production Braintree creditials, in both production and development environments, PayPal as payment method is essentially not functional although for some reason under certain unknown circumstances it will work as expected for a specific customer checkout. It did work as expected on M2.4.5-p2
I was unable to find any workaround and the PayPal payment method is currently disabled on our M2.4.6 production website.
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 68 (2 by maintainers)
Thank you everyone for your feedback!
GENE Commerce is responsible for developing the Magento Braintree extension. I would like to tell you that this issue is already been fixed in Magento v2.4.7-beta1 that has already been released on June 13, 2023. Here, you can find the v2.4.7-beta1 release notes for the Braintree: https://experienceleague.adobe.com/docs/commerce-operations/release/notes/adobe-commerce/2-4-7.html?lang=en#braintree
We already have a patch ready for Magento/Adobe v2.4.6 and its patch versions for the issue reported here. You can download the patch from this link: https://support.gene.co.uk/support/solutions/articles/35000227790-patch-for-unable-to-checkout-via-paypal-through-braintree-in-magento-v2-4-6-and-v2-4-6-p1-p2
Also if you have any technical issues or concerns regarding our Magento Braintree extension, you can reach out to us by raising a support ticket from here: https://support.gene.co.uk/support/home
Thank you @kartikmaniyar! I have been waiting ages for an official patch. Time to move our installation to the current release 😄
Another issue I found with Braintree was when trying to do SPLIT invoices. When I create the first invoice, everything goes fine. When I try to create a second invoice with the other items left I get an error “Token Invalid”.
The issue is related to the code in
vendor/paypal/module-braintree-core/Gateway/Request/VaultCaptureDataBuilder.phpline 43The null coalesce command is wrong as you can see if the object
$paymentTokenis not null it will return afalseand then returnfalseas apaymentMethodTokenvalue.My solution was:
Hey, thanks a lot @nicholasfishjgm - that helps for now. But an official update by the maintainers would still be very appreciated.
anything with this? Been over a month, seems like a pretty big issue.
rich
This ticket is correctly tagged “Priority: P0” - i.e. mission critical functionality for sites accepting PayPal payments through Braintree for which there is no work around other than revert to M2.4.5 The only thing to do to remain on M2.4.6 is turn off accepting payments via PayPal, which in our case means PayPal is losing hundreds of USD per day and at least a other sites are likely in the same situation so in actuality this means PayPal losses are possibly thousands of USD in fees per day! Plus an unknown impact of the merchant not offering a PayPal payment method to customers. I expect if the question were asked of PayPal “What is the impact on my sales as a result of not offering PayPal as a payment method?” their reply would be something like “significant”.
Yet two+ weeks have passed and it is not even assigned to a developer much less a hotfix.
After consultation, I have learned that the Braintree V4.5.0 module in M2.4.6 includes new functionality and is now passing individual cart line items to PayPal. Previously, the Braintree V4.4.0 version in M2.4.5 and earlier did NOT pass cart line items to PayPal just the Grand Total amount on the order. However, there is an issue in that when the cart line items do not add up to the Grand Total, for example if there is a separate sales tax line item, then PayPal through Braintree will fail as a payment method on checkout, the modal box will automatically close and Magento will display an error message to the customer “PayPal Checkout could not be initialized.”
There is a configuration option found under Advanced Braintree Settings for Send Cart Line Items, which defaults to Yes. Setting “Send Cart Line Items” = NO does allow the PayPal login modal box to zoom out and remain… it is possible to login to PayPal using the modal box, but upon clicking the “Complete Purchase” button, the modal box closes and returns to the Magento checkout flow where a pink box declares “Something went wrong with your request. Please try again later.” simultaneously an error for “Call to undefined method…” is logged in exception.log file.
** main.CRITICAL: Error: Call to undefined method Magento\Sales\Api\Data\OrderExtension::getGwBasePrice() in /www/releases/vendor/paypal/module-braintree-core/Gateway/Request/Level23ProcessingDataBuilder.php:188 **
As of now, there is no workaround that allows checkout using PayPal through Braintree on M2.4.6