Skip to content

Commit d26e8e6

Browse files
committed
MAG2-171 - Debit for Ratepay will not send basket info when no products or shipping_costs were selected
1 parent 9a26968 commit d26e8e6

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Helper/Api.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use Magento\Quote\Model\Quote;
3030
use Payone\Core\Model\Methods\PayoneMethod;
3131
use Magento\Sales\Model\Order as SalesOrder;
32+
use Payone\Core\Model\Methods\Ratepay\RatepayBase;
3233

3334
/**
3435
* Helper class for everything that has to do with APIs
@@ -275,14 +276,20 @@ public function addPayoneOrderData(SalesOrder $oOrder, $aRequest, $aResponse)
275276
* Check if invoice-data has to be added to the authorization request
276277
*
277278
* @param PayoneMethod $oPayment
279+
* @param array|null $aPositions
278280
* @return bool
279281
*/
280-
public function isInvoiceDataNeeded(PayoneMethod $oPayment)
282+
public function isInvoiceDataNeeded(PayoneMethod $oPayment, $aPositions = null)
281283
{
282284
$sStoreCode = null;
283285
if ($oPayment->getInfoInstance()->getOrder()) {
284286
$sStoreCode = $oPayment->getInfoInstance()->getOrder()->getStore()->getCode();
285287
}
288+
289+
if ($oPayment instanceof RatepayBase && is_array($aPositions) && empty($aPositions)) { // empty array means products and shipping costs were deselected
290+
return false; // RatePay demands that adjustment refunds without products and shipping costs are sent without basket info
291+
}
292+
286293
$blInvoiceEnabled = (bool)$this->getConfigParam('transmit_enabled', 'invoicing', 'payone_general', $sStoreCode); // invoicing enabled?
287294
if ($blInvoiceEnabled || $oPayment->needsProductInfo()) {
288295
return true; // invoice data needed

Model/Api/Request/Debit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function sendRequest(PayoneMethod $oPayment, InfoInterface $oPaymentInfo,
175175
$this->addParameter('invoiceappendix', $sRefundAppendix);
176176
}
177177

178-
if ($this->apiHelper->isInvoiceDataNeeded($oPayment)) {
178+
if ($this->apiHelper->isInvoiceDataNeeded($oPayment, $aPositions)) {
179179
$this->invoiceGenerator->addProductInfo($this, $oOrder, $aPositions, true); // add invoice parameters
180180
}
181181

0 commit comments

Comments
 (0)