Orders with coupons cannot be paid anymore

Created on 6 December 2023, about 1 year ago
Updated 11 December 2023, about 1 year ago

Problem/Motivation

Unzer now validates more strictly. If there is a coupon then trying to pay via Unzer results in an error.

Steps to reproduce

Put a product in the cart and add a coupon that applies to the product during checkout. When you try to pay you will get an error.

The log message says "UnzerSDK\\Exceptions\\UnzerApiException: Basket ''totalValueGross'' does not equals sum of (amountPerUnitGross - amountDiscountPerUnitGross) * quantity. in UnzerSDK\\Services\\HttpService->handleErrors() (line 179 of /opt/drupal/web/vendor/unzerdev/php-sdk/src/Services/HttpService.php)".

This is probably due to our current handling of items with negative value:
Since Unzer did not accept negative values we entered them with their absolute value and marked the label with "Minus".
So indeed, the values do not add up correctly. And now Unzer seems to actually do the math.

I assume this has been triggered by removing deprecations on our side. We are now using the parameterless constructor plus setters.

Proposed resolution

I recently came across an item type for coupons in the Unzer docs. Probably using this will resolve the issue.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇩🇪Germany cspitzlay 🇩🇪🇪🇺

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

Comments & Activities

Production build 0.71.5 2024