问题描述
我在 magento 中制作了我的自定义模块,我在其中动态设置了折扣.我为此使用以下代码.但是当我完成支付程序后,订单状态应该是'processing
',但这个订单状态变成了Suspected Fraud
".
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);
推荐答案
从你的问题中很难判断.这可能取决于您使用的 Magento 支付网关/方法(Paypal、Authorize.net、Saved Card 等),因为每种方法都可以实现不同的交易授权、捕获等方法.
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.
看看默认的 Mage_Sales_Model_Order_Payment
类.当尝试捕获交易的资金并将订单状态设置为可疑欺诈时,这会多次调用名为 $this->getIsFraudDetected()
的方法,如果 true
像这样:
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;
}
在默认支付类中,当 _isCaptureFinal()
方法返回 false
时,在 registerCaptureNotification()
方法中设置欺诈标志:
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));
}
当您尝试捕获的金额不完全等于剩余订单余额时,_isCaptureFinal()
方法返回 false
.
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...
这篇关于“涉嫌诈骗"在 magento 中完成付款后的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!