PHP Code:
<?php
function analyzeNotificationXML(&$xml, &$operation, &$status, &$transid, $idformerchant) {
$operation = '';
$status = '';
$transid = '';
$idformerchant = '';
SimpleXMLElement;
$obj = new ( $xml )( );
Exception {
logTransaction( $GATEWAY['name'], 'Exception: ' . $e, 'Unsuccessful' );
return false;
if (isset( $obj->result[0]->operation )) {
$operation = $obj->result[0]->operation;
}
else {
return false;
}
if (isset( $obj->result[0]->status )) {
$status = $obj->result[0]->status;
}
else {
return false;
}
if (isset( $obj->result[0]->transid )) {
$transid = $obj->result[0]->transid;
}
else {
return false;
}
if (isset( $obj->result[0]->idForMerchant )) {
$idformerchant = $obj->result[0]->idForMerchant;
}
else {
return false;
}
return true;
}
}
include( '../../../dbconnect.php' );
include( '../../../includes/functions.php' );
include( '../../../includes/gatewayfunctions.php' );
include( '../../../includes/invoicefunctions.php' );
require_once( '../hipay/mapi_package.php' );
$gatewaymodule = 'hipay';
$GATEWAY = getGatewayVariables( $gatewaymodule );
if (!$GATEWAY['type']) {
exit( 'Module Not Activated' );
}
$xml = html_entity_decode( trim( $_POST['xml'] ) );
if (isset( $xml )) {
$ret = analyzeNotificationXML( $xml, &$operation, &$status, &$transid, &$idformerchant );
}
else {
logTransaction( $GATEWAY['name'], 'No POST data', 'Unsuccessful' );
return null;
}
if ($ret = false) {
logTransaction( $GATEWAY['name'], $xml, 'Unsuccessful' );
return 1;
}
$status = $status;
$invoiceid = $idformerchant;
$transid = $transid;
$amount = $amount;
$fee = 0;
$invoiceid = checkCbInvoiceID( $invoiceid, $GATEWAY['name'] );
checkCbTransID( $transid );
if (( $status = 'ok' && $operation = 'capture' )) {
addInvoicePayment( $invoiceid, $transid, $amount, $fee, $gatewaymodule );
logTransaction( $GATEWAY['name'], $xml, 'Successful' );
return 1;
}
logTransaction( $GATEWAY['name'], $xml, 'Unsuccessful' );
?>