<?php
/*****************************************************************************************************/
/*  CALL BACK CODE FROM 2CHECKOUT : This code needs to be called from your processor upon completion */
/*****************************************************************************************************/
define('INCLUDE_STEPS', 'pluginCallback');
require_once dirname(__FILE__) . '/../../../common/common.php';
include_once("classes/class.gateway.plugin.php");

////////////////////////////////////

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

$hash  = "$_POST[PAYMENT_ID]:$_POST[PAYEE_ACCOUNT]:$_POST[PAYMENT_AMOUNT]:$_POST[PAYMENT_UNITS]:$_POST[PAYMENT_METAL_ID]:$_POST[PAYMENT_BATCH_NUM]:";
$hash .= "$_POST[PAYER_ACCOUNT]:".md5(trim($cPlugin->GetPluginVariable("plugin_egold_Alternate Passphrase"))).":$_POST[ACTUAL_PAYMENT_OUNCES]:$_POST[USD_PER_OUNCE]:$_POST[FEEWEIGHT]:$_POST[TIMESTAMPGMT]";
$hash  = trim(md5(strtoupper(trim($hash))));

if(strcasecmp(trim($_POST['V2_HASH']), $hash) == 0)
   $cPlugin->PaymentAccepted($_POST["PAYMENT_AMOUNT"]);

else
   $cPlugin->PaymentRejected("Error");
?>
