Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several Paypal Express Checkout errors (since 1 sept 2020) missing AMT, Array data #1177

Open
seansan opened this issue Sep 2, 2020 · 12 comments

Comments

@seansan
Copy link
Contributor

seansan commented Sep 2, 2020

Since 1 sept we are seeing Paypal Express errors (we have activated the express checkuot from cart - 1 click)

php 7.2
M 1.9.4.x latest LTS

This probably needs a fix

Preconditions (*)

  1. Enable paypal express
  2. Enable button in cart
  3. Checkout with PP via cart

Steps to reproduce (*)

  1. See above, place order

Expected result (*)

  1. Order is processed

Actual result (*)

  1. We are seeing 2 new error in our exception logs so the order is no longer coming thru

Exception: PayPal response hasn't required fields.Array in app/code/core/Mage/Paypal/Model/Api/Nvp.php:996

Exception: Expected PayPal field not found in NVP Response: AMT in /app/code/core/Mage/Paypal/Model/Api/Nvp.php:1168

@seansan seansan added the bug label Sep 2, 2020
@sprankhub
Copy link
Contributor

I think Stabilis_PaypalExpressRedirect will not help in this case, see https://github.com/thinklikeamage/Stabilis_PaypalExpressRedirect/blob/cd42b60253133fc2fbff25d527fa45b07c68d81d/code/community/Stabilis/PaypalExpressRedirect/Model/Api/Nvp.php#L30-L44.

Did this actually work for you before and does not work since September 1? Or haven't you had this enabled before?

@seansan
Copy link
Contributor Author

seansan commented Sep 3, 2020 via email

@seansan
Copy link
Contributor Author

seansan commented Sep 4, 2020

Update 4sept - we are seeing this error more often now several counts today (problem is also that PP reports the sales as paid for an legit ... but Magento has no data at all and we have to copy the order data manually from PP to Magento)

Would there be an easy fix for this? (is the AMT field really used, or can it be obtained from another field?)

@seansan
Copy link
Contributor Author

seansan commented Sep 4, 2020

Sorry a brain wave .. ;)

Can someone do as quick check who knows how?

  • is the AMT field really used for Paypal Express (only occurs for Express)
  • if the field is really required and not there can we copy it from another field as a backup?
  • and if not both: cn we at least add the order in pending state before we raise an error?

I have already added extra logging to protected function _validateResponse($method, $response) might be a good addition anyhow for LTS (so when an Exception is raised we see what is missing (AMT) but also what is being sent (now unknown in the log))

@seansan
Copy link
Contributor Author

seansan commented Sep 6, 2020

I am debuggin this and it is something to do with customers going back and forth between screens - also we have a PSP that also offers Paypal. Maybe it is related to that?

I added some debugging and now we see indeed AMT field is missing, because there is an error

2020-09-06T16:53:18+00:00 DEBUG (7): Expected PayPal field not found in NVP Response: AMT Response was: Array
(
    [TOKEN] => EC-8199621SECRET9EA035S
    [SUCCESSPAGEREDIRECTREQUESTED] => false
    [TIMESTAMP] => 2020-09-06T16:53:18Z
    [CORRELATIONID] => eaf09f8ce4558
    [ACK] => Failure
    [VERSION] => 72.0
    [BUILD] => 54864294
    [L_ERRORCODE0] => 10415
    [L_SHORTMESSAGE0] => Transaction refused because of an invalid argument. See additional error messages for details.
    [L_LONGMESSAGE0] => A successful transaction has already been completed for this token.
    [L_SEVERITYCODE0] => Error
)

When the customer calls, this is the status

  • Payment in Paypal is paid and completen
  • Payment in Magento is pending and not complete
  • Payment in Magento has comment "redirected to PSP"
  • PSP dashboard als reports the payment as unpaid

Can it be that the customer has some kind of unique flow?

  • try native paypal express, then via PSP checkout als paypal and Magento does not know which handler to use?
  • is the NVP call back being triggered to Magento which is should not, it should go to the PSP instead who originated thed payment?
  • some old session or cookie containing old data?

Hope it helps

Also see:
magento/magento2#10154

@rvelhote
Copy link
Contributor

rvelhote commented Sep 8, 2020

I tried searching in our paypal logs for that error code and we did not get a match. The only error codes we have logged are 10486 (bad funding source) or 10605 (unsupported currency).

Are you using any customized modules to process Paypal payments? Is there something in common between all payments (e.g. currency, destination, country)?

@seansan
Copy link
Contributor Author

seansan commented Sep 16, 2020

Maybe related
magento/magento2#10154
And magento/magento2#4580
magento/magento2#4474

For some reason the flow is

  • magento
  • paypal
  • redirect to order overview page @ magento
  • we see the error

@Rahza
Copy link

Rahza commented Jan 25, 2021

@seansan Were you able to resolve this issue? I'm having the same problem in our store

@r-martins
Copy link

I'm currently facing the first exception randomly in my store.
I just created a new module to override the \Mage_Paypal_Model_Api_Nvp::$_requiredResponseParams variable and remove the AMT value from the array.
I've never been able to reproduce the error myself. But let's see how it goes and if the problem will persist after that.

@jfksk
Copy link

jfksk commented Sep 14, 2021

I also had that lately. It always occurred when DoExpressCheckoutPayment returned an error, because the API will not return AMT alongside w/ the error.
A possible workaround is to check for the AMT field after the response has been validated and the errors have been processed.

class RockSolid_PayPal_Model_Api_Nvp extends Mage_Paypal_Model_Api_Nvp
{
// snip [...]
    protected function _construct() {
        parent::_construct();
        // We'll remove the 'AMT' field from the required field to prevent an early exit.
        // We'll check that in self::call();
        $this->_requiredResponseParams[self::DO_EXPRESS_CHECKOUT_PAYMENT] = ['ACK', 'CORRELATIONID'];
    }
// snip [...]
    public function call($methodName, array $request)
    {
        // Will throw an exeption if there is an error
        $res = parent::call($methodName, $request);
        // We did remove AMT from the validation. If everything else is fine: check for it!
        if ($methodName == self::DO_EXPRESS_CHECKOUT_PAYMENT && !isset($res['AMT'])) {
            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.')
            );
        }

        return $res;
    }
// snip [...]
}

Adjust the error-management in _handleCallErrors() to your liking...

To reproduce it:

  • Enable debug mode
  • Create a sandbox account w/ insufficient funds. E.g. enough for the products in cart but not for shipping.
  • You should receive error #10486

@kanevbg
Copy link
Contributor

kanevbg commented Sep 12, 2024

If someone has a custom patch for that, please share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants