422 error Unprocessable entity INSTRUMENT_DECLINED

Created on 14 April 2023, about 1 year ago
Updated 2 January 2024, 6 months ago

Problem/Motivation

Customers can not access Paypal payment because of commerce_payment error type :

Client error: `POST https://api.paypal.com/v2/checkout/orders/xxxxxxxxxxxxxxxx/capture` resulted in a `422 Unprocessable Entity` response: {"name":"UNPROCESSABLE_ENTITY","details":[{"issue":"INSTRUMENT_DECLINED","description":"The instrument presented was ei (truncated...)

Steps to reproduce

Working with Commerce PayPal 8.x-1.4
Having a Paypal payment gateway, Paypal Checkout plugin, Access Paypal Smart Payment Buttons ON, Collect Billing information, Transaction type Capture, Update billing and shipping address with information entered at PayPal, no restrictions.
It seems to happen when customer choose the Credit or debit card funding source.

๐Ÿ› Bug report
Status

Closed: cannot reproduce

Version

1.0

Component

PayPal Checkout

Created by

๐Ÿ‡ซ๐Ÿ‡ทFrance Toki Caen, Normandy

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue created by @Toki
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance Toki Caen, Normandy
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States josh.stewart Lexington, KY

    Is it possible to look into this a little bit further? I'm running into this issue (the error from OP), but I think the bigger problem that I'm seeing and I'm not sure where to start with debugging it or providing more information for it is that my site is not handling the error at all. Instead it's allowing the order to process with no payments attached.

    Order moves into a state for validation and has the look and feel that it was "completed" as a transaction.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States josh.stewart Lexington, KY

    Is it possible to look into this a little bit further? I'm running into this issue (the error from OP), but I think the bigger problem that I'm seeing and I'm not sure where to start with debugging it or providing more information for it is that my site is not handling the error at all. Instead it's allowing the order to process with no payments attached.

    Order moves into a state for validation and has the look and feel that it was "completed" as a transaction.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States josh.stewart Lexington, KY

    I've dug deeper into this.

    Iโ€™m testing a weird instance where orders can be placed through PayPal but if a specific error is fired off (Insufficient Funds like the one above), the code traceback will go through the process of throwing a PaymentGatewayException however it still proceeds through the code without redirecting back to a previous spot. It actually continues on and places the order, without payment at all.

    When it gets to the part of code about redirecting to the $error_step_id, $this->redirectToPrevious() is set to false which I think is where the bug is as well. It should not continue on through the code to where $order->save() is called.

    The question I have isโ€ฆ what should my checkout flow look like for Paypal Checkout (Preferred)? Is it possible I have the wrong order of things?

    Kinda seems like a bug to me in tthis module, but could it be with commerce itself?

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance Nicolas Bouteille

    I stumbled upon this error myself.
    After reading your comment, I got scared and tested the insufficient funds case.
    Fortunately, the order does not complete and the user gets a proper error message and is invited to try again.
    FYI: I am using Commerce 2.36, Commerce Paypal 1.4.0, Drupal 9.5.10 with PHP 8.1

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States josh.stewart Lexington, KY

    I should have followed up. This was due to another module not handling errors properly. This was NOT an issue with commerce_paypal, instead was an issue from commerce_multi_payments and not handling errors well.

  • Status changed to Closed: cannot reproduce 6 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ฑIsrael jsacksick

    So closing this per the comments.

Production build 0.69.0 2024