PAYONE-GmbH / shopware-6

PAYONE Payment Plugin for Shopware 6
MIT License
16 stars 19 forks source link

Capturing transactions with discounted shipping costs is not possible (PayOne Secure Invoice in Preauthorization Mode) #293

Closed patchee500 closed 9 months ago

patchee500 commented 9 months ago

This behavior has been observed with the payone_secure_invoice_payment_handler payment method. Shopware Version is 6.5.8.5, Plugin Version is 3.0.0.

Steps to reproduce:

Configure payone_secure_invoice_payment_handler payment method to work in preauthorization mode. Configure shop to use shipping costs, e.g. 6€ for each order. Configure a discount rule that grants a (fixed) discount on the shipping costs, e.g. -4€.

Carry out some order (make sure the discount is applied) and wait for webhook response, marking order ready for capture. Try to capture the order, e.g. via the Shopware Admin interface.

Expected behavior:

Order should be captured fine and capture should be visible in Payone Merchant Interface.

Actual behavior:

Order is not captured. Capture Request ist sent to Payone but returns with Error 1610 "Article list faulty or incomplete".

I guess the problem here is that the logic to assemble the cart contents that are sent over to Payone do not add up properly due to the discount being a 0.00 (€) value item. For discounts on shipping costs the discount value (so the -4€ from the example above) is not held as a negative amount in a line item (there is a line item, but it's value is 0.00) but rather in an additional delivery (There will then be two deliveries for one order).

Here is an example of an order that I tested:

Line Items (values include vat):

1: Some Product: 73,52 2: Discount on Cart: -11,03 3: Discount on Shipping: -4,00

Shipping Costs: 10,98 Order Total: 69,47

The payload that is being sent over to Payone for this order looks like this:

{
  "ip": "127.0.0.1",
  "aid": "XXX",
  "key": "XXX",
  "mid": "XXX",
  "zip": "XXX",
  "city": "XXX",
  "hash": "XXX",
  "mode": "test",
  "de[1]": "Product",
  "de[2]": "Discount on Cart",
  "de[3]": "Discount on Shipping",
  "de[4]": "Shipping Costs",
  "email": "XXX",
  "id[1]": "XXX",
  "id[2]": "XXX",
  "id[3]": "XXX",
  "id[4]": 4,
  "it[1]": "goods",
  "it[2]": "voucher",
  "it[3]": "voucher",
  "it[4]": "shipment",
  "no[1]": 1,
  "no[2]": 1,
  "no[3]": 1,
  "no[4]": 1,
  "pr[1]": 7352,
  "pr[2]": -1103,
  "pr[3]": 0,
  "pr[4]": 1098,
  "va[1]": 1900,
  "va[2]": 1900,
  "va[3]": 0,
  "va[4]": 1900,
  "amount": 6947,
  "street": "XXX",
  "country": "DE",
  "request": "preauthorization",
  "birthday": "XXX",
  "currency": "EUR",
  "encoding": "UTF-8",
  "language": "de",
  "lastname": "XXX",
  "portalid": "XXX",
  "firstname": "XXX",
  "reference": "XXX",
  "salutation": "XXX",
  "api_version": "3.10",
  "clearingtype": "rec",
  "solution_name": "kellerkinder",
  "narrative_text": "XXX",
  "clearingsubtype": "POV",
  "integrator_name": "shopware6",
  "businessrelation": "b2c",
  "solution_version": "5.0.2",
  "integrator_version": "6.5.8.5"
}

As can be seen from the above payload, there is no mention of the shipping discount (It should be -400 somewhere). 7352 - 1103 + 1098 equal 7347 and not the 6947 that are being sent over as amount. A deduction of -400 is missing and thus the complaint from Payone seems valid. If I place the same order without the shipping discount, the order can be captured without issues.

janteuber commented 9 months ago

Hello @patchee500 ,

Thank you for the message.

In order to be able to take a closer look at the case, our colleagues from technical support need more detailed information about this transaction (e.g. the mid and the exact date). I would therefore ask you to send the case by e-mail to tech.support@payone.com.

Thank you very much.

patchee500 commented 9 months ago

I'll not contact the Payone support. This will lead nowhere like it did with https://github.com/PAYONE-GmbH/shopware-6/issues/119 (Which we then patched ourselves until it was fixed in 3.2.0)

The described problem is most certainly an issue with the plugin and not with Payone. It should be reproducible easily, following the described steps above.

Luckily it is rather an edge case for us, so we'll simply live with it and ignore it for now.