Magento2: Magento 2.2 Paypal Can't Accept Checkout Agreements Before Routing to PayPal

Created on 30 Oct 2017  ·  51Comments  ·  Source: magento/magento2

This could potentially be a module conflict, but after stepping through and inspecting the checkout code I can't find any obvious third-party interference.

When going through standard checkout and selecting PayPal Express at the payment step, there is an agreements checkbox present. However, checking this box does nothing as the agreements data is not parsed and passed to the set-payment-information API. This triggers the CheckoutAgreements validation plugin which fails to validate with no agreements data.

When I override the PayPal JS to add the agreements data to the paymentData before sending to the API, it passes validation but then fails because PayPal doesn't allow setting extension data.

The only way I was able to work around the problem was by overriding the validation classes and skipping validation when the method was PayPal Express.

I was not experiencing this issue on prior versions of Magento 2, nor does it make sense to have agreements here since you must accept them again during the review step.

Preconditions

  1. Magento 2.2 (maybe earlier?)
  2. PHP 7.0 or 7.1
  3. PayPal Express enabled in-checkout payment methods
  4. Checkout Agreements created and required

Steps to reproduce

  1. Attempt to check out with PayPal Express with the agreements box checked
    (It does not seem to matter whether or not in-context is enabled - though for in-context the flow is even worse as it opens the pop-up window and then fails the payment submission leaving the window open in a failed state.)

Expected result

  1. Proceed to PayPal Express checkout as normal

Actual result

  1. A validation error is returned whether or not the agreement box is checked (though the JS validation will fail without it anyway).
Fixed in 2.2.x Fixed in 2.3.x Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.2.x Reproduced on 2.3.x

Most helpful comment

@roman204 quick fix worked for us, thank you very much :)
Here is the code to install this fix :

composer config repositories.copex/module-paypalfix git [email protected]:CopeX/PaypalFix.git
composer require copex/module-paypalfix:dev-master -n
bin/magento module:enable CopeX_PaypalFix
bin/magento setup:upgrade

All 51 comments

@Silarn, thank you for your report.
We've created internal ticket(s) MAGETWO-83068 to track progress on the issue.

Confirm this issue on vanilla Magento CE 2.2. The agreement IDs are not populated in the request to /V1/carts/mine/set-payment-information whereas they are for other methods like checkmo.

Pretty urgent one this i'd say...

As I mentioned in the op, even if you add the agreement data to the API call, it still fails because the PayPal payment type complains that it can't save custom data. Best workaround is to override the validator and skip it for PayPal Express for the time being.

Same issue.
Magento 2.2.0
PHP: 7.0.24

Users can not proceed to Paypal.
"Please agree to all the terms and conditions before placing the order."

Is there any quick/hotfix for this issue?

same problem for other payment methods except checkmo. (Monetico CM CIC payment in our case).
This was functional in 2.1.9 but not now on CE 2.2.1 version.

same problem for all other payment methods since 2.2.0. The agreement is checked, but magento checkout shows a pop-up message with "please agree to all the terms and conditions before placing the order."
In our case it's no solution to disable agreements in checkout to use all payment methods (paypal etc.).

image

same here, we are running Magento version CE 2.2.1
We have only one agreement configured (btw.: The configuration of agreements is buggy, too. One can not modify existing entries)
the xhr page set-payment-information returns this error, but the box IS checked. Then paypal popup hangs...
{ "message": "Bitte akzeptieren Sie die Geschäftsbedingungen, bevor Sie eine Bestellung aufgeben." }
Request is:
{"cartId":"32","paymentMethod":{"method":"paypal_express","po_number":null,"additional_data":null}}
Hope to get a solution soon...

We are also getting the same issue in latest version 2.2.1.
This is a critical error in magento which blocks paypal payment completely, appreciate if any body have patch for this

In the agreement settings, i set the mode of the agreement to automatically. Then there is no checkbox at the checkout (just the text) and the payment works. Maybe this is a temporary solution until magento fixed this issue.

