“Suspected Fraud” status after compeleting the pay

2019-02-21 06:47发布

I have made my custom module in magento, in which I have set discount in dynamically. I am using following code for this. But when I have completed the payment procedure, the order status should be 'processing' but instead of this order status become "Suspected Fraud".

Please let me know what I have done wrong. Although discount added successfully in order information.

$order->setData('base_discount_amount', $discountAmt);

$order->setData('base_discount_canceled', $discountAmt);

$order->setData('base_discount_invoiced', $discountAmt);

$order->setData('base_discount_refunded', $discountAmt);

$order->setData('discount_description', 'Affliate Discount');

$order->setData('discount_amount', $discountAmt);

$order->setData('discount_canceled', $discountAmt);

$order->setData('discount_invoiced', $discountAmt);

$order->setData('discount_refunded', $discountAmt);

2条回答
在下西门庆
2楼-- · 2019-02-21 07:16

It takes me a long time to solve this 0.10 error,

So I will share with you what was the problem in my case:

In:

/app/code/core/Mage/Paypal/Model/Cart.php

There is a _validate function in which PayPal checks the difference between $sum and $referenceAmount.

I replace it with:

if (sprintf('%.4F', $sum) == sprintf('%.4F', $referenceAmount)) {
    $this->_areItemsValid = true;
}

I found it in a Magento backup before the upgrade.

查看更多
太酷不给撩
3楼-- · 2019-02-21 07:32

It's not easy to tell from your question. This can depend on which Magento payment gateway / method you are using (Paypal, Authorize.net, Saved Card etc) as each can implement different methods for transaction authorization, capturing etc.

Take a look at the default Mage_Sales_Model_Order_Payment class. This has several calls to a method called $this->getIsFraudDetected() when attempting to capture funds for a transaction and set the order status to Suspected Fraud if true like so:

if ($this->getIsFraudDetected()) {
    $status = Mage_Sales_Model_Order::STATUS_FRAUD;
}

In the default Payment class the fraud flag is set in the registerCaptureNotification() method when the _isCaptureFinal() method returns false:

if ($this->_isCaptureFinal($amount)) {
    $invoice = $order->prepareInvoice()->register();
    $order->addRelatedObject($invoice);
    $this->setCreatedInvoice($invoice);
} else {
    $this->setIsFraudDetected(true);
    $this->_updateTotals(array('base_amount_paid_online' => $amount));
}

The _isCaptureFinal() methods returns false when the amount you are trying to capture does not equal exactly the remaining order balance.

/**
 * Decide whether authorization transaction may close (if the amount to capture will cover entire order)
 * @param float $amountToCapture
 * @return bool
 */
protected function _isCaptureFinal($amountToCapture)
{
    $amountToCapture = $this->_formatAmount($amountToCapture, true);
    $orderGrandTotal = $this->_formatAmount($this->getOrder()->getBaseGrandTotal(), true);
    if ($orderGrandTotal == $this->_formatAmount($this->getBaseAmountPaid(), true) + $amountToCapture) {
        if (false !== $this->getShouldCloseParentTransaction()) {
            $this->setShouldCloseParentTransaction(true);
        }
        return true;
    }
    return false;
}

Check your totals (requested capture vs. outstanding balance) if using the default payment method or look at your payment methods implementation and use the above information to debug your code...

查看更多
登录 后发表回答