Last active
October 13, 2015 12:08
-
-
Save mklooss/4193690 to your computer and use it in GitHub Desktop.
Magento PayPal CronJob - Fraud False Positiv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PaypalFraud | |
{ | |
const PAYPAL_FRAUD_LOG = "paypal_cron_fraud.log"; | |
public function changeFraudStatus() | |
{ | |
$collection_of_orders = Mage::getModel('sales/order')->getCollection(); | |
$collection_of_orders->addFieldToFilter('status',array('fraud', 'payment_review')); | |
foreach($collection_of_orders as $order) | |
{ | |
self::Log("Suspected Fraud / Processing Review check: Changing order #" . $order->getIncrementId() . " to \"Processing\""); | |
$order_new = Mage::getModel('sales/order')->load($order->getId()); | |
$order_new->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, "[CRON] Order automatically changed to \"Processing\"",false)->save(); | |
if(!$order->getEmailSent()) { | |
self::Log("Send Order E-Mail#" . $order->getIncrementId()); | |
$order_new->sendNewOrderEmail(); | |
} | |
} | |
if(count($collection_of_orders) > 0) | |
{ | |
self::Log("Fraud detected"); | |
} | |
} | |
protected function Log($message) | |
{ | |
return Mage::log($message,null,self::PAYPAL_FRAUD_LOG); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
could you put a short documentation on how to install this as a cron? Thanks in advance,
Philipp