We are experiencing a problem with PayPal payments, as the API returns an UNPROCESSABLE_ENTITY error (CANNOT_BE_NEGATIVE) with certain carts. In this project, we have defined a custom adjustment type, which reduces the order total, hence is negative - which PayPal API doesn't allow.

The CheckoutSdk class is already skipping certain adjustment types, such as tax, shipping, promotion and giftcards. And yes, there's already an CheckoutOrderRequestEvent which allows us to modify the request before it is sent. However, walking through the items and identifying the problematic ones is a bit cumbersome and not the cleanest solution imho.

Therefore I'm suggesting introducing a new event, that allows us directly to add/remove these skipped adjustment types

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

agoradesign created an issue. See original summary.

jsacksick’s picture

hm... this event is reallllly specific... I'd be more in favor of introducing a setting for that (maybe at the gateway level?) Problem is, this method doesn't have access to the gateway... Could be just a setting that we fetch via Settings::get(), we'd just need to document it, but similar to how we have an event that you'd need to know about...

agoradesign’s picture

ok, I see, we also need to fix the $breakdown.. but anyway, this can be done inside CheckoutOrderRequestEvent as well, so having this extra event would still be valuable imho

agoradesign’s picture

@jsacksick I haven't really recognized your comment on friday. just saw it :D

hmm well, yes it is specific, but I believe we should be open to custom adjustment types, allowing them to have a solid way to integrate themselves. why should it harm to use events?

We have actually 2 different places inside prepareOrderRequest(), where we deal with an hardcoded opinionated list of adjustment types (skip, discount). my latest commit considers both (I have added in total 2 events, re-using the same event class)

agoradesign’s picture

Version: 8.x-1.x-dev » 2.x-dev

gonna rebase this