0

Magento 2.4.6 Paypal Braintree error when adding item to cart 'display on shopping cart'(Paypal button) is enabled. Once you disable you are able to add items to cart and checkout.

update-fresh install i was able to duplicate.

Enable Braintree payments.

Enable PayPal through Braintree.

Display on shopping cart-'yes' 500 error display on shopping cart-'no' no error, able to add to cart and proceed.

https://magento-967393-3381519.cloudwaysapps.com/

https://magento-967393-3381519.cloudwaysapps.com/checkout/cart/

currently set to Display on shopping cart-'yes'

Rich

0

2 Answers 2

2

Found this that answers my above issue.

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

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

0

Hope this helps as I've had the same thing.

On magento github somebody suggested the following:

This issue seems to stem for the "Gift Wrapping" Section within /Magento/vendor/paypal/module-braintree-core/Gateway/Request/Level23ProcessingDataBuilder.php

Commenting out lines 186-189 & 198-232 allows PayPal via Braintree to process without errors

Under Advanced Braintree Setttings "Send Cart Lines" Should be set to NO, if items are not being added to the mini-cart

Basically, quote out these lines:

        $extensionAttributes = $order->getExtensionAttributes();
        $gwBasePrice = $this->numberToString($extensionAttributes->getGwBasePrice(), 2);
        $gwItemsBasePrice = $this->numberToString($extensionAttributes->getGwItemsBasePrice(), 2);

These

        if ($gwBasePrice > 0) {
            $gwBasePriceItems[] = [
                'name' => 'Gift Wrapping for Order',
                'kind' => TransactionLineItem::DEBIT,
                'quantity' => 1.00,
                'unitAmount' => $gwBasePrice,
                'totalAmount' => $gwBasePrice
            ];

            $lineItems = array_merge($lineItems, $gwBasePriceItems);
        }

And these

         if ($gwItemsBasePrice > 0) {
            $gwItemsBasePriceItems[] = [
                'name' => 'Gift Wrapping for Items',
                'kind' => TransactionLineItem::DEBIT,
                'quantity' => 1.00,
                'unitAmount' => $gwItemsBasePrice,
                'totalAmount' => $gwItemsBasePrice
            ];

            $lineItems = array_merge($lineItems, $gwItemsBasePriceItems);
        }

Someone also supplied a patch in the same page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.