@CYBKBL ah yes, good suggestion. I've applied the same for the time being and it works well. Just have to change the wording a little to 'By checking out I agree to...' Thanks.

Having the same issue with Bank Transfer Payment and other payment methods with Magento 2.2.1 as well.

This is really not nice, struggled around with it and in the end i wrote a module which provides a quick fix to get the payment via paypal back for shops which are online now and cant wait for a new version.

@roman204 confirm that the fix resolves the issue for us. Pretty shocked by the amount of issue 2.2.1 (and earlier versions) gives us.

So much bugs and regressions with ezch version. I advise customers to stay
safe un 1.9.x version, much stable (and so much faster)

Le 9 déc. 2017 22:13, "Felix Wolfsteller" notifications@github.com a
écrit :

@roman204 https://github.com/roman204 confirm that the fix resolves the
issue for us. Pretty shocked by the amount of issue 2.2.1 (and earlier
versions) gives us.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/magento/magento2/issues/11885#issuecomment-350505903,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAkPMkAB1PVvne3-aQd-7L6uGmcQTwneks5s-vgIgaJpZM4QLtpm
.

@roman204 do you want to provide a Pull Request to fix the issue in the core as well?! :)

hy @avoelkl, there is currently a pull request from someone, my solution is only for those who can't wait until a new version of magento is released.

Sorry, seems I missed that 😅 @roman204

Hi @Silarn. Thank you for your report.
The issue has been fixed in magento/magento2#12401 by @therool in 2.2-develop branch
Related commit(s):

  • ba0472f27f53a51ba532ec33fb017663902f34ab
  • 48923e1c95a235b490d3a119139bb762e947c68f
  • 774cb4c67ece33041901035602aa62c180ae76b1
  • 12145bca8cc87f5072cd5fcbcbd85493c012af4d
  • 7bdb92156a3ea588196d7bdc8b9899b894092b7c
  • 70f5e3860919d97c58c443862d6e6bcf7ff0a5a2
  • 92f620f87717d4ddee66726a403b70fb79b151d4
  • 1c7123fe902932c77053873bd73d452bb74e5f77
  • 9d5fa49fd44e14cde60c65e3c28486e4f5e3ddfa
  • a35b4686c1b95dc356595246410e527d7c57e2ac

The fix will be available with the upcoming patch release.

Hi @Silarn. Thank you for your report.
The issue has been fixed in magento-engcom/magento2ce#1299 by @magento-engcom-team in 2.3-develop branch
Related commit(s):

  • 99e3a76b47267c930d4268b7bbf65500d1913f24
  • 4cfc07e28a8edb388011168e5fd0726dc6c71119
  • ea616e0a217e74707305f1038e6ca207d4bdaba6
  • be55217eae883abd02d44211fa0a88bb0a1d803c
  • 41c52fb989d961ad6ac48eea23163deb61dd9adc
  • 7f42a672ee864f2fc186d0259eb0de2e3d9634f6
  • 1090c8b54733b409a17553bfeb3ec292d449e5ce
  • c80b5ca54d2890407cf329bd24312ebf858929d2
  • 8077af7d42d069523f4addc21741567579e6e74f
  • 38e34a8747651b69a85575d7416d88a3ae49a34d
  • c13ad8595cf555b683223688325fe888fc112bec
  • 9e7bf93ec5b0e90952cac07391d2bde1a72d81ef
  • 10a6288175601ba26075996f3c39880b6e17eb76
  • abf31d2afaa543cddca00b197434ba3f28ac199b
  • 898a470a8b8b6cc6048a403be03594b8fd1b6b98
  • c99c3a7ae67ab16ab2407641a9b2c796f63ce3ef
  • 4537e784c70a3e07470ff7424684348c802839c8
  • 0bad56f0c371d5edc3cfc80dbae1e11400516546
  • fd2418ed8d062181ebc2e10bc298aba95d6d7a5e
  • 946e9e1b508e7788abf12e5c50098cdd9f6447ec

