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.
Comments
Comment #2
cspitzlayHere is the documentation:
https://docs.unzer.com/server-side-integration/direct-api-integration/ma...
The type is "voucher". Another type that may be useful to us: "shipment" for shipping costs.
Now this is the documentation for direct API access. But there also is a class in the Unzer PHP SDK that defines types:
UnzerSDK\Constants\BasketItemTypes and there is a setType() method on the basket item.
Comment #4
cspitzlay