Using the Smart Checkout Buttons in the cart leads to "We could not complete your payment with PayPal. [...]"

Created on 24 November 2022, almost 2 years ago
Updated 14 February 2023, almost 2 years ago

Problem/Motivation

If

Show the Smart payment buttons on the cart form.

is enabled to use the Smart Payment Buttons on the cart form and trying this payment method, after clicking "Pay" in the last checkout step, I get:

We could not complete your payment with PayPal. Please try again or contact us if the problem persists.

and the order can not be completed.

The watchdog log says:
PayPalCheckoutHttpClientErrorException: 422 HTTP response status code not OK. in PayPalCheckoutClient->submitRequest() (Line 366 of /sites/all/modules/contrib/commerce_paypal/modules/checkout/lib/PayPalCheckoutClient.php).
and

PayPal Checkout transaction failed for order 166029.

at https://www.example.com/checkout/166029/paypal_checkout

Regular payment process works just fine.

Steps to reproduce

See above.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.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

Not all content is available!

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

  • πŸ‡ΊπŸ‡ΈUnited States jantoine

    @Anybody,

    I was getting the same error which was due to one of the "items" sent to the PayPal API having an empty string for a "name".

    This ended up being caused by a custom line item that was not a product, but that I hadn't defined the "title" callback for, so when the Commerce PayPal Checkout module was looping over the line items from the order to create the items array that it sends to the PayPal API, the title being generated for my line item was an empty string.

    Hope this helps you resolve your issue!

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @jantoine thanks, that's a very important point! I guess then we should catch that case in the module to prevent this kind of issue, which is super hard to find!

    It should be implemented in 7.x-2.x and 8.x!

Production build 0.71.5 2024