Needs to redirect users on UNPROCESSABLE_ENTITY > PAYER_ACTION_REQUIRED - No checkout possible

Created on 26 November 2024, 6 months ago

Problem/Motivation

Using PayPal Checkout with the buttons in cart can sometimes lead to a PayPal error with
name: UNPROCESSABLE_ENTITY
details: issue: PAYER_ACTION_REQUIRED

You can find more details here:
https://www.paypal-community.com/t5/Sandbox-Environment/PAYER-ACTION-REQ...

Steps to reproduce

Use PayPal with Checkout buttons in the cart
Click the checkout buttons, enter your PayPal data and proceed with the checkout.
When trying to finish the checkout, see an error message. In background an exception is thrown like the one described in the paypal community.

Proposed resolution

If this kind of error appears, redirect the user to the given URL (where rel="payer-action")
Check if there can be any root cause, like described in https://www.paypal-community.com/t5/Sandbox-Environment/PAYER-ACTION-REQ...

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

PayPal Checkout

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Anybody
  • 🇩🇪Germany Anybody Porta Westfalica

    Maybe the reason for paypal to check again could be different order totals in the cart (because no shipping could be calculated yet) and checkout (with shipping collected)? Any other ideas why PayPal might ask for confirmation?

    Regular checkout, not using the Checkout buttons in cart, selecting PayPal as regular payment method, works correctly!

  • 🇮🇱Israel jsacksick

    This is no longer fresh for me, would be great if you could investigate and report back.

  • 🇩🇪Germany Anybody Porta Westfalica

    Yeah I'll try to do my best, first I'd like to find out the root cause - sadly PayPal returns no details, why it wants re-confirmation. It doesn't only happen for my PayPal account (thought maybe rate limit for my tests), but any PayPal account using the Smart Checkout buttons.

    Should you have any idea, please let me know.

    Here's the ERROR returned:

    {
       "name":"UNPROCESSABLE_ENTITY",
       "details":[
          "@""issue":"PAYER_ACTION_REQUIRED",
          "description":"Payer needs to perform the following action before proceeding with payment."
       ],
       "message":"The requested action could not be performed, semantically incorrect, or failed business validation.",
       "debug_id":"0e90efd2abb2d",
       "links":[
          "@""href":"https://developer.paypal.com/api/rest/reference/orders/v2/errors/#PAYER_ACTION_REQUIRED",
          "rel":"information_link",
          "method":"GET",
          "@""href":"https://www.paypal.com/checkoutnow?token=XXXXXXXXXXXXXXX",
          "rel":"payer-action",
          "method":"GET"
       ]
    }
    
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica

    @jsacksick do you know any project where Show Smart Payment Buttons on the cart page is working in production and Checkout completes correctly?

    I really can't get it working due to the response from PayPal given above. Regular checkout works, but sadly the message from PayPal doesn't explain any details why the user needs to re-confirm the order.
    I already tried pre-calculating the total amount, as I thought maybe the problem is that the final amount is different, but it still fails with the same error.
    Furthermore I'm not sure how we should implement that redirect then, because it wouldn't be nice to redirect the main page, I think?
    Guess typically that's done in the popup.

    But first I'd really like to know what's this caused by and if it works somewhere. Maybe we can circumvent this problem...

  • Status changed to Postponed 7 days ago
  • 🇩🇪Germany Grevil

    Let's wait for the error handler service from Print details from error messages returned by paypal Active , after which we continue here.

    POSTPONED on https://www.drupal.org/project/commerce_paypal/issues/3490120 Print details from error messages returned by paypal Active .

  • 🇩🇪Germany Grevil

    Now, that we enabled the express checkout buttons, there are a LOT of messages like these in our shop. We temporarily disabled the express buttons, until this is properly handled.

  • 🇩🇪Germany Grevil

    Ok, I gathered a few more information on this problem and I think I found the problem.

    The problem is, that our shop overcharges the user above the amount he agreed to pay for, which is not allowed and against the "Overcapture requirements (PSD2)", on which PayPal implemented a way to reconfirm the new updated price through the "payer-action" link returned from the "PAYER_ACTION_REQUIRED" error response.

    For more information, please take a look at:
    https://www.paypal.com/ae/cshelp/article/overcapture-requirements-psd2-h...
    https://developer.paypal.com/docs/multiparty/checkout/standard/customize...

    This is easily reproducible using the express checkout buttons:
    - An anonymous user buys a product through the express checkout cart button (we have no information on their address yet)
    - He approves to pay the product costs via PayPal
    - The user gets redirected to the shop. The shop now knows the address of the user (through by PayPal)
    - The shop can now calculate the shipping rate based on the address given and patch the PayPal auction.
    - When trying to finalize the purchase (capture the payment), PayPal returns a "PAYER_ACTION_REQUIRED" response containing a "payer-action" link, because the user approved the costs of the product only, not the costs of the product + shipping cost.
    - The "payer-action" link redirects the user to PayPal, where he needs to reconfirm the new updated amount.

    Unfortunately, there seems to be no error in sandbox mode for whatever reason. It seems like overcharging in sandbox mode is just fine, maybe there is a setting to tweak this behavior.

    The remaining question is, whether this is something, that should be handled by the service provided through Print details from error messages returned by paypal Active . Or something else entirely. @tomtech @jsacksick what do you think about this?

  • 🇩🇪Germany Anybody Porta Westfalica

    Thanks for the super helpful and important investigations @grevil!

    I think we should do two things:
    a) handle the different link types (rel's: (information_link, payer-action, redirect, ...?) as described in 🐛 Needs to redirect users on UNPROCESSABLE_ENTITY > PAYER_ACTION_REQUIRED - No checkout possible Active in Print details from error messages returned by paypal Active so that if user action is needed, it works!
    b) Try to reduce the cases where a user action is needed by default, e.g. might mean to include a default shipping (country) rate in the first call in the cart

Production build 0.71.5 2024