2012-03-21 100 views
0

我已經在magento中製作了我的自定義模塊,我在其中動態設置了折扣。 我正在使用下面的代碼。 但是,當我完成付款程序時,訂單狀態應該是'processing',而不是此訂單狀態變爲「Suspected Fraud」。在magento中完成付款後的「可疑欺詐」狀態?

請讓我知道我做錯了什麼。雖然折扣成功添加了訂單信息。

$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); 
+0

檢查此[可疑的欺詐狀態後,在competingting-the-payment-in-magento](https://stackoverflow.com/questions/9804883/suspected-fraud-status-after-compeleting-the- payments -in-magento/44993619#44993619) – 2017-07-09 06:30:45

回答

4

從您的問題中很難說清楚。這可以在其Magento的支付網關/方法使用的是依賴寶(PayPal,Authorize.net,保存卡等)的每個人都可以實現對交易的授權不同的方法,捕捉等

看看默認Mage_Sales_Model_Order_Payment類。

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

在默認付款類欺詐標誌在registerCaptureNotification()設置:試圖捕捉到的資金用於交易和訂單狀態設置爲涉嫌詐騙,如果true喜歡,所以當這有幾個電話給一個叫$this->getIsFraudDetected()方法法當_isCaptureFinal()方法返回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當您試圖捕獲量並不完全等於剩餘訂單餘額。

/** 
* 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; 
} 

使用默認的付款方式檢查總數(請求的捕獲與餘額),如果還是看您的付款方式實現,並使用這些信息來調試代碼...

+0

我已將「false」標誌更改爲True。現在它爲我工作。但是,是否有最好的方法來做這件事?實際上,我遇到了貝​​寶的這個問題,因爲我收到「可疑欺詐」訂單狀態,並且由於這種狀態,我的客戶無法在通過Paypal付款後收到訂單電子郵件。 - 謝謝你。 – aforankur 2013-10-28 12:12:16

0

我花了很長一段時間來解決這個誤差0.10,

因此,我將與大家分享什麼是在我的情況的問題:

在:

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

有一個_validate功能,其中貝檢查$sum$referenceAmount之間的差異。

我將其替換爲:

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

我發現它在升級前Magento的備份。