Please agree to all the terms and conditions before placing the order redirect issue in Paypal Express Checkout and Magento

So your customers are not able to complete orders when using Paypal Express Checkout in Magento one page checkout due to “misbehaving” sales agreement checkboxes.

Please agree to all the terms and conditions before placing the order.

The scenario at hand is as follows:

  1. Customers select PayPal Express Checkout as checkout method (yes, it’s not a payment method!)
  2. Customers are redirected to the PayPal payment page and select “Buy Now”
  3. Customers are redirected to Magento’s PayPal order review page (/paypal/order/review) to accept your sales agreements set (so far so good)
  4. Customers check all required agreement checkboxes displayed on the order review page and click “Buy now”
  5. But instead of being able to complete their order customers are redirected back to the order review page with a message “Please agree to all the terms and conditions before placing the order” that they need to accept all agreements in order to submit their order – thus ending in a order submission loop and being unable to complete their orders.

Check for required sales agreements

The solution to overcome this problem is rather easy: Check for required agreements via Sales / Agreements that might cause the PayPal order review step block valid order submission.

There’s a chance that some agreements is not rendered (correctly), thus disabling customers from accepting them and actually submitting their order.

A recent customer had the payment option electronic direct debit enabled, based on an third-party extension. Unfortuntalely, this extension did not render its additional required sales agreement correctly leading to the fact that customers were unable to select the corresponding required checkbox on the order review page ending in the above mentioned order submission loop.

Check for required sales agreements at order submission runtime

You can also check at runtime which agreements are required to be able to submit orders by inspecting the Paypal Express Checkout controller: Mage_Paypal_Controller_Express_Abstract. There you find the method placeOrderAction which initially checks for required agreements and their submission value. We can easily inject a debug message there to retrieve the required sales agreements at runtime. Below you find the corresponding code snippet. All we need to do is

Mage::log(implode(', ', $requiredAgreements));

which will write the required agreements to system.log. As always, make sure to enable debug logging in Magento.

public function placeOrderAction()
{
  try {
    $requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds();

    Mage::log(implode(', ', $requiredAgreements)); // inject debug logging

    if ($requiredAgreements) {
      $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
      if (array_diff($requiredAgreements, $postedAgreements)) {
        Mage::throwException(Mage::helper('paypal')->__('Please agree to all the terms and conditions before placing the order.'));
      }
    }
...

this will print your required agreement ids in system.log.

Make sure to revert any changes done to this Magento core file!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *