<?php
/********************************************************/
/*  CALL BACK CODE FROM MONEYBOOKERS                    */
/********************************************************/
define('INCLUDE_STEPS', 'pluginCallback');
require_once dirname(__FILE__) . '/../../../common/common.php';
require_once 'classes/class.gateway.plugin.php';

//Create plug in class to interact with CE
$cPlugin = new Plugin($_POST['transaction_id']);

if ($_POST['status'] == 2) $responsetext = "This transaction has been approved.";
else $responsetext = "This transaction has been declined.";


$hash = $_POST['merchant_id'].$_POST['transaction_id'].strtoupper(md5(trim($GLOBALS["gSettingsArray"]["plugin_moneybookers_Secret Word"]))).$_POST['mb_amount'].$_POST['mb_currency'].$_POST['status'];
$hash = strtoupper(trim(md5(trim($hash))));

if(strcasecmp(trim($_POST['md5sig']), $hash) == 0 && $_POST['status'] == 2) {
    $cPlugin->m_Amount = $_POST['amount'];
    $cPlugin->m_TransactionID = $_POST['mb_transaction_id'];
    $cPlugin->m_Action = "charge";
    $cPlugin->PaymentAccepted($_POST['amount'], $responsetext." MB Trans ID(".$_POST['mb_transaction_id'].")");
} else {
    $cPlugin->PaymentRejected("Error: ".$responsetext." MB Trans ID(".$_POST['mb_transaction_id'].")");
}
?>
