Skip to content

Virtual products lead to incomplete invoices when using an Open Invoice payment method (e.g. Klarna) #2813

@pmzandbergen

Description

@pmzandbergen

Describe the bug

private function itemsToBeInvoiced(Shipment $shipment): array
{
$shipmentItems = $shipment->getItems();
$invoiceItems = [];
foreach ($shipmentItems as $shipmentItem) {
$invoiceItems[$shipmentItem->getOrderItemId()] = $shipmentItem->getQty();
}
return $invoiceItems;
}

This code expects all items to ship, which is not the case for virtual products. This causes those items not to be invoiced leading to a partial (or failed) capture.

To Reproduce
Steps to reproduce the behavior:

  1. Place an order with both virtual and regular (simple) products
  2. Pay using an Open Invoice method (Klarna for example)
  3. Create a shipment
  4. Inspect the invoice and capture flow

Expected behavior
Items which do not require a shipment (e.g. virtual products) should be invoiced and captured.

Magento version
2.4.7-p3

Plugin version
9.6.0, but can be reproduced on the latest version (9.11.0) as well.

Screenshots
N/A

Desktop (please complete the following information):
N/A

Smartphone (please complete the following information):
N/A

Additional context
N/A

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions