AbanteCart Development > Payment Modules
Validate my order before send it to payment gateway
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:
--- 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?
--- End quote ---
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: ---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();
}
}
--- End code ---
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!');
}
}
}
?>
--- End quote ---
abolabo:
you should to add
--- Code: --- $that = $this->baseObject;
--- End code ---
and replace
--- Code: ---$this->model_checkout_order->
--- End code ---
to
--- Code: ---$that->model_checkout_order->
--- End code ---
seikan:
That's weird. I still cannot trigger the checking. Am I missing something? :'(
Navigation
[0] Message Index
[#] Next page
Go to full version