support

Validate my order before send it to payment gateway

Started by seikan, June 11, 2014, 10:31:48 PM

Previous topic - Next topic

seikan

I'm developing an extension to validate my order against fraudster and cancel the order before send it to payment gateway. Any clues which hooks to use?

abolabo

#1
Quote from: seikan on June 11, 2014, 10:31:48 PM
I'm developing an extension to validate my order against fraudster and cancel the order before send it to payment gateway. Any clues which hooks to use?

you should to set order status "canceled" from hook. But you should to define in which place. i guess on checkout/success page...is it?

add function in your hook class something like this

public function onControllerPagesCheckoutSuccess_InitData() {

//ask remote server about payer
$result = .....

//update order status based on outcome
                $that->loadModel('checkout/order');
                if (!$result)) {
                        $message = 'Attention! Order #'.$order_id.' was flagged as fraudulent' . "\n\n" . $message;
                        $that->model_checkout_order->update($order_id, $order_status, $message, FALSE);
                        //send email to store owner
                        $mail = new AMail();
                        $mail->setSubject($message);
                        $mail->setTo($this->config->get('store_main_email'));
                        $mail->setText($message);
                        $mail->send();
                }
}

"No one is useless in this world who lightens the burdens of another."
― Charles Dickens

seikan

Hi abolabo, thanks for your reply.

Unfortunately, I can't get it working. Can you point out what I done it wrongly?

I got my extension at /extensions/antifraudster/storefront/controller/responses/extension/antifraudster.php"

Quote<?php
if (!defined('DIR_CORE')) {
   header('Location: static_pages/');
}

class ControllerResponsesExtensionAntiFraudster extends AController {

   public function main() {}

   public function onControllerPagesCheckoutSuccess_InitData() {
      $that->loadModel('checkout/order');

      $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);

      if($order_info['payment_country'] == 'NG') {
         die('Fraud detected!');
      }
   }
}
?>

abolabo

you should to add
$that = $this->baseObject;

and replace
$this->model_checkout_order->

to $that->model_checkout_order->
"No one is useless in this world who lightens the burdens of another."
― Charles Dickens

seikan

That's weird. I still cannot trigger the checking. Am I missing something?  :'(

abolabo

Quote from: seikan on July 23, 2014, 05:09:30 AM
Am I missing something?  :'(

yes. you missed $that = $this->baseObject;

$this->baseObject
is instance of controller class that you tried to hook. use it for calls of model etc
"No one is useless in this world who lightens the burdens of another."
― Charles Dickens

Forum Rules Code of conduct
AbanteCart.com 2010 -