PAYONE-GmbH / shopware-5

PAYONE Payment Plugin for shopware 5
MIT License
10 stars 24 forks source link

Bootstrap::refundOrder needs to process custom quantity for a position #92

Closed thomasbit closed 7 years ago

thomasbit commented 7 years ago

Hey,

we currently have a problem, if a customer returns less items of an order position than he has ordered. Example: The customer orders 3 shirts and returns 2. Because the returned quantity is not considered in Bootstrap::refundOrder, the request contains the wrong quantity and we get an 1610 error (Article list faulty or incomplete|customermessage=An error occured while processing this transaction (wrong parameters)).

see: https://github.com/PAYONE-GmbH/shopware-5/blob/master/Frontend/MoptPaymentPayone/Bootstrap.php#L835

The function only process the "id" and "amount" of the given $orderDetailsParams

$orderParams = array_combine(array_column($orderDetailParams, 'id'), array_column($orderDetailParams, 'amount'));

We should be able to pass the quantity and it should be further processed.

The next function where this needs to be considered is the Mopt_PayoneParamBuilder::getInvoicingFromOrder. (https://github.com/PAYONE-GmbH/shopware-5/blob/master/Frontend/MoptPaymentPayone/Components/Classes/PayoneParamBuilder.php#L1283) There the quantity is fetched from the order - this needs to be changed to consider the passed quantity.

fjbender commented 7 years ago

I guess it'd be smart to also look at Bootstrap::captureOrder in this case, as partial captures are also possible and both methods basically work the same.

thomasbit commented 7 years ago

@fjbender As far is I understand it, both methods support to adjust the "amount" of a captured/refunded position. But our current problem is not the amount, but the quantity of an order position. Even if we adjust the refunded amount, we still have the problem that the wrong quantity is included in the refund request and we get the mentioned error.

thomasbit commented 7 years ago

For further clarification here is our request and response log:

The order included the product with quantity 3. Price per item is 4,95. Two items were returned. Therefore the refund amount of 2*4,95 = 9,90. The problem is: "no[1]=3", this is should be "2" instead of "3".

Request:

s:491:"amount=-990|capturemode=notcompleted|currency=EUR|de[1]=Articlename|ed[1]=|encoding=UTF-8|id[1]=16112100|integrator_name=shopware|integrator_version=5.2.4|invoice_deliverydate=|invoice_deliveryenddate=|invoice_deliverymode=|invoiceappendix=|invoiceid=|it[1]=goods|key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|mid=32895|mode=live|no[1]=3|portalid=2024868|pr[1]=-495|request=debit|sd[1]=|sequencenumber=2|solution_name=fatchip|solution_version=3.4.7|txid=224535954|va[1]=1900";

Response:

s:161:"status=ERROR|errorcode=1610|errormessage=Article list faulty or incomplete|customermessage=An error occured while processing this transaction (wrong parameters).";

fjbender commented 7 years ago

@thomasbit can you look at #93 and confirm that this fixes the error?

thomasbit commented 7 years ago

Just looking at the code, I think this will fix the problem. I will test it in our application.