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

cspitzlay created an issue. See original summary.

cspitzlay’s picture

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

  • cspitzlay committed ac1c13fd on 1.0.x
    Issue #3406459 by cspitzlay: Orders with coupons cannot be paid anymore
    
cspitzlay’s picture

Status: Active » Fixed
  • Commerce promotion adjustments are turned into Unzer basket items of type "voucher", grouped by source ID now.
  • Shipping costs are turned into Unzer basket items of type "shipment" now.
  • The broken general handling of items with negative value has been removed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.