AbanteCart Community
AbanteCart Development => Extensions and Add-Ons => Payment Modules => Topic started by: 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?
-
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();
}
}
-
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"
<?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!');
}
}
}
?>
-
you should to add
$that = $this->baseObject;
and replace
$this->model_checkout_order->
to $that->model_checkout_order->
-
That's weird. I still cannot trigger the checking. Am I missing something? :'(
-
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