422: Unprocessable Entity when using 100% discounts
-
Hi Mollie,
Just so you know, there is a bug in your plugin where your API fails to process line items that have a 100% discount. For example when you apply a coupon set to 100% discount.
The plugin sets type to ‘discount’ only when $this->get_item_total_amount($cart_item) < 0, but the unitPrice is calculated from line_subtotal (the original price before discounts).
The problem is:unitPrice uses line_subtotal → original positive price
totalAmount uses line_total → 0 or negative after Smart Coupons discount
When totalAmount is negative, type becomes ‘discount’, but unitPrice stays positive → Mollie rejects it
Result: user gets the checkout notice saying something went wrong.
I added a workaround, just let me know when this is fixed so I can remove it.
You must be logged in to reply to this topic.