Closed EliasKotlyar closed 7 years ago
Hello,
thank you for your input. I will get into this today and I will notify you about the progress. Your work will help me to get this done faster.
Hello,
I had similar problem. All payments by credit card had status "fraud". It looks that method calculateQuoteChecksum (/vendor/wirecard/magento2-wcp/Helper/Data.php) generates incorrect checksum for the response (from bank).
Two properties used to calculate checksum are changed on submit order (probably here /vendor/magento/module-quote/Model/QuoteManagement.php:497 $this->quoteRepository->save($quote);)
for example table quote before submit:
'563', '1', '2016-11-16 21:57:50', '0000-00-00 00:00:00', NULL, '1', '0', '0', '1', '1.0000', '0', '0.0000', '0.0000', 'EUR', 'EUR', 'EUR', '13.3500', '13.3500', NULL, '1489', '3', '1', 'test.mj+mj@gmail.com', 'Herr', 'mm', NULL, 'COMPANY', NULL, NULL, NULL, '1', '0', '127.0.0.1', NULL, NULL, NULL, NULL, 'EUR', '1.0000', '1.0000', NULL, NULL, '7.6800', '7.6800', '7.6800', '7.6800', '1', '0', NULL, '0', NULL
and after:
'563', '1', '2016-11-16 21:57:50', '2016-11-16 22:06:26', NULL, '0', '0', '0', '1', '1.0000', '0', '0.0000', '0.0000', 'EUR', 'EUR', 'EUR', '13.3500', '12.5800', NULL, '1489', '3', '1', 'test.mj.+mj@gmail.com', 'Herr', 'mm', NULL, 'COMPANY', NULL, NULL, NULL, '1', '0', '127.0.0.1', NULL, '200001837', NULL, NULL, 'EUR', '1.0000', '1.0000', NULL, NULL, '7.6800', '6.9800', '7.6800', '6.9800', '1', '0', NULL, '0', NULL
table quote_item before:
'1230', '563', '2016-11-16 21:57:50', '0000-00-00 00:00:00', '49', '1', NULL, '0', '566909', 'Product-1', NULL, NULL, NULL, '0', '0', '500.0000', '1.0000', '7.6800', '7.6800', NULL, '0.0000', '0.0000', '0.0000', '10.0000', '0.7700', '0.7700', '7.6800', '7.6800', '0.0000', '500.0000', 'simple', NULL, NULL, NULL, NULL, NULL, '8.4500', '8.4500', '8.4500', '8.4500', '0.0000', '0.0000', '0', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
after:
'1230', '563', '2016-11-16 21:57:50', '2016-11-16 22:06:26', '49', '1', NULL, '0', '566909', 'Product-1', NULL, NULL, NULL, '0', '0', '500.0000', '1.0000', '6.9800', '6.9800', NULL, '0.0000', '0.0000', '0.0000', '10.0000', '0.7700', '0.7000', '7.6800', '6.9800', '0.0000', '500.0000', 'simple', NULL, NULL, NULL, NULL, NULL, '8.4500', '7.6800', '8.4500', '7.6800', '0.0000', '0.0000', '0', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
I changed my code on:
public function calculateQuoteChecksum($quote)
{
$data = round($quote->getGrandTotal(), $this->getPrecision()) .
$quote->getBaseCurrencyCode() .
$quote->getCustomerEmail();
foreach ($quote->getAllVisibleItems() as $item) {
/** @var \Magento\Quote\Model\Quote\Item $item */
$data .= $item->getSku();
$data .= round($item->getRowTotal(), $this->getPrecision());
$data .= round($item->getTaxAmount(), $this->getPrecision());
}
it works, but it's not good solution. I don't understand why some fields/values are changed on submit (table: quote and quote_item).
do you have any idea how to resolve this problem ? :)
maybe better solution is add new field 'hash' to table 'quote' and update record with quote here /vendor/wirecard/magento2-wcp/Model/AbstractPayment.php:245 after: $init->quoteHash = $this->_dataHelper->calculateQuoteChecksum($quote);
In this case we will have to change just method \Wirecard\CheckoutPage\Helper\Data->compareQuoteChecksum
for ex: public function compareQuoteChecksum($quote, $his) { if ($quote->getHash() != $his) { $this->_logger->debug(METHOD . ':quote checksum mismatch');
return false;
}
return true;
}
is the bad idea ? :)
Hi! the first solution you proposed is actually the correct one. If you take a look at this magento thread (it's v1.7 but the explanation remains) where it's explained what the difference is. When the quote is checked after the payment, the price gets converted to the base price of the shop. Whatever it is, it doesn't necessarily have always be the same. Therefore please use the first solution, it will be taken into account in the next release.
Hello Wirecard-Team,
We figured out an error which we want to report here:
Preconditions
Steps to reproduce:
Expected result
Order is completed without any notices.
Actual result
Order is completed but reported as a fraud
Traceback
We traced this error back to the compareQuoteChecksum method. We included a few additional debug-outputs to the plugin to find out the reason:
Additional Debug Output :
Summary:
The error is triggered due a hash mismatch. The webservice returns a hash and this hash is compared to another hash which is calculated from the quote. Both Hashes are different but should be same.
We are thinking that the wirecard-server-side hash calculation differs from the calculation in magento.
Could you provide us some help with this Error? We are stuck at the development right now.
Feel free to contact us anytime for more information and debug Logs.(Email : elias.kotlyar@mediawave.de)
Many thanks in Advance,
Elias
Appendix : Complete Debug Log: