cancel
Showing results for 
Search instead for 
Did you mean: 

PayPal response hasn't required fields - AMT field is deprecated

PayPal response hasn't required fields - AMT field is deprecated

Hi,

 

We're using Magento 1.9.3 with the PayPal gateway. Today, a customer reported receiving the following error message:

 

There was an error processing your order. Please contact us or try again later.

 

Upon inspection, I found this in the exception.log:

2016-10-27T17:02:37+00:00 ERR (3): 
exception 'Exception' with message 'PayPal response hasn't required fields.' in /app/code/core/Mage/Paypal/Model/Api/Nvp.php:996
Stack trace:
#0 /app/code/core/Mage/Paypal/Model/Api/Nvp.php(644): Mage_Paypal_Model_Api_Nvp->call('DoExpressChecko...', Array)
#1 /app/code/core/Mage/Paypal/Model/Express.php(581): Mage_Paypal_Model_Api_Nvp->callDoExpressCheckoutPayment()
#2 /app/code/core/Mage/Paypal/Model/Express.php(377): Mage_Paypal_Model_Express->_placeOrder(Object(Mage_Sales_Model_Order_Payment), '190.75')
#3 /app/code/core/Mage/Sales/Model/Order/Payment.php(443): Mage_Paypal_Model_Express->capture(Object(Mage_Sales_Model_Order_Payment), '190.75')
#4 /app/code/core/Mage/Sales/Model/Order/Invoice.php(395): Mage_Sales_Model_Order_Payment->capture(Object(Mage_Sales_Model_Order_Invoice))
#5 /app/code/core/Mage/Sales/Model/Order/Payment.php(608): Mage_Sales_Model_Order_Invoice->capture()
#6 /app/code/core/Mage/Sales/Model/Order/Payment.php(410): Mage_Sales_Model_Order_Payment->_invoice()
#7 /app/code/core/Mage/Sales/Model/Order/Payment.php(348): Mage_Sales_Model_Order_Payment->capture(NULL)
#8 /app/code/core/Mage/Sales/Model/Order.php(896): Mage_Sales_Model_Order_Payment->place()
#9 /app/code/core/Mage/Sales/Model/Order.php(1114): Mage_Sales_Model_Order->_placePayment()

This error is not very helpful. However, I did take a look at the /app/code/core/Mage/Paypal/Model/Api/Nvp.php file (line 996):

        if (!$this->_validateResponse($methodName, $response)) {
            Mage::logException(new Exception(
                Mage::helper('paypal')->__("PayPal response hasn't required fields.")
            ));
            Mage::throwException(Mage::helper('paypal')->__('There was an error processing your order. Please contact us or try again later.'));
        }

So I examined _validateResponse() and added some logging statements there:

    protected function _validateResponse($method, $response)
    {
        if (isset($this->_requiredResponseParams[$method])) {
            foreach ($this->_requiredResponseParams[$method] as $param) {
                if (!isset($response[$param])) {
Mage::log("Expected PayPal field was not found: $param");
                    return false;
                }
            }
        }
        return true;
    }

So, after trying to place the order again, I get this:

Expected PayPal field was not found: AMT

This is happening both in the PayPal live API and the PayPal sandbox API. A review of their documentation clearly specifies that the AMT field is deprecated:

https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/

 

(look in the "Deprecated Payment Details Type Fields" section).

 

It looks like the usage of the AMT field has been discontinued by PayPal. This is breaking all PayPal express payments, so it could be a big deal. Replacing the field seems simple enough, but there are tests that should be run.

How do we proceed here?

5 REPLIES

Re: PayPal response hasn't required fields - AMT field is deprecated

Hey mate, did you find a solution to this by any chance?

 

Has anyone else figured out a solution or is having the same problem?

Re: PayPal response hasn't required fields - AMT field is deprecated

Hi!

 

Actually, even though the AMT field is indeed deprecated, PayPal is still returning it.

My issue was related to another extension (TBT Reports) that was replacing the tax calculations. Things weren't adding up before reaching PayPal (we're using AvaTax to do some very specific taxes, so there was a conflict), and then PayPal was sending back an error. I didn't catch it the first time because error reporting is a bit strange here.

But as for this issue, I would categorize it as something to improve on, but not a critical thing anymore.

Re: PayPal response hasn't required fields - AMT field is deprecated

I am getting the same error after upgrading to 1.9.3

Any solutions? Paypal payment now not able to work.

Re: PayPal response hasn't required fields - AMT field is deprecated

Having the same issue, did you find a solution?

 

Re: PayPal response hasn't required fields - AMT field is deprecated

Hi guys, please note my answer from December 2016, where I mention that the problem is somewhere else. It seems that when PayPal sends an error back, Magento doesn't report it well, and then you get that AMT field issue.

But the problem is not the AMT field. Is that something else sent an error. You might want to check your PayPal responses to see what error it is sending.