Author Topic: Validate my order before send it to payment gateway  (Read 4562 times)

Offline seikan

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Validate my order before send it to payment gateway
« 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?

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1783
  • Karma: +248/-11
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Validate my order before send it to payment gateway
« Reply #1 on: June 12, 2014, 12:53: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
Code: [Select]
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();
                }
}
« Last Edit: June 12, 2014, 01:02:33 PM by abolabo »
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline seikan

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Validate my order before send it to payment gateway
« Reply #2 on: June 19, 2014, 04:41:17 AM »
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!');
      }
   }
}
?>

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1783
  • Karma: +248/-11
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Validate my order before send it to payment gateway
« Reply #3 on: June 19, 2014, 05:25:17 AM »
you should to add
Code: [Select]
$that = $this->baseObject;
and replace
Code: [Select]
$this->model_checkout_order->
to
Code: [Select]
$that->model_checkout_order->
“No one is useless in this world who lightens the burdens of another.”
― Charles Dickens

Offline seikan

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Validate my order before send it to payment gateway
« Reply #4 on: July 23, 2014, 05:09:30 AM »
That's weird. I still cannot trigger the checking. Am I missing something?  :'(

Offline abolabo

  • core-developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1783
  • Karma: +248/-11
  • web for all, all for web!
    • View Profile
    • AbanteCart
Re: Validate my order before send it to payment gateway
« Reply #5 on: July 23, 2014, 05:24:42 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

 

Powered by SMFPacks Social Login Mod