The fix will be available with the upcoming patch release.

I am using Magento 2.2 community version and facing same checkout issue for paypal method.

While going to place order with paypal payment method. Order not placed and getting error "Please agree to all the terms and conditions before placing the order" warning even if the terms and conditions checkbox is checked.

any hope to receive patch in coming few days ? or it will take more time ?

@23digitalTest you can create a file "Magento_Paypal/web/js/action/set-payment-method.js" under your local theme "app/design/frontend//" with the following contents:

/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

define([
    'Magento_Checkout/js/model/quote',
    'Magento_Checkout/js/action/set-payment-information'
], function (quote, setPaymentInformation) {
    'use strict';

    return function (messageContainer) {
        return setPaymentInformation(messageContainer, quote.paymentMethod());
    };
});

Hi @therool I used above code given by you but unfortunately its not working for me. I am using onestepcheckout plugin in my site. Also when i implement this code i getting error "The payment disallows storing objects."

@23digitalTest Hi, sorry forgot to paste additional code, for this you need an local module under app/code/<vendor>/<module>

  1. create di.xml file under app/code/<vendor>/<module>/etc/di.xml or edit the existing one
  2. add the following contents to di.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <!--Remove extension attributes from processing as additional data-->

    <type name="Magento\Paypal\Model\Express">
        <plugin name="<vendor>_<module>::ExpressPlugin" type="<vendor>\<vendor>\Plugin\Magento\Paypal\Model\ExpressPlugin" disabled="false" />
    </type>
</config>
  1. Create ExpressPlugin.php under app/code/<vendor>/<module>/Plugin/Magento/Paypal/Model/ExpressPlugin.php
  2. Add the following contents to ExpressPlugin.php:
<?php
namespace <vendor>\<module>\Plugin\Magento\Paypal\Model;

use \Magento\Paypal\Model\Express;

/**
 * Class ExpressPlugin
 *
 * @package <vendor>\<module>\Plugin\Magento\Paypal\Model
 */
class ExpressPlugin
{
    /**
     * Remove extension attributes from data
     *
     * @param Express $subject
     * @param \Magento\Framework\DataObject $data
     */
    public function beforeAssignData(Express $subject, \Magento\Framework\DataObject $data)
    {
        $extensionAttributeKey = \Magento\Framework\Api\ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY;
        $additionalDataKey = \Magento\Quote\Api\Data\PaymentInterface::KEY_ADDITIONAL_DATA;

        $additionalData = $data->getData($additionalDataKey);

        if (is_array($additionalData) && isset($additionalData[$extensionAttributeKey])) {
            unset($additionalData[$extensionAttributeKey]);
            $data->setData($additionalDataKey, $additionalData);
        }
    }
}
  1. Add <module name="Magento_Paypal"/> to module.xml which should be in app/code/<vendor>/<module>/etc/module.xml. It should look something like:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="<vendor>_<module>" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Paypal"/>
        </sequence>
    </module>
</config>

If you can't manage to add this then I could send you this local module on Monday.

in ExpressPlugin there is a typo:

... Plugin\Magento\Paypa\Model ...

has to be changed to

... Plugin\Magento\Paypal\Model ....

Hi Ričards (@therool),
Thanks for your code guide and interestingly it is working for me. really Appreciated !

Hi,

Very thankful - Luckily this fix is being working for us.

