Problem/Motivation

Authorization fails when applying shipping promotions that are not included in the price as the un-adjusted shipping amount is sent to Klarna.

Steps to reproduce

Add a shipping promotion that is not included in the price
- Select offer type 'Fixed amount off shipment amount.' or 'Percentage off the shipment amount'
- Select "Only show the discount on the order total summary."

Add product to your cart.
Navigate to checkout.
Apply the shipping promotion (use coupon or fulfill condition defined when adding the promotion).
Proceed to pay with Klarna.
You will receive the error "An unknown error occurred. Please contact store administration if the problem persists."
In the Klarna logs you will see a 400 response with the error code BAD_VALUE, as the order total is not equal to the sum of the line items.

Proposed resolution

Modify the Drupal\commerce_klarna_payments\Request\Payment\RequestBuilder::createShippingOrderLine($shipment) method to call $shipment->getAdjustedAmount() instead of $shipment->getAmount(). This will then handle shipping promotions using the adjusted price analogously to how the createOrderLine() method indirectly handles order item based promotions using the adjusted price.

Remaining tasks

A merge request is to follow.

User interface changes

None.

API changes

None.

Data model changes

None.

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

tcrawford created an issue. See original summary.

tcrawford’s picture

tcrawford’s picture

tcrawford’s picture

tcrawford’s picture

I have created a merge request and a patch (for those still using in their workflow).

tcrawford’s picture

I see tests are failing as the fake shipment interface does not include the getAdjustedAmount method. I will rectify this when time permits.

tuutti made their first commit to this issue’s fork.

tuutti’s picture

Parent issue: » #3271766: 3.0 roadmap

This should be fixed in 3.x branch now. I haven't tested it properly yet tho.

tuutti’s picture

Version: 8.x-2.x-dev » 3.x-dev
Status: Active » Fixed

Status: Fixed » Closed (fixed)

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