Magento Version 1.9.x

  • Requirement

I need to build an extension to alter the checkout flow. I want to send the user info ( email, name, shipping address ) , order info ( product name, quantity ) plus the payment details ( card holder name, card number , payment method etc ) to my fraud detection algorithm. The extension should execute when user clicks the final PAY button. It will gather the required information ( user, order and payment details ) and send it to fraud detection algorithm server. The payment should proceed only if the response from the server is a "GO" else it will throw error message.

  • Done So Far

I have made an event observer for sales_order_save_before to do so.

class Mahadev_FraudDetection_Model_Observer { public function gatherData($observer) { // $payment_info from $_POST global variable at this point. $data = $observer->getEvent()->getOrder(); Mage::log($data->debug(), null, "gatherData.log", true); } }

I can gather the payment information from $_POST variable.

  • Questions

1) sales_order_save_before is the right event to use ? I need to check the order and payment details before the actual payment. If not , which event I should observe ? May be sales_order_save_before is getting triggered after the payment ( not sure yet ).

2) Will this method works with all the payment gateways? and with all kind of checkouts and payment.

3) Please suggest if I can do this in some better way. Is there any event which can give me payments information also. I do not want to gather payments information from $_POST.

4) Can you put some good link to understand advance magento development. I can't find any good resource for building these kind of extensions.

P.S. I am very new to Magento, so please feel free to correct me if I am wrong somewhere.

Thank you.

1 Answer 1


You should try following event


So register event in global scope like:



class Vendor_Module_Model_Observer
    public function fraudDetection($observer)
        $payment = $observer->getEvent()->getPayment();
            Mage::helper('sales')->__('The transaction cannot be fulfil.')

  • This answer is good. Note that it WILL NOT work for all payment methods--all payment methods should fire the observer, but not all have the full credit card number available. Any methods that redirect (PayPal Express) or do a direct post or JS post (Authorize.Net Direct Post, and many others) will at most give you the CC type, expiration date, and last 4 digits.
    – Ryan Hoerr
    Jun 4, 2017 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.