Tried to understand that fix to know what causes the issue actually. But not cleared whats wrong within 'additional data' of 'extension attribute key' ! (http://devdocs.magento.com/guides/v2.0/extension-dev-guide/attributes.html)

Due to this fix, I would like to confirm that can there be any possibilities of having security hole in Magento-to-PayPal-to-Magento transaction ?

And also, can there be any possibility of data loss ? if yes then please advise if any.

Thanks & Regards.

@23digitalTest there is no dataloss and no security issues with that fix, it just skips the extension_attributes object which just contains checkout agreement ids information, the need to unset the "extension_attributes" key is that it is an object and it can't be assigned to info instance and it contains no paypal data. https://github.com/magento/magento2/blob/2.2.2/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js#L36, https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Paypal/Model/Express.php#L628, https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Payment/Model/Info.php#L154.

Hi,

Cool..very informative. Thanks a lot!

Regards,

Hi
I installed the latest version Magento 2.2.3 but there is the same issue.
Conflict wit paypal and accept terms and condition.

What can I do?

Regards
Roberto

@robysalv cou can try my fix here: https://github.com/CopeX/PaypalFix I think it should work also in 2.2.3.

This is getting ridiculous, sorry Magento-Team i love your work and so on but i think you should prioritize such bugs a bit more.

thank you roman204

@roman204 Will the module work for Thrid-Party Payment Extensions too? (Paypal via Cardprocess payment module.)

@yacms i dont think so because its only a fix for paypal module which is a magento core module

Does anyone have fix of this, as I am also facing the same issue with Payumoney method installed in my system.

Facing same issue after upgrading from Magento 2.1.3 to 2.2.3.

Above solutions do not work for me unfortunately. Even roman204*s extension is not working for me.

@roman204 Have you tested against 2.2.3 by chance? Thank you so much for your efforts on this fix.

Yes i did test it with 2.2.3. Cause i developed it on that version.

I can confirm that this issue is still present in 2.2.3 for me too. Thanks @roman204 for your module, it has been a lifesaver!

@magento-engcom-team - why is this still present several releases after it was marked as fixed? With the upcoming introduction of GDPR in Europe having Terms and Conditions working at checkout is going to be essential.

+1

@roman204 Thanks for your module, when I install it it doesn't really solve the problem though. It just makes PayPal disappear completely. Kinda solves the problem, but yeah - You have any advice? And this seems to be rather old, how come that Magento did not release a fix for that yet..

Still exists in 2.2.4 :( Can we give this higher priority? Client needs this functionality ASAP as GDPR legislation requires it in Europe! Cheers

@Valentin-Huwer hmm seems to be another problem, we got now 2 shops online with our fix for paypal with magento2 and both work very well.

Have you tried Magento 2.2.5? There the issue is gone for me. No other mentioned fix did work for me either.

@roman204 I try to install your fix but i don't know how to bypass the error message via composer:
[InvalidArgumentException]
Could not find package PaypalFix at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability
Can you help me?

You have to configure also the url of the git repo in composer.json file

@roman204 Sorry, can you make me an example?

Like that:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/igorw/monolog"
}
],

The T&C checkbox used to work and started showing this issue in the 2.2.x series. We have some clients who think this error is not a core issue but third party module issue.

Could someone please clearly establish if the "please agree to all the terms and conditions before placing the order." issue is a core issue or not, and how we can fix in third party modules?

Am I wrong or does it say, it is fixed in 2.2.X?
Got 2.2.3 and the same problem.

Anyone sure if it is fixed in 2.3? Gonna do a update then...

Fixed in 2.2.x is kind of misleading. I guess it means it was fixed in the latest 2.2.x version at the time the tag was added. Sometimes you also have a comment saying "will be fixed in upcoming version 2.2.7 but then it isn't.

To be really sure you should go to the release page and ctrl+f this issue number. If it was included then it will be part of the Community contributions list. This one was added in 2.2.4.

n ExpressPlugin there is a typo:

... Plugin\Magento\Paypa\Model ...

has to be changed to

Hello,

please, where did I find this file?

Thank you!

@roman204 quick fix worked for us, thank you very much :)
Here is the code to install this fix :

composer config repositories.copex/module-paypalfix git [email protected]:CopeX/PaypalFix.git
composer require copex/module-paypalfix:dev-master -n
bin/magento module:enable CopeX_PaypalFix
bin/magento setup:upgrade
Was this page helpful?
0 / 5 - 0 ratings