<?php

$web = 'index.php';

if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
Phar::interceptFileFuncs();
set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
Phar::webPhar(null, $web);
include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
return;
}

if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
Extract_Phar::go(true);
$mimes = array(
'phps' => 2,
'c' => 'text/plain',
'cc' => 'text/plain',
'cpp' => 'text/plain',
'c++' => 'text/plain',
'dtd' => 'text/plain',
'h' => 'text/plain',
'log' => 'text/plain',
'rng' => 'text/plain',
'txt' => 'text/plain',
'xsd' => 'text/plain',
'php' => 1,
'inc' => 1,
'avi' => 'video/avi',
'bmp' => 'image/bmp',
'css' => 'text/css',
'gif' => 'image/gif',
'htm' => 'text/html',
'html' => 'text/html',
'htmls' => 'text/html',
'ico' => 'image/x-ico',
'jpe' => 'image/jpeg',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'js' => 'application/x-javascript',
'midi' => 'audio/midi',
'mid' => 'audio/midi',
'mod' => 'audio/mod',
'mov' => 'movie/quicktime',
'mp3' => 'audio/mp3',
'mpg' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'pdf' => 'application/pdf',
'png' => 'image/png',
'swf' => 'application/shockwave-flash',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'wav' => 'audio/wav',
'xbm' => 'image/xbm',
'xml' => 'text/xml',
);

header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

$basename = basename(__FILE__);
if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
chdir(Extract_Phar::$temp);
include $web;
return;
}
$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
if (!$pt || $pt == '/') {
$pt = $web;
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
exit;
}
$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
header('HTTP/1.0 404 Not Found');
echo "<html>\n <head>\n  <title>File Not Found<title>\n </head>\n <body>\n  <h1>404 - File Not Found</h1>\n </body>\n</html>";
exit;
}
$b = pathinfo($a);
if (!isset($b['extension'])) {
header('Content-Type: text/plain');
header('Content-Length: ' . filesize($a));
readfile($a);
exit;
}
if (isset($mimes[$b['extension']])) {
if ($mimes[$b['extension']] === 1) {
include $a;
exit;
}
if ($mimes[$b['extension']] === 2) {
highlight_file($a);
exit;
}
header('Content-Type: ' .$mimes[$b['extension']]);
header('Content-Length: ' . filesize($a));
readfile($a);
exit;
}
}

class Extract_Phar
{
static $temp;
static $origdir;
const GZ = 0x1000;
const BZ2 = 0x2000;
const MASK = 0x3000;
const START = 'index.php';
const LEN = 6643;

static function go($return = false)
{
$fp = fopen(__FILE__, 'rb');
fseek($fp, self::LEN);
$L = unpack('V', $a = fread($fp, 4));
$m = '';

do {
$read = 8192;
if ($L[1] - strlen($m) < 8192) {
$read = $L[1] - strlen($m);
}
$last = fread($fp, $read);
$m .= $last;
} while (strlen($last) && strlen($m) < $L[1]);

if (strlen($m) < $L[1]) {
die('ERROR: manifest length read was "' .
strlen($m) .'" should be "' .
$L[1] . '"');
}

$info = self::_unpack($m);
$f = $info['c'];

if ($f & self::GZ) {
if (!function_exists('gzinflate')) {
die('Error: zlib extension is not enabled -' .
' gzinflate() function needed for zlib-compressed .phars');
}
}

if ($f & self::BZ2) {
if (!function_exists('bzdecompress')) {
die('Error: bzip2 extension is not enabled -' .
' bzdecompress() function needed for bz2-compressed .phars');
}
}

$temp = self::tmpdir();

if (!$temp || !is_writable($temp)) {
$sessionpath = session_save_path();
if (strpos ($sessionpath, ";") !== false)
$sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
die('Could not locate temporary directory to extract phar');
}
$temp = $sessionpath;
}

$temp .= '/pharextract/'.basename(__FILE__, '.phar');
self::$temp = $temp;
self::$origdir = getcwd();
@mkdir($temp, 0777, true);
$temp = realpath($temp);

if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
self::_removeTmpFiles($temp, getcwd());
@mkdir($temp, 0777, true);
@file_put_contents($temp . '/' . md5_file(__FILE__), '');

foreach ($info['m'] as $path => $file) {
$a = !file_exists(dirname($temp . '/' . $path));
@mkdir(dirname($temp . '/' . $path), 0777, true);
clearstatcache();

if ($path[strlen($path) - 1] == '/') {
@mkdir($temp . '/' . $path, 0777);
} else {
file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
@chmod($temp . '/' . $path, 0666);
}
}
}

chdir($temp);

if (!$return) {
include self::START;
}
}

static function tmpdir()
{
if (strpos(PHP_OS, 'WIN') !== false) {
if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
return $var;
}
if (is_dir('/temp') || mkdir('/temp')) {
return realpath('/temp');
}
return false;
}
if ($var = getenv('TMPDIR')) {
return $var;
}
return realpath('/tmp');
}

static function _unpack($m)
{
$info = unpack('V', substr($m, 0, 4));
 $l = unpack('V', substr($m, 10, 4));
$m = substr($m, 14 + $l[1]);
$s = unpack('V', substr($m, 0, 4));
$o = 0;
$start = 4 + $s[1];
$ret['c'] = 0;

for ($i = 0; $i < $info[1]; $i++) {
 $len = unpack('V', substr($m, $start, 4));
$start += 4;
 $savepath = substr($m, $start, $len[1]);
$start += $len[1];
   $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
& 0xffffffff);
$ret['m'][$savepath][7] = $o;
$o += $ret['m'][$savepath][2];
$start += 24 + $ret['m'][$savepath][5];
$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
}
return $ret;
}

static function extractFile($path, $entry, $fp)
{
$data = '';
$c = $entry[2];

while ($c) {
if ($c < 8192) {
$data .= @fread($fp, $c);
$c = 0;
} else {
$c -= 8192;
$data .= @fread($fp, 8192);
}
}

if ($entry[4] & self::GZ) {
$data = gzinflate($data);
} elseif ($entry[4] & self::BZ2) {
$data = bzdecompress($data);
}

if (strlen($data) != $entry[0]) {
die("Invalid internal .phar file (size error " . strlen($data) . " != " .
$stat[7] . ")");
}

if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
die("Invalid internal .phar file (checksum error)");
}

return $data;
}

static function _removeTmpFiles($temp, $origdir)
{
chdir($temp);

foreach (glob('*') as $f) {
if (file_exists($f)) {
is_dir($f) ? @rmdir($f) : @unlink($f);
if (file_exists($f) && is_dir($f)) {
self::_removeTmpFiles($f, getcwd());
}
}
}

@rmdir($temp);
clearstatcache();
chdir($origdir);
}
}

Extract_Phar::go();
__HALT_COMPILER(); ?>                 4   com/PayMaster/DataConversion/CharacterConversion.php  dd  d?      3   com/PayMaster/DataConversion/DateTimeConversion.php   dd   L      1   com/PayMaster/DataConversion/NumberConversion.phpA  ddA  ў      0   com/PayMaster/DataConversion/SplitConversion.php  dd  G4      4   com/PayMaster/DataConversion/SubstringConversion.php  dd  L"[S      )   com/PayMaster/Decode/ParameterDecoder.php#  dd#  s1      )   com/PayMaster/Encode/ParameterEncoder.php  dd  b      *   com/PayMaster/Entities/PayMasterEntity.php  dd  \4      #   com/PayMaster/Import/ImportFile.php|  dd|        C   com/PayMaster/MessageGenerator/PayMasterRequestMessageGenerator.phpv  ddv  ǂc      D   com/PayMaster/MessageGenerator/PayMasterResponseMessageGenerator.php?  dd?        K   com/PayMaster/MessageGenerator/PayMasterUPPQueryRequestMessageGenerator.php  dd  "%      L   com/PayMaster/MessageGenerator/PayMasterUPPQueryResponseMessageGenerator.phpq  ddq  ն      D   com/PayMaster/MessageRequestBuilder/PaymentRequestMessageBuilder.php  dd        N   com/PayMaster/MessageRequestBuilder/WebServicePaymentRequestMessageBuilder.php.  dd.  zʶ      F   com/PayMaster/MessageResponseBuilder/PaymentResponseMessageBuilder.php  dd        3   com/PayMaster/PropertiesReader/PropertiesReader.php?  dd?  Sg˶      +   com/PayMaster/SecureHash/MessageHashing.php  dd  Ͷ      ,   com/PayMaster/Security/MessageEncryption.php}	  dd}	  8Ƕ      ,   com/PayMaster/WebService/UPPPaymentQuery.xml4  dd4  0      :   com/PayMaster/WebService/UPPPaymentQueryRequestMessage.php  dd        <?php
namespace com\PayMaster\DataConversion;

class CharacterConversion
{
    public function replaceCharacter($string, $charToReplace, $replaceValue){
        if($string == "" ){
            return "";
        }
        return str_replace($charToReplace, $replaceValue, $string);
    }
    
    public function reverseString($string){
        if($string == "" ){
            return "";
        }
        return strrev($string);
    }
}
?><?php
namespace com\PayMaster\DataConversion;

class DateTimeConversion
{
    public function getCurrentDateTime(){
        date_default_timezone_set("Asia/Kuala_Lumpur");
        return date("YmdHis");
    }
    
    public function getCurrentDate(){
        date_default_timezone_set("Asia/Kuala_Lumpur");
        return date("Ymd");
    }
    
    public function getCurrentTime(){
        date_default_timezone_set("Asia/Kuala_Lumpur");
        return substr(date("Hisu"),0,8);
    }
}
?><?php
namespace com\PayMaster\DataConversion;

class NumberConversion
{
    public function convertNumberToString($amount){
        if($amount==""){
            return $amount;
        }
        $amount = str_replace(",","",$amount);
        $amount = str_replace(".","",$amount);
        for($i = strlen($amount)-1;$i<11;$i++){
            $amount = "0" . $amount;
        }
        return $amount;
    }
    public function getNumberOfDecimalPoint($amount){
        if($amount==""){
            return $amount;
        }
        $decimalPoint = strlen($amount);
        if(strpos($amount,".")==""){
            return "0";
        }
        $decimalPoint = $decimalPoint - 1 - strpos($amount, ".");
        
        return $decimalPoint;
    }
    
    public function convertStringToNumber($amount,$decimalPoint){
        $convertToEmpty = true;
        if($amount == ""){
            return "";
        }
        if($decimalPoint==""){
            $decimalPoint = "0";
        }
        $beforeDecimalPoint = substr($amount,0,strlen($amount)-$decimalPoint);
        $afterDecimalPoint = substr($amount,strlen($amount)-$decimalPoint);
        $afterConversion = "";
        
        for($i =0;$i<strlen($beforeDecimalPoint);$i++){
            if(!($beforeDecimalPoint[$i]=="0"&&$convertToEmpty)){
                $afterConversion = $afterConversion . "" . $beforeDecimalPoint[$i];
                $convertToEmpty=false;
            }else{
                if($i==strlen($beforeDecimalPoint)-1){
                    $afterConversion = $afterConversion . "".$beforeDecimalPoint[$i];
                }
            }
            
        }
        if($decimalPoint!="0"){
            $afterConversion = $afterConversion . "." . $afterDecimalPoint;
        }
        return $afterConversion;
    }
}
?><?php
namespace com\PayMaster\DataConversion;

class SplitConversion
{
    public function splitConvertStringToNumber($value,$splitter,$decimalPoint){
        if($value!=""){
            $formationValue = "";
            $numberConversion = new NumberConversion();
            $splitValue = explode($splitter,$value);
            for($i =0;$i<count($splitValue);$i++) {
                if($i==0) {
                    $formationValue = $numberConversion->convertStringToNumber($splitValue[$i], $decimalPoint);
                }else {
                    $formationValue = $formationValue. $splitter. $numberConversion->convertStringToNumber($splitValue[$i],  $decimalPoint);
                }
            }
            return $formationValue;
        }
        return "";
    }
    
    public function splitConvertNumberToString($value,$splitter){
        if($value!=""){
            $formationValue = "";
            $numberConversion = new NumberConversion();
            $splitValue = explode($splitter,$value);
            for($i = 0;$i<count($splitValue);$i++){
                if($i == 0){
                    $formationValue = $numberConversion->convertNumberToString($splitValue[$i]);
                }else{
                    $formationValue = $formationValue . $splitter . $numberConversion->convertNumberToString($splitValue[$i]);
                }
            }
            return $formationValue;
        }
        return "";
        
    }

}
?><?php
namespace com\PayMaster\DataConversion;

class SubstringConversion
{
    public function substringConversion($value,$length){
        if($value == ""){
            return "";
        }
        return substr($value,0,$length);
    }
    
    public function substringRemainingConversion($value,$length){
        if($value == ""){
            return "";
        }
        return substr($value,$length);
    }
    
    public function getStringBetween($str,$from,$to)
    {
        if($str ==""){
            return "";
        }
        $sub = substr($str, strpos($str,$from)+strlen($from),strlen($str));
        return substr($sub,0,strpos($sub,$to));
    }
}
?><?php
namespace com\PayMaster\Decode;

class ParameterDecoder
{
    public function decodeValue($encodedValue){
        $decodeValue=urldecode($encodedValue);
        return $decodeValue;
    }
    
    // Added by KohJC on 14th July 2021 - To cater message encryption/decryption [S]
    public function base64urlDecode($encodedValue){
        $decodeValue=base64_decode(strtr($encodedValue, '-_', '+/'));
        return $decodeValue;
    }
    // Added by KohJC on 14th July 2021 - To cater message encryption/decryption [E]
}
?><?php
namespace com\PayMaster\Encode;

class ParameterEncoder
{
    public function encodeValue($plainValue){
        $encodeValue=urlencode($plainValue);
        return $encodeValue;
    }
    
    // Added by KohJC on 14th July 2021 - To cater message encryption/decryption [S]
    public function base64urlEncode($plainValue){
        $encodeValue=strtr(base64_encode($plainValue), '+/', '-_');
        return $encodeValue;
    }
    // Added by KohJC on 14th July 2021 - To cater message encryption/decryption [E]
}
?><?php
namespace com\PayMaster\Entities;

class PayMasterEntity
{
    private $payMasterEntity = array();
    
	public function getPayMasterEntity(){
		return $this->payMasterEntity;
	}
	
    public function setter($fieldName,$fieldValue){
        $this->payMasterEntity[$fieldName] = $fieldValue;
    }
    
    public function getter($fieldName){
        if(array_key_exists($fieldName, $this->payMasterEntity)){
            return $this->payMasterEntity[$fieldName];
        }else{
            return "";
        }
    }
    
    public function toString(){
        foreach ($this->payMasterEntity as $key => $value){
            echo $key."=".$value."\n";
        }
    }
    
    public function remove($fieldName){
        unset($this->payMasterEntity[$fieldName]);
    }
    
    public function removeAll(){
        $this->payMasterEntity = array();
    }
}
?><?php
namespace com\PayMaster\Import;

class ImportFile
{
    public function includeFile($basePath){
        include_once $basePath . "com/PayMaster/DataConversion/CharacterConversion.php";
        include_once $basePath . "com/PayMaster/DataConversion/DateTimeConversion.php";
        include_once $basePath . "com/PayMaster/DataConversion/NumberConversion.php";
        include_once $basePath . "com/PayMaster/DataConversion/SplitConversion.php";
        include_once $basePath . "com/PayMaster/DataConversion/SubstringConversion.php";
        include_once $basePath . "com/PayMaster/Decode/ParameterDecoder.php";
        include_once $basePath . "com/PayMaster/Encode/ParameterEncoder.php";
        include_once $basePath . "com/PayMaster/Entities/PayMasterEntity.php";
        include_once $basePath . "com/PayMaster/MessageGenerator/PayMasterRequestMessageGenerator.php";
        include_once $basePath . "com/PayMaster/MessageGenerator/PayMasterResponseMessageGenerator.php";
        include_once $basePath . "com/PayMaster/MessageGenerator/PayMasterUPPQueryRequestMessageGenerator.php";
        include_once $basePath . "com/PayMaster/MessageGenerator/PayMasterUPPQueryResponseMessageGenerator.php";
        include_once $basePath . "com/PayMaster/MessageRequestBuilder/PaymentRequestMessageBuilder.php";
        include_once $basePath . "com/PayMaster/MessageRequestBuilder/WebServicePaymentRequestMessageBuilder.php";
        include_once $basePath . "com/PayMaster/MessageResponseBuilder/PaymentResponseMessageBuilder.php";
        include_once $basePath . "com/PayMaster/PropertiesReader/PropertiesReader.php";
        include_once $basePath . "com/PayMaster/SecureHash/MessageHashing.php";
        include_once $basePath . "com/PayMaster/Security/MessageEncryption.php";
        include_once $basePath . "com/PayMaster/WebService/UPPPaymentQueryRequestMessage.php";
    }
}
?><?php
namespace com\PayMaster\MessageGenerator;
use com\PayMaster\Entities\PayMasterEntity;
use com\PayMaster\PropertiesReader\PropertiesReader;
use com\PayMaster\DataConversion\SubstringConversion;
use com\PayMaster\Encode\ParameterEncoder;
use com\PayMaster\DataConversion\CharacterConversion;
use com\PayMaster\DataConversion\SplitConversion;
use com\PayMaster\Decode\ParameterDecoder;
use com\PayMaster\SecureHash\MessageHashing;
use com\PayMaster\Security\MessageEncryption;

class PayMasterRequestMessageGenerator
{
    //Private Variable
    private $paymentMessage="";
    private $hashMessage="";
    // Added by KohJC on 14th July 2021 - To cater message encryption/decryption [S]
    private $encryptMessage="";
    private $isDisplayField="false"; //To indicate the field need to be Displayed or not
    // Added by KohJC on 14th July 2021 - To cater message encryption/decryption [E]
    
    public function buildPaymentRequestMessage($paymentMT,PayMasterEntity $payMasterEntity,PropertiesReader $propReader){

        $paymentSchema="";
        $subStringConvert = new SubstringConversion();
        $characterConvert = new CharacterConversion();

        //Payment Type - Card Payment
        if(strpos($payMasterEntity->getter("PaymentID"),"C")!==false){
            $paymentSchema = file_get_contents($propReader->readPropertiesValue("CCSchema"));
        }
        //Payment Type - FPX Payment
        else if(strpos($payMasterEntity->getter("PaymentID"),"D")!==false){
            $paymentSchema = file_get_contents($propReader->readPropertiesValue("FPXSchema"));
        }
        //Payment Type - UPP Payment
        else if(strpos($payMasterEntity->getter("PaymentID"),"U")!==false){
            $paymentSchema = file_get_contents($propReader->readPropertiesValue("UPPSchema"));
        }
        //Added by ChrisOng on 9th Dec 2020 - To support QR Payment [S]
        else if(strpos($payMasterEntity->getter("PaymentID"),"Q")!==false){
            $paymentSchema = file_get_contents($propReader->readPropertiesValue("QRSchema"));
        }
        //Added by ChrisOng on 9th Dec 2020 - To support QR Payment [E]
        //Added by CSW on 13th Jun 2023 - To support Bank Listing [S]
        else if(strpos($payMasterEntity->getter("PaymentID"),"B")!==false){
            $paymentSchema = file_get_contents($propReader->readPropertiesValue("BankListingSchema"));
        }
        //Added by CSW on 13th Jun 2023 - To support Bank Listing [E]

        //Convertion String to JSON
        $jsonSchema = json_decode($paymentSchema,true);
        
        //Get Message Schema
        $messageSchema = $jsonSchema[$paymentMT];
        
        //Build Header - Get Header variables [S]
        foreach($messageSchema as $headerTag => $messageHeader){
            //Build Trailer - Get Trailer variables [S]
            foreach($messageHeader as $trailerKey => $trailerContent){
                //Futher Processing on Message Trailer
                foreach($trailerContent as $trailerContentKey => $trailerValue){
                    if($trailerContentKey == "IfNull" ){
                        if(array_key_exists("MerchantField", $trailerContent)){
                            if($payMasterEntity->getter($trailerContent["MerchantField"])==""){
                                if(array_key_exists("DefaultValue", $trailerValue)){
                                    $payMasterEntity->setter($trailerContent["MerchantField"], $trailerValue["DefaultValue"]);
                                }else{
                                    if(array_key_exists("PropertiesValue", $trailerValue)){
                                        $payMasterEntity->setter($trailerContent["MerchantField"], $propReader->readPropertiesValue($trailerContent["MerchantField"]));
                                    }
                                    if($payMasterEntity->getter($trailerContent["MerchantField"])==""){
                                        if(array_key_exists("ClassName",$trailerValue)){
                                            $className = $characterConvert->replaceCharacter($trailerValue["ClassName"],".","\\");
                                            $methodName = $trailerValue["MethodName"];
                                            if(array_key_exists("Parameter",$trailerValue)){
                                                $parameter = $trailerValue["Parameter"];
                                                for($i = 0;$i<count($parameter);$i++){
                                                    if(strpos($parameter[$i],"prop")!==false){
                                                        $parameter[$i]=$this->overridePropValue($payMasterEntity, $propReader, $parameter[$i]);
                                                    }else if(strpos($parameter[$i],"getter")!==false){
                                                        $parameter[$i]=$payMasterEntity->getter($subStringConvert->getStringBetween($parameter[$i], "'", "'"));
                                                    }
                                                    
                                                }
                                                if(count($parameter)==1){
                                                    $payMasterEntity->setter($trailerContent["MerchantField"], (new $className)->$methodName($parameter[0]));
                                                }
                                                else if(count($parameter)==2){
                                                    $payMasterEntity->setter($trailerContent["MerchantField"], (new $className)->$methodName($parameter[0],$parameter[1]));
                                                }
                                                else if(count($parameter)==3){
                                                    $payMasterEntity->setter($trailerContent["MerchantField"], (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2]));
                                                }
                                                else if(count($parameter)==4){
                                                    $payMasterEntity->setter($trailerContent["MerchantField"], (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2],$parameter[3]));
                                                }
                                                else if(count($parameter)==5){
                                                    $payMasterEntity->setter($trailerContent["MerchantField"], (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2],$parameter[3],$parameter[4]));
                                                }
                                            }else{
                                                $payMasterEntity->setter($trailerContent["MerchantField"], (new $className)->$methodName());
                                            }
                                            
                                            
                                        }
                                    }
                                }
                            }
                        }else{
                            if($payMasterEntity->getter($trailerKey)==""){
                                if(array_key_exists("DefaultValue", $trailerValue)){
                                    $payMasterEntity->setter($trailerKey, $trailerValue["DefaultValue"]);
                                }else{
                                    if(array_key_exists("PropertiesValue", $trailerValue)){
                                        $payMasterEntity->setter($trailerKey, $propReader->readPropertiesValue($trailerKey));
                                    }
                                    if(array_key_exists("ClassName",$trailerValue)){
                                        $className =  $characterConvert->replaceCharacter($trailerValue["ClassName"],".","\\");
                                        $methodName = $trailerValue["MethodName"];
                                        if(array_key_exists("Parameter",$trailerValue)){
                                            $parameter = $trailerValue["Parameter"];
                                            for($i = 0;$i<count($parameter);$i++){
                                                if(strpos($parameter[$i],"prop")!==false){
                                                    $parameter[$i]=$this->overridePropValue($payMasterEntity, $propReader, $parameter[$i]);
                                                }else if(strpos($parameter[$i],"getter")!==false){
                                                    $parameter[$i]=$payMasterEntity->getter($subStringConvert->getStringBetween($parameter[$i], "'", "'"));
                                                }
                                                
                                            }
                                            if(count($parameter)==1){
                                                $payMasterEntity->setter($trailerKey, (new $className)->$methodName($parameter[0]));
                                            }
                                            else if(count($parameter)==2){
                                                $payMasterEntity->setter($trailerKey, (new $className)->$methodName($parameter[0],$parameter[1]));
                                            }
                                            else if(count($parameter)==3){
                                                $payMasterEntity->setter($trailerKey, (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2]));
                                            }
                                            else if(count($parameter)==4){
                                                $payMasterEntity->setter($trailerKey, (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2],$parameter[3]));
                                            }
                                            else if(count($parameter)==5){
                                                $payMasterEntity->setter($trailerKey, (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2],$parameter[3],$parameter[4]));
                                            }
                                        }else{
                                            $payMasterEntity->setter($trailerKey, (new $className)->$methodName());
                                        }
                                        
                                    }
                                }
                            }
                        }
                    }
                    
                    if($trailerContentKey =="Combination"){
                        $arrayField = $trailerValue["MerchantField"];
                        $tempContent="";
                        for($i = 0;$i<count($arrayField);$i++){
                            $tempContent = $tempContent . $payMasterEntity->getter($arrayField[$i]);
                        }
                        $payMasterEntity->setter($trailerKey, $tempContent);
                    }
                    
                    if($trailerContentKey =="Conversion"){
                        if(array_key_exists("MerchantField", $trailerContent)){
                            if($payMasterEntity->getter($trailerContent["MerchantField"])!=""){
                                $className = $characterConvert->replaceCharacter($trailerValue["ClassName"],".","\\");
                                $methodName = $trailerValue["MethodName"];
                                if(array_key_exists("Parameter",$trailerValue)){
                                    $parameter = $trailerValue["Parameter"];
                                    for($i = 0;$i<count($parameter);$i++){
                                        if(strpos($parameter[$i],"prop")!==false){
                                            $parameter[$i]=$this->overridePropValue($payMasterEntity, $propReader, $parameter[$i]);
                                        }else if(strpos($parameter[$i],"getter")!==false){
                                            $parameter[$i]=$payMasterEntity->getter($subStringConvert->getStringBetween($parameter[$i], "'", "'"));
                                        }
                                        
                                    }
                                    if(count($parameter)==1){
                                        $payMasterEntity->setter($trailerContent["MerchantField"], (new $className)->$methodName($parameter[0]));
                                    }
                                    else if(count($parameter)==2){
                                        $payMasterEntity->setter($trailerContent["MerchantField"], (new $className)->$methodName($parameter[0],$parameter[1]));
                                    }
                                    else if(count($parameter)==3){
                                        $payMasterEntity->setter($trailerContent["MerchantField"], (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2]));
                                    }
                                    else if(count($parameter)==4){
                                        $payMasterEntity->setter($trailerContent["MerchantField"], (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2],$parameter[3]));
                                    }
                                    else if(count($parameter)==5){
                                        $payMasterEntity->setter($trailerContent["MerchantField"], (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2],$parameter[3],$parameter[4]));
                                    }
                                    
                                }
                            }
                        }else{
                            if($payMasterEntity->getter($trailerKey)!=""){
                                
                                $className = $characterConvert->replaceCharacter($trailerValue["ClassName"],".","\\");
                                $methodName = $trailerValue["MethodName"];
                                if(array_key_exists("Parameter",$trailerValue)){
                                    $parameter = $trailerValue["Parameter"];
                                    for($i = 0;$i<count($parameter);$i++){
                                        if(strpos($parameter[$i],"prop")!==false){
                                            $parameter[$i]=$this->overridePropValue($payMasterEntity, $propReader, $parameter[$i]);
                                        }else if(strpos($parameter[$i],"getter")!==false){
                                            $parameter[$i]=$payMasterEntity->getter($subStringConvert->getStringBetween($parameter[$i], "'", "'"));
                                        }
                                        
                                    }
                                    if(count($parameter)==1){
                                        $payMasterEntity->setter($trailerKey, (new $className)->$methodName($parameter[0]));
                                    }
                                    else if(count($parameter)==2){
                                        $payMasterEntity->setter($trailerKey, (new $className)->$methodName($parameter[0],$parameter[1]));
                                    }
                                    else if(count($parameter)==3){
                                        $payMasterEntity->setter($trailerKey, (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2]));
                                    }
                                    else if(count($parameter)==4){
                                        $payMasterEntity->setter($trailerKey, (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2],$parameter[3]));
                                    }
                                    else if(count($parameter)==5){
                                        $payMasterEntity->setter($trailerKey, (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2],$parameter[3],$parameter[4]));
                                    }
                                    
                                }
                            }
                        }
                        
                    }
                    
                    if($trailerContentKey == "Hash"){
                        // Added by KohJC on 14th July 2021 - To cater message encryption/decryption [S]
                        if(array_key_exists("Display", $trailerContent)){
                            $this->isDisplayField = $trailerContent["Display"];
                        }else{
                            $this->isDisplayField = "false"; //Default to false if Display tag is not exist
                        }
                        // Added by KohJC on 14th July 2021 - To cater message encryption/decryption [E]
                        
                        if(array_key_exists("Version", $trailerContent)){
                            $versionBody = $trailerContent["Version"];
                            $versionPublished = "";
                            $versionAbolished = "";
                            $boolPublished = false;
                            $boolAbolished = false;
                            if(array_key_exists("Published", $versionBody)){
                                $versionPublished = $versionBody["Published"];
                                $boolPublished = true;
                            }
                            
                            if(array_key_exists("Abolished", $versionBody)){
                                $versionAbolished = $versionBody["Abolished"];
                                $boolAbolished = true;
                            }
                            $currentVersion="";
                            if($payMasterEntity->getter("VersionNo")!=""){
                                $currentVersion=$payMasterEntity->getter("VersionNo");
                            }else{
                                $currentVersion=$propReader->readPropertiesValue("VersionNo");
                            }
                            
                            if($boolAbolished && $boolPublished){
                                if($currentVersion >=$versionPublished){
                                    if($currentVersion < $versionAbolished){
                                        if(array_key_exists("MerchantField", $trailerContent)){
                                            if($trailerValue =="true"){
                                                $this->setHashMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                                $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                            }else{
                                                $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                            }
                                        }else{
                                            if($trailerValue =="true"){
                                                $this->setHashMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                                $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                            }else{
                                                $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                            }
                                        }
                                    }
                                }
                                
                            }else if($boolAbolished){
                                if($currentVersion < $versionAbolished){
                                    if(array_key_exists("MerchantField", $trailerContent)){
                                        if($trailerValue =="true"){
                                            $this->setHashMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                            $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                        }else{
                                            $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                        }
                                    }else{
                                        if($trailerValue =="true"){
                                            $this->setHashMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                            $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                        }else{
                                            $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                        }
                                    }
                                }
                            }else if($boolPublished){
                                if($currentVersion >= $versionPublished){
                                    if(array_key_exists("MerchantField", $trailerContent)){
                                        if($trailerValue =="true"){
                                            $this->setHashMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                            $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                        }else{
                                            $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                        }
                                    }else{
                                        if($trailerValue =="true"){
                                            $this->setHashMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                            $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                        }else{
                                            $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                        }
                                    }
                                }
                            }else{
                                if(array_key_exists("MerchantField", $trailerContent)){
                                    if($trailerValue =="true"){
                                        $this->setHashMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                        $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                    }else{
                                        $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                    }
                                }else{
                                    if($trailerValue =="true"){
                                        $this->setHashMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                        $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                    }else{
                                        $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                    }
                                }
                            }
                            
                        }else{
                            if(array_key_exists("MerchantField", $trailerContent)){
                                if($trailerValue =="true"){
                                    $this->setHashMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                    $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                }else{
                                    $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerContent["MerchantField"]),$payMasterEntity);
                                }
                            }else{
                                if($trailerValue =="true"){
                                    $this->setHashMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                    $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                }else{
                                    $this->setPaymentMessage($trailerKey, $payMasterEntity->getter($trailerKey),$payMasterEntity);
                                }
                            }
                        }
                        
                    }
                }
            }
        }
        //Build Trailer - Get Trailer variables [E]
        
        // Edited by KohJC on 14th July 2021 - To cater message encryption/decryption [S]
        if($this->encryptMessage!=""){
            $secretKey=$payMasterEntity->getter("SecretKey")==""? $propReader->readPropertiesValue("SecretKey") : $payMasterEntity->getter("SecretKey");

            $encodeMessage = new ParameterEncoder();
            $messageEncryption = new MessageEncryption();
            
            $this->encryptMessage = $messageEncryption->encryption($this->encryptMessage, $secretKey);
            $this->paymentMessage = $this->paymentMessage==""? $this->encryptMessage : $this->paymentMessage . "&" . $this->encryptMessage;
            $payMasterEntity->setter("paymentMessage", $this->paymentMessage);
            
            return $encodeMessage->base64urlEncode($payMasterEntity->getter("paymentMessage"));
        }
        // Edited by KohJC on 14th July 2021 - To cater message encryption/decryption [E]
        
        return $payMasterEntity->getter("paymentMessage");
    }
    
    public function setPaymentMessage($fieldName,$fieldValue,PayMasterEntity $payMasterEntity){
        $encodeMessage = new ParameterEncoder();
        // Edited by KohJC on 14th July 2021 - To cater message encryption/decryption  [S]
        if($payMasterEntity->getter("Encryption")=="true"){
            if($this->encryptMessage==""){
                $this->encryptMessage = $this->encryptMessage.$fieldName."=".$encodeMessage->encodeValue($fieldValue);
            }else{
                $this->encryptMessage = $this->encryptMessage."&".$fieldName."=".$encodeMessage->encodeValue($fieldValue);
            }
            $payMasterEntity->setter("encryptMessage", $this->encryptMessage);
        }
        
        if($payMasterEntity->getter("Encryption")!="true" || $this->isDisplayField=="true"){
            if($this->paymentMessage==""){
                $this->paymentMessage = $this->paymentMessage.$fieldName."=".$encodeMessage->encodeValue($fieldValue);
            }else{
                $this->paymentMessage = $this->paymentMessage."&".$fieldName."=".$encodeMessage->encodeValue($fieldValue);
            }
            $payMasterEntity->setter("paymentMessage", $this->paymentMessage);
        }
        // Edited by KohJC on 14th July 2021 - To cater message encryption/decryption [E]
    }
    
    public function setHashMessage($fieldName,$fieldValue,PayMasterEntity $payMasterEntity){
        if($this->hashMessage==""){
            $this->hashMessage = $this->hashMessage.$fieldName."=".$fieldValue;
        }else{
            $this->hashMessage = $this->hashMessage."&".$fieldName."=".$fieldValue;
        }
        $payMasterEntity->setter("hashMessage", $this->hashMessage);
    }
    
    public function getPaymentMessage(){
        return $this->paymentMessage;
    }
    
    public function getHashMessage(){
        return $this->hashMessage;
    }
    
    public function overridePropValue(PayMasterEntity $payMasterEntity,PropertiesReader $propReader,$fieldName){
        $subStringConvert = new SubstringConversion();
        if(strpos($fieldName,"'")!==false){
            if($payMasterEntity->getter($subStringConvert->getStringBetween($fieldName, "'", "'"))==""){
                return $propReader->readPropertiesValue($subStringConvert->getStringBetween($fieldName, "'", "'"));
            }else{
                return $payMasterEntity->getter($subStringConvert->getStringBetween($fieldName, "'", "'"));
            }
            
        }else{
            if($payMasterEntity->getter($fieldName)==""){
                return $propReader->readPropertiesValue($fieldName);
            }else{
                return $payMasterEntity->getter($fieldName);
            }
        }
    }
    
}
?>
<?php
namespace com\PayMaster\MessageGenerator;
use com\PayMaster\Entities\PayMasterEntity;
use com\PayMaster\PropertiesReader\PropertiesReader;
use com\PayMaster\DataConversion\SubstringConversion;
use com\PayMaster\Encode\ParameterEncoder;
use com\PayMaster\DataConversion\CharacterConversion;
use com\PayMaster\DataConversion\SplitConversion;
use com\PayMaster\Decode\ParameterDecoder;
use com\PayMaster\SecureHash\MessageHashing;
use com\PayMaster\Security\MessageEncryption;

class PayMasterResponseMessageGenerator
{
    //Private Variable
    private $hashMessage="";
    
    public function buildPaymentResponseMessage($paymentType,PayMasterEntity $payMasterEntity,PropertiesReader $propReader){
        $paymentSchema="";
        $subStringConvert = new SubstringConversion();
        $characterConvert = new CharacterConversion();
        $parameterDecoder = new ParameterDecoder();
        
        //Payment Type - Card Payment
        if($paymentType=="CC"){
            $paymentSchema = file_get_contents($propReader->readPropertiesValue("CCSchema"));
        }
        //Payment Type - FPX Payment
        else if($paymentType=="DD"){
            $paymentSchema = file_get_contents($propReader->readPropertiesValue("FPXSchema"));
        }
        //Payment Type - UPP Payment
        else if($paymentType=="UPP"){
            $paymentSchema = file_get_contents($propReader->readPropertiesValue("UPPSchema"));
        }
        //Added by ChrisOng on 9th Dec 2020 - To support QR Payment [S]
        else if($paymentType=="QR"){
            $paymentSchema = file_get_contents($propReader->readPropertiesValue("QRSchema"));
        }
        //Added by ChrisOng on 9th Dec 2020 - To support QR Payment [E]
        //Added by CSW on 13th Jun 2023 - To support Bank Listing [S]
        else if($paymentType=="BL"){
            $paymentSchema = file_get_contents($propReader->readPropertiesValue("BankListingSchema"));
        }
        //Added by CSW on 13th Jun 2023 - To support Bank Listing [E]
        
        //Convertion String to JSON
        $jsonSchema = json_decode($paymentSchema,true);
        
        // Added by KohJC on 14th July 2021 - To cater message encryption/decryption [S]
        $payMasterEntity->setter("ResponseMessage", $payMasterEntity->getter("ResponseMessage"), $payMasterEntity->getter("SecretKey"), $propReader);
        // Added by KohJC on 14th July 2021 - To cater message encryption/decryption [E]
        
        //Split message
        $messageSeparator = explode("&", $payMasterEntity->getter("ResponseMessage"));
        for($i=0;$i<count($messageSeparator);$i++){
            $splitMsg = explode("=",$messageSeparator[$i],2);
            $payMasterEntity->setter($splitMsg[0], $parameterDecoder->decodeValue(isset($splitMsg[1])?$splitMsg[1]:""));
        }
        
        //Get Message Schema
        $messageSchema = $jsonSchema["MT".$payMasterEntity->getter("h001_MTI")];
        $messageHash = new MessageHashing();
        foreach($messageSchema as $headerTag => $headerTagContent){
            foreach($headerTagContent as $messageTag => $messageTagContent){
                if(array_key_exists("Hash", $messageTagContent)){
                    if(array_key_exists("Version", $messageTagContent)){
                        $versionBody = $messageTagContent["Version"];
                        $versionPublished = "";
                        $versionAbolished = "";
                        $boolPublished = false;
                        $boolAbolished = false;
                        if(array_key_exists("Published", $versionBody)){
                            $versionPublished = $versionBody["Published"];
                            $boolPublished = true;
                        }
                        
                        if(array_key_exists("Abolished", $versionBody)){
                            $versionAbolished = $versionBody["Abolished"];
                            $boolAbolished = true;
                        }
                        $currentVersion="";
                        if($payMasterEntity->getter("VersionNo")!=""){
                            $currentVersion=$payMasterEntity->getter("VersionNo");
                        }else{
                            $currentVersion=$propReader->readPropertiesValue("VersionNo");
                        }
                        
                        if($boolAbolished && $boolPublished){
                            if($currentVersion >=$versionPublished){
                                if($currentVersion < $versionAbolished){
                                    if($messageTagContent["Hash"]=="true"){
                                        $this->setHashMessage($messageTag, $payMasterEntity->getter($messageTag), $payMasterEntity);
                                    }
                                }
                            }
                            
                        }else if($boolAbolished){
                            if($currentVersion < $versionAbolished){
                                if($messageTagContent["Hash"]=="true"){
                                    $this->setHashMessage($messageTag, $payMasterEntity->getter($messageTag), $payMasterEntity);
                                }
                            }
                        }else if($boolPublished){
                            if($currentVersion >= $versionPublished){
                                if($messageTagContent["Hash"]=="true"){
                                    $this->setHashMessage($messageTag, $payMasterEntity->getter($messageTag), $payMasterEntity);
                                }
                            }
                        }else{
                            if($messageTagContent["Hash"]=="true"){
                                $this->setHashMessage($messageTag, $payMasterEntity->getter($messageTag), $payMasterEntity);
                            }
                        }
                        
                    }else{
                        if($messageTagContent["Hash"]=="true"){
                            $this->setHashMessage($messageTag, $payMasterEntity->getter($messageTag), $payMasterEntity);
                        }
                    }
                }
            }
        }
        $generatedHash = $messageHash->hashMessageInSHA2($this->overridePropValue($payMasterEntity, $propReader, "SecretKey"), $this->getHashMessage());
        if($messageHash->compareMessageHashing($payMasterEntity->getter("t002_SHV"), $generatedHash)==false){
            $payMasterEntity->setter("f258_TxnStatDetCde", "5015");
            $payMasterEntity->setter("f259_TxnStatMsg", "Invalid Secure Hash Value, failed validate secure hash");
        }
        
        
        foreach($messageSchema as $headerTag => $headerTagContent){
            foreach($headerTagContent as $messageTag => $messageTagContent){
                foreach($messageTagContent as $messageContentKey => $ContentValue){
                    if($messageContentKey=="Conversion"){
                        $className = $characterConvert->replaceCharacter($ContentValue["ClassName"],".","\\");
                        $methodName = $ContentValue["MethodName"];
                        if(array_key_exists("Parameter", $ContentValue)){
                            $parameter = $ContentValue["Parameter"];
                            for($i = 0;$i<count($parameter);$i++){
                                if(strpos($parameter[$i],"prop")!==false){
                                    $parameter[$i]=$this->overridePropValue($payMasterEntity, $propReader, $parameter[$i]);
                                }else if(strpos($parameter[$i],"getter")!==false){
                                    $parameter[$i]=$payMasterEntity->getter($subStringConvert->getStringBetween($parameter[$i], "'", "'"));
                                }
                            }
                            if(count($parameter)==1){
                                $payMasterEntity->setter($messageTag, (new $className)->$methodName($parameter[0]));
                            }
                            else if(count($parameter)==2){
                                $payMasterEntity->setter($messageTag, (new $className)->$methodName($parameter[0],$parameter[1]));
                            }
                            else if(count($parameter)==3){
                                $payMasterEntity->setter($messageTag, (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2]));
                            }
                            else if(count($parameter)==4){
                                $payMasterEntity->setter($messageTag, (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2],$parameter[3]));
                            }
                            else if(count($parameter)==5){
                                $payMasterEntity->setter($messageTag, (new $className)->$methodName($parameter[0],$parameter[1],$parameter[2],$parameter[3],$parameter[4]));
                            }
                        }else{
                            $payMasterEntity->setter($messageTag, (new $className)->$methodName());
                        }
                    }
                    
                    if($messageContentKey=="SplitConversion"){
                        $className = $characterConvert->replaceCharacter($ContentValue["ClassName"],".","\\");
                        $methodName = $ContentValue["MethodName"];
                        $parameter = $ContentValue["Parameter"];
                        for($i = 0;$i<count($parameter);$i++){
                            if(strpos($parameter[$i],"prop")!==false){
                                $parameter[$i]=$this->overridePropValue($payMasterEntity, $propReader, $parameter[$i]);
                            }else if(strpos($parameter[$i],"getter")!==false){
                                $parameter[$i]=$payMasterEntity->getter($subStringConvert->getStringBetween($parameter[$i], "'", "'"));
                            }
                        }
                        $merchantField = $ContentValue["MerchantField"];
                        for($i=0;$i<count($merchantField);$i++){
                            
                            $payMasterEntity->setter($merchantField[$i], (new $className)->$methodName($parameter[0],$parameter[1]));
                            if(strlen($parameter[0])>$parameter[1]){
                                $parameter[0]= $subStringConvert->substringRemainingConversion($parameter[0], $parameter[1]);
                            }
                            
                        }
                    }
                    
                    if($messageContentKey=="IfElse"){
                        $fromValue = $ContentValue["FromValue"];
                        $compareTo = $ContentValue["CompareTo"];
                        $trueValue = $ContentValue["True"];
                        $falseValue = $ContentValue["False"];
                        
                        if(strpos($fromValue,"prop")!==false){
                            $fromValue=$this->overridePropValue($payMasterEntity, $propReader, $fromValue);
                        }else if(strpos($fromValue,"getter")!==false){
                            $fromValue=$payMasterEntity->getter($subStringConvert->getStringBetween($fromValue, "'", "'"));
                        }
                        
                        if(strpos($compareTo,"prop")!==false){
                            $compareTo=$this->overridePropValue($payMasterEntity, $propReader, $compareTo);
                        }else if(strpos($compareTo,"getter")!==false){
                            $compareTo=$payMasterEntity->getter($subStringConvert->getStringBetween($compareTo, "'", "'"));
                        }
                        
                        if(strpos($trueValue,"prop")!==false){
                            $trueValue=$this->overridePropValue($payMasterEntity, $propReader, $trueValue);
                        }else if(strpos($trueValue,"getter")!==false){
                            $trueValue=$payMasterEntity->getter($subStringConvert->getStringBetween($trueValue, "'", "'"));
                        }
                        
                        if(strpos($falseValue,"prop")!==false){
                            $falseValue=$this->overridePropValue($payMasterEntity, $propReader, $falseValue);
                        }else if(strpos($falseValue,"getter")!==false){
                            $falseValue=$payMasterEntity->getter($subStringConvert->getStringBetween($falseValue, "'", "'"));
                        }
                        
                        if($fromValue == $compareTo){
                            $payMasterEntity->setter($messageTag, $trueValue);
                        }else{
                            $payMasterEntity->setter($messageTag, $falseValue);
                        }
                    }
                }
                
            }
        }
        
        foreach($messageSchema as $headerTag => $headerTagContent){
            foreach($headerTagContent as $messageTag => $messageTagContent){
                //Set Merchant Field Value;
                if(array_key_exists("MerchantField", $messageTagContent)){
                    $payMasterEntity->setter($messageTagContent["MerchantField"], $payMasterEntity->getter($messageTag));
                    $payMasterEntity->remove($messageTag);
                }
            }
        }
    }
        
    public function setHashMessage($fieldName,$fieldValue,PayMasterEntity $payMasterEntity){
        if($this->hashMessage==""){
            $this->hashMessage = $this->hashMessage.$fieldName."=".$fieldValue;
        }else{
            $this->hashMessage = $this->hashMessage."&".$fieldName."=".$fieldValue;
        }
    }
        
    public function getHashMessage(){
        return $this->hashMessage;
    }
    
    public function overridePropValue(PayMasterentity $payMasterEntity,PropertiesReader $propReader,$fieldName){
        $subStringConvert = new SubstringConversion();
        if(strpos($fieldName,"'")!==false){
            if($payMasterEntity->getter($subStringConvert->getStringBetween($fieldName, "'", "'"))==""){
                return $propReader->readPropertiesValue($subStringConvert->getStringBetween($fieldName, "'", "'"));
            }else{
                return $payMasterEntity->getter($subStringConvert->getStringBetween($fieldName, "'", "'"));
            }
            
        }else{
            if($payMasterEntity->getter($fieldName)==""){
                return $propReader->readPropertiesValue($fieldName);
            }else{
                return $payMasterEntity->getter($fieldName);
            }
        }
    }
    
    // Added by KohJC on 14th July 2021 - To cater message encryption/decryption [S]
    public function decryptMessage($encryptedMessage, $secretKey, PropertiesReader $propReader){
        $MessageEncryption = new MessageEncryption();
        $parameterDecoder = new ParameterDecoder();
        $message = $encryptedMessage;
        $key = $secretKey==""? $propReader->readPropertiesValue("SecretKey") : $secretKey;
        
        if(strpos($message,"&")===false){
            $message = $parameterDecoder->base64urlDecode($message);
        }
        
        if(strpos($message,"encryptedData=")!==false && strpos($message,"&iv=")!==false){
            list($paymentMessage, $encryptedPart) = explode("encryptedData=", $message, 2);
            list($encryptedData, $iv) = explode("&iv=", $encryptedPart, 2);
            
            $decryptMessage=$MessageEncryption->decryption($encryptedData, $key, $iv);
            $message = $paymentMessage . $decryptMessage;
        }
        
        return $message;
    }
    // Added by KohJC on 14th July 2021 - To cater message encryption/decryption [E]
}
?><?php
namespace com\PayMaster\MessageGenerator;

use com\PayMaster\PropertiesReader\PropertiesReader;
use com\PayMaster\Entities\PayMasterEntity;
use com\PayMaster\DataConversion\DateTimeConversion;
use com\PayMaster\SecureHash\MessageHashing;

class PayMasterUPPQueryRequestMessageGenerator
{
    public function UPPPaymentQueryRequestMessage(PropertiesReader $propReader, PayMasterEntity $payMasterEntity){
        $datetimeConvert = new DateTimeConversion();
        $messageHash = new MessageHashing();
        //Message Header
        $h001="0780";
        $h002="";
        if($payMasterEntity->getter("VersionNo")!=""){
            $h002 = $payMasterEntity->getter("VersionNo");
        }else{
            $h002 = $propReader->readPropertiesValue("VersionNo");
        }
        $h003 = $datetimeConvert->getCurrentDate();
        $h004 = $datetimeConvert->getCurrentTime();
        
        //Message Content
        $f001="";
        if($payMasterEntity->getter("MerchantID")!=""){
            $f001 = $payMasterEntity->getter("MerchantID");
        }else{
            $f001 = $propReader->readPropertiesValue("MerchantID");
        }
        $f260 = "";
        if($payMasterEntity->getter("ServiceID")!=""){
            $f260 = $payMasterEntity->getter("ServiceID");
        }else{
            $f260 = $propReader->readPropertiesValue("ServiceID");
        }
        $f263 = $payMasterEntity->getter("MerchRefNo");
        $f284 = "";
        if($payMasterEntity->getter("QueryRespURL")!=""){
            $f284 = $payMasterEntity->getter("QueryRespURL");
        }else{
            $f284 = $propReader->readPropertiesValue("QueryRespURL");
        }
        //Message Trailer
        $t001 = "";
        if($payMasterEntity->getter("SHAlgorithmType")!=""){
            $t001 = $payMasterEntity->getter("SHAlgorithmType");
        }else{
            $t001 = $propReader->readPropertiesValue("SHAlgorithmType");
        }
        $t002 = "";
        //Generate Hash
        $secretKey = "";
        if($payMasterEntity->getter("SecretKey")!=""){
            $secretKey = $payMasterEntity->getter("SecretKey");
        }else{
            $secretKey = $propReader->readPropertiesValue("SecretKey");
        }
        $message = "h001_MTI=".$h001."&h002_VNO=".$h002."&h003_TDT=".$h003."&h004_TTM=".$h004."&f001_MID=".$f001."&f260_ServID=".$f260."&f263_MRN=".$f263."&f284_RURL_UPPPQ=".$f284;
        // Edited by JC - Version 3.0.1 [S]
        $t002 = $messageHash->hashMessageInSHA2($secretKey, $message);
        // Edited by JC - Version 3.0.1 [E]
        
        //Build WS
        $query0780 = array (
            'f001_MID' => $f001,
            'f260_ServID' => $f260,
            'f263_MRN' => $f263,
            'f284_RURL_UPPPQ' => $f284,
            'h001_MTI' => $h001,
            'h002_VNO' => $h002,
            'h003_TDT' => $h003,
            'h004_TTM' => $h004,
            't001_SHT' => $t001,
            't002_SHV' => $t002
        );
        return $query0780;
    }
}
?><?php
namespace com\PayMaster\MessageGenerator;

use com\PayMaster\PropertiesReader\PropertiesReader;
use com\PayMaster\Entities\PayMasterEntity;
use com\PayMaster\DataConversion\NumberConversion;

class PayMasterUPPQueryResponseMessageGenerator
{
    public function UPPPaymentQueryResponseMessage($query0790,PropertiesReader $propReader, PayMasterEntity $payMasterEntity){
        $numberConvert = new NumberConversion();        
        $payMasterEntity->setter("MerchantID",$query0790["f001_MID"]);
        $payMasterEntity->setter("MerchRefNo",$query0790["f263_MRN"]);
        if($query0790["f283_UPP_PM"]=="00"){
            $payMasterEntity->setter("TxnStatus",$query0790["f009_RespCode"]);
        }else if($query0790["f283_UPP_PM"]=="01"){
            $payMasterEntity->setter("TxnStatus",$query0790["f254_DDRespCode"]);
        }else{
            $payMasterEntity->setter("TxnStatus",$query0790["f009_RespCode"]);
        }
        $payMasterEntity->setter("QueryStatus",$query0790["f274_QRespCode"]);
        $payMasterEntity->setter("SHAlgorithmType",$query0790["t001_SHT"]);
        $payMasterEntity->setter("SHValue",$query0790["t002_SHV"]);
        
        $payMasterEntity->setter("TxnStatDetCde",$query0790["f258_TxnStatDetCde"]);
        $payMasterEntity->setter("TxnStatMsg",$query0790["f259_TxnStatMsg"]);
        $payMasterEntity->setter("OrderRefNo",$query0790["f270_ORN"]);
        $payMasterEntity->setter("TxnDtTm",$query0790["f006_TxnDtTm"]);
        $payMasterEntity->setter("CurrCode",$query0790["f010_CurrCode"]);
        $payMasterEntity->setter("TxnAmt",$numberConvert->convertStringToNumber($query0790["f007_TxnAmt"],$query0790["f019_ExpTxnAmt"]));
        $payMasterEntity->setter("ExpTxnAmt",$query0790["f019_ExpTxnAmt"]);
        $payMasterEntity->setter("OrigCurrCode",$query0790["f248_OrgCurrCode"]);
        $payMasterEntity->setter("OrigTxnAmt",$numberConvert->convertStringToNumber($query0790["f247_OrgTxnAmt"],$query0790["f287_ExpOrgTxnAmt"]));
        $payMasterEntity->setter("ExpOrigTxnAmt",$query0790["f287_ExpOrgTxnAmt"]);
        $payMasterEntity->setter("UppPymtMode",$query0790["f283_UPP_PM"]);
        $payMasterEntity->setter("FICode",$query0790["f256_FICode"]);
        $payMasterEntity->setter("FPXRefNo",$query0790["f277_DDRN"]);
        $payMasterEntity->setter("PymtGwRefNo",$query0790["f257_PGRN"]);
        $payMasterEntity->setter("CardNo",$query0790["f004_PAN"]);
        if($query0790["f283_UPP_PM"]=="00"){
            $payMasterEntity->setter("OrigRespCode",$query0790["f024_OrgRespCode"]);
        }else{
            $payMasterEntity->setter("OrigRespCode",$query0790["f286_OrgDDRespCode"]);
        }
        $payMasterEntity->setter("AuthIDRespCode",$query0790["f011_AuthIDResp"]);
        $payMasterEntity->setter("RetrievalRefNo",$query0790["f023_RRN"]);
        $payMasterEntity->setter("TxnChannel",$query0790["f249_TxnCh"]);
        $payMasterEntity->setter("ServiceID",$query0790["f260_ServID"]);
        $payMasterEntity->setter("MerchHostID",$query0790["f261_HostID"]);
        $payMasterEntity->setter("MerchSessionID",$query0790["f262_SessID"]);
    }
}
?><?php
namespace com\PayMaster\MessageRequestBuilder;

use com\PayMaster\Entities\PayMasterEntity;
use com\PayMaster\PropertiesReader\PropertiesReader;
use com\PayMaster\MessageGenerator\PayMasterRequestMessageGenerator;

class PaymentRequestMessageBuilder
{
    public function buildPaymentRequestMessage(PayMasterEntity $payMasterEntity,PropertiesReader $propReader){
        $paymentMasterEntryPoint=file_get_contents($propReader->readPropertiesValue("PaymasterEntryPoint"));
        $jsonEntryPoint = json_decode($paymentMasterEntryPoint,true);
        
        $paymentEntryPoint = $jsonEntryPoint["PaymasterEntryPoint"];
        
        $paymentID = $paymentEntryPoint[$payMasterEntity->getter("PaymentID")];
        
        foreach ($paymentID as $key => $value){
            $payMasterEntity->setter($key, $value);
        }
        
        $payMasterRequestMessageGenerator = new PayMasterRequestMessageGenerator();
        $paymentMessage = $payMasterRequestMessageGenerator->buildPaymentRequestMessage($paymentID["MessageType"], $payMasterEntity, $propReader);
        $payMasterEntity->removeAll();
        return $paymentMessage;
    }
    
    
}
?><?php
namespace com\PayMaster\MessageRequestBuilder;

use com\PayMaster\Entities\PayMasterEntity;
use com\PayMaster\PropertiesReader\PropertiesReader;
use com\PayMaster\MessageGenerator\PayMasterUPPQueryRequestMessageGenerator;
use com\PayMaster\WebServices\UPPPaymentQueryRequestMessage;
use com\PayMaster\MessageGenerator\PayMasterUPPQueryResponseMessageGenerator;

class WebServicePaymentRequestMessageBuilder
{
    public function buildUPPQueryRequestMessage(PayMasterEntity $payMasterEntity,PropertiesReader $propReader){
        if($payMasterEntity->getter("PaymentID")=="U02"){
            $payMasterUPPQueryRequestMessageGenerator = new PayMasterUPPQueryRequestMessageGenerator();
            $query0780 = $payMasterUPPQueryRequestMessageGenerator->UPPPaymentQueryRequestMessage($propReader, $payMasterEntity);
            $payMasterEntity->removeAll();
            $uppPaymentQueryRequestMessage = new UPPPaymentQueryRequestMessage();
            $query0790 = $uppPaymentQueryRequestMessage->invokeUPPPaymentQueryWebService($query0780);
            $payMasterUPPQueryResponseMessageGenerator = new PayMasterUPPQueryResponseMessageGenerator();
            $payMasterUPPQueryResponseMessageGenerator->UPPPaymentQueryResponseMessage($query0790, $propReader, $payMasterEntity);
        }
    }
}
?><?php
namespace com\PayMaster\MessageResponseBuilder;
use com\PayMaster\Entities\PayMasterEntity;
use com\PayMaster\PropertiesReader\PropertiesReader;
use com\PayMaster\MessageGenerator\PayMasterResponseMessageGenerator;
class PaymentResponseMessageBuilder
{
    public function buildCardPaymentResponseMessage(PayMasterEntity $payMasterEntity,PropertiesReader $propReader){    
        $payMasterResponseMessageGenerator = new PayMasterResponseMessageGenerator();
        return $payMasterResponseMessageGenerator->buildPaymentResponseMessage("CC", $payMasterEntity, $propReader);
    }
    
    public function buildFPXPaymentResponseMessage(PayMasterEntity $payMasterEntity,PropertiesReader $propReader){
        $payMasterResponseMessageGenerator = new PayMasterResponseMessageGenerator();
        return $payMasterResponseMessageGenerator->buildPaymentResponseMessage("DD", $payMasterEntity, $propReader);
    }
    
    public function buildUPPPaymentResponseMessage(PayMasterEntity $payMasterEntity,PropertiesReader $propReader){
        $payMasterResponseMessageGenerator = new PayMasterResponseMessageGenerator();
        return $payMasterResponseMessageGenerator->buildPaymentResponseMessage("UPP", $payMasterEntity, $propReader);
    }
    
    public function buildQRPaymentResponseMessage(PayMasterEntity $payMasterEntity,PropertiesReader $propReader){
        $payMasterResponseMessageGenerator = new PayMasterResponseMessageGenerator();
        return $payMasterResponseMessageGenerator->buildPaymentResponseMessage("QR", $payMasterEntity, $propReader);
    }

    public function buildBankListingResponseMessage(PayMasterEntity $payMasterEntity,PropertiesReader $propReader){
        $payMasterResponseMessageGenerator = new PayMasterResponseMessageGenerator();
        return $payMasterResponseMessageGenerator->buildPaymentResponseMessage("BL", $payMasterEntity, $propReader);
    }
    
    public function messageDecryption($encryptedMessage, PropertiesReader $propReader){
        $payMasterResponseMessageGenerator = new PayMasterResponseMessageGenerator();
        return $payMasterResponseMessageGenerator->decryptMessage($encryptedMessage, "",  $propReader);
    }
}
?><?php
namespace com\PayMaster\PropertiesReader;

class PropertiesReader
{
    private $ini_array;
    
    public function __call($name_of_function,$arguments){
        if($name_of_function =="PropertiesReader"){
            switch (count($arguments)){
                case 2:
                    return $this->ini_array=parse_ini_file($arguments[0] . "/" . $arguments[1],true,INI_SCANNER_RAW);
                case 1:
                    return $this->ini_array=parse_ini_file($arguments[0],true,INI_SCANNER_RAW);
            }
        }
    }
    
    public function readPropertiesValue($propertiesName){
        return $this->ini_array[$propertiesName];
    }
	
	public function setPropertiesValue($propertiesName,$propertiesValue){
		$this->ini_array[$propertiesName]=$propertiesValue;
	}
	
	public function updatePropertiesFile($filepath){
		$this->update_ini_file($filepath);
	}
	
	public function update_ini_file( $filepath) { 
		$content = ""; 
		$parsed_ini = parse_ini_file($filepath, true);
		foreach($this->ini_array as $key=>$value){
                $content .= $key."=".$value."\n"; 
        }
		//write it into file
        if (!$handle = fopen($filepath, 'w')) { 
            return false; 
        }
        $success = fwrite($handle, $content);
        fclose($handle); 

	}
}
?><?php
namespace com\PayMaster\SecureHash;

class MessageHashing
{
    public function hashMessageInSHA2($secretKey,$message){
        return strtoupper(hash_hmac("sha256", $message.$secretKey, $secretKey));
    }
    
    public function compareMessageHashing($responseHash, $generatedHash) {
        if($responseHash==$generatedHash) {
            return true;
        }
        return false;
    }
}
?><?php
namespace com\PayMaster\Security;

use com\PayMaster\DataConversion\SubstringConversion;
use com\PayMaster\DataConversion\CharacterConversion;
use com\PayMaster\Encode\ParameterEncoder;
use com\PayMaster\Decode\ParameterDecoder;

class MessageEncryption
{

    private $encryptMethod = "AES-256-CTR";

    public function encryption($message, $secretKey)
    {
        $parameterEncoder = new ParameterEncoder();
        $encryptMessage = "";
        
        // Generate encryption key based on Hash Secret Key
        $encryptionKey = $this->generateKey($secretKey);

        // Generate an IV (initialization vector)
        $iv_size = openssl_cipher_iv_length($this->encryptMethod);
        $iv = openssl_random_pseudo_bytes($iv_size);
        $ivStr = bin2hex($iv);
        $iv = substr($ivStr, 0, 16);

        // Encrypt data
        $encryptedData = openssl_encrypt($message, $this->encryptMethod, $encryptionKey, OPENSSL_NO_PADDING, $iv);

        // Base64url encode on the encrypted data
        $encodedMessage = $parameterEncoder->base64urlEncode($encryptedData);
        
        // Append encryptedData and iv to the message
        $encryptMessage = $encryptMessage . "encryptedData=" . $encodedMessage;
        $encryptMessage = $encryptMessage . "&iv=" . $ivStr;
        
        return $encryptMessage;
    }

    public function decryption($encrypted, $secretKey, $iv)
    {
        $parameterDecoder = new ParameterDecoder();
        
        // Base64url decode on the encrypted data
        $decodedMessage = $parameterDecoder->base64urlDecode($encrypted);

        // Generate encryption key based on Hash Secret Key
        $encryptionKey = $this->generateKey($secretKey);

        // IV
        $iv = substr($iv, 0, 16);

        // Decrypt data
        $decryptedData = openssl_decrypt($decodedMessage, $this->encryptMethod, $encryptionKey, OPENSSL_NO_PADDING, $iv);

        return $decryptedData;
    }

    public function generateKey($secretKey)
    {
        $subStringConvert = new SubstringConversion();
        $characterConvert = new CharacterConversion();
        $salt = $secretKey;
        $salt = $subStringConvert->substringConversion($salt, 42);
        $salt = $subStringConvert->substringRemainingConversion($salt, 10);
        $salt = $characterConvert->reverseString($salt);
        return $salt;
    }
}
?><wsdl:definitions xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://paymaster.finexus.com" xmlns:intf="http://paymaster.finexus.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://paymaster.finexus.com">
<!-- WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT) -->
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://paymaster.finexus.com">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="Query0780Req">
<sequence>
<element name="f001_MID" nillable="true" type="soapenc:string"/>
<element name="f260_ServID" nillable="true" type="soapenc:string"/>
<element name="f263_MRN" nillable="true" type="soapenc:string"/>
<element name="f284_RURL_UPPPQ" nillable="true" type="soapenc:string"/>
<element name="h001_MTI" nillable="true" type="soapenc:string"/>
<element name="h002_VNO" nillable="true" type="soapenc:string"/>
<element name="h003_TDT" nillable="true" type="soapenc:string"/>
<element name="h004_TTM" nillable="true" type="soapenc:string"/>
<element name="t001_SHT" nillable="true" type="soapenc:string"/>
<element name="t002_SHV" nillable="true" type="soapenc:string"/>
</sequence>
</complexType>
<complexType name="Query0790Resp">
<sequence>
<element name="f001_MID" nillable="true" type="soapenc:string"/>
<element name="f004_PAN" nillable="true" type="soapenc:string"/>
<element name="f006_TxnDtTm" nillable="true" type="soapenc:string"/>
<element name="f007_TxnAmt" nillable="true" type="soapenc:string"/>
<element name="f009_RespCode" nillable="true" type="soapenc:string"/>
<element name="f010_CurrCode" nillable="true" type="soapenc:string"/>
<element name="f011_AuthIDResp" nillable="true" type="soapenc:string"/>
<element name="f019_ExpTxnAmt" nillable="true" type="soapenc:string"/>
<element name="f023_RRN" nillable="true" type="soapenc:string"/>
<element name="f024_OrgRespCode" nillable="true" type="soapenc:string"/>
<element name="f247_OrgTxnAmt" nillable="true" type="soapenc:string"/>
<element name="f248_OrgCurrCode" nillable="true" type="soapenc:string"/>
<element name="f249_TxnCh" nillable="true" type="soapenc:string"/>
<element name="f254_DDRespCode" nillable="true" type="soapenc:string"/>
<element name="f256_FICode" nillable="true" type="soapenc:string"/>
<element name="f257_PGRN" nillable="true" type="soapenc:string"/>
<element name="f258_TxnStatDetCde" nillable="true" type="soapenc:string"/>
<element name="f259_TxnStatMsg" nillable="true" type="soapenc:string"/>
<element name="f260_ServID" nillable="true" type="soapenc:string"/>
<element name="f261_HostID" nillable="true" type="soapenc:string"/>
<element name="f262_SessID" nillable="true" type="soapenc:string"/>
<element name="f263_MRN" nillable="true" type="soapenc:string"/>
<element name="f270_ORN" nillable="true" type="soapenc:string"/>
<element name="f274_QRespCode" nillable="true" type="soapenc:string"/>
<element name="f277_DDRN" nillable="true" type="soapenc:string"/>
<element name="f283_UPP_PM" nillable="true" type="soapenc:string"/>
<element name="f286_OrgDDRespCode" nillable="true" type="soapenc:string"/>
<element name="f287_ExpOrgTxnAmt" nillable="true" type="soapenc:string"/>
<element name="h001_MTI" nillable="true" type="soapenc:string"/>
<element name="h002_VNO" nillable="true" type="soapenc:string"/>
<element name="h003_TDT" nillable="true" type="soapenc:string"/>
<element name="h004_TTM" nillable="true" type="soapenc:string"/>
<element name="t001_SHT" nillable="true" type="soapenc:string"/>
<element name="t002_SHV" nillable="true" type="soapenc:string"/>
</sequence>
</complexType>
<complexType name="Query0600Req">
<sequence>
<element name="f001_MID" nillable="true" type="soapenc:string"/>
<element name="f004_PAN" nillable="true" type="soapenc:string"/>
<element name="f005_ExpDate" nillable="true" type="soapenc:string"/>
<element name="f253_CntyCode" nillable="true" type="soapenc:string"/>
<element name="f268_CHName" nillable="true" type="soapenc:string"/>
<element name="f269_IssName" nillable="true" type="soapenc:string"/>
<element name="f288_IssCntrCde" nillable="true" type="soapenc:string"/>
<element name="f344_MercCustId" nillable="true" type="soapenc:string"/>
<element name="f345_ActInd" nillable="true" type="soapenc:string"/>
<element name="f346_Token" nillable="true" type="soapenc:string"/>
<element name="f347_TokenShrtNm" nillable="true" type="soapenc:string"/>
<element name="f350_CrdTyp" nillable="true" type="soapenc:string"/>
<element name="f355_CustContcAddr1" nillable="true" type="soapenc:string"/>
<element name="f356_CustContcAddr2" nillable="true" type="soapenc:string"/>
<element name="f357_CustContcAddr3" nillable="true" type="soapenc:string"/>
<element name="f358_CustContcZip" nillable="true" type="soapenc:string"/>
<element name="f359_CustContcStCde" nillable="true" type="soapenc:string"/>
<element name="f360_CustContcTown" nillable="true" type="soapenc:string"/>
<element name="f361_CustContcCntry" nillable="true" type="soapenc:string"/>
<element name="h001_MTI" nillable="true" type="soapenc:string"/>
<element name="h002_VNO" nillable="true" type="soapenc:string"/>
<element name="h003_TDT" nillable="true" type="soapenc:string"/>
<element name="h004_TTM" nillable="true" type="soapenc:string"/>
<element name="t001_SHT" nillable="true" type="soapenc:string"/>
<element name="t002_SHV" nillable="true" type="soapenc:string"/>
</sequence>
</complexType>
<complexType name="Query0610Resp">
<sequence>
<element name="f001_MID" nillable="true" type="soapenc:string"/>
<element name="f006_TxnDtTm" nillable="true" type="soapenc:string"/>
<element name="f009_RespCode" nillable="true" type="soapenc:string"/>
<element name="f258_TxnStatDetCde" nillable="true" type="soapenc:string"/>
<element name="f259_TxnStatMsg" nillable="true" type="soapenc:string"/>
<element name="f344_MercCustId" nillable="true" type="soapenc:string"/>
<element name="h001_MTI" nillable="true" type="soapenc:string"/>
<element name="h002_VNO" nillable="true" type="soapenc:string"/>
<element name="h003_TDT" nillable="true" type="soapenc:string"/>
<element name="h004_TTM" nillable="true" type="soapenc:string"/>
<element name="t001_SHT" nillable="true" type="soapenc:string"/>
<element name="t002_SHV" nillable="true" type="soapenc:string"/>
</sequence>
</complexType>
<complexType name="Query0620Req">
<sequence>
<element name="f001_MID" nillable="true" type="soapenc:string"/>
<element name="f325_ECommMercInd" nillable="true" type="soapenc:string"/>
<element name="f344_MercCustId" nillable="true" type="soapenc:string"/>
<element name="h001_MTI" nillable="true" type="soapenc:string"/>
<element name="h002_VNO" nillable="true" type="soapenc:string"/>
<element name="h003_TDT" nillable="true" type="soapenc:string"/>
<element name="h004_TTM" nillable="true" type="soapenc:string"/>
<element name="t001_SHT" nillable="true" type="soapenc:string"/>
<element name="t002_SHV" nillable="true" type="soapenc:string"/>
</sequence>
</complexType>
<complexType name="ArrayOf_xsd_string">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
</restriction>
</complexContent>
</complexType>
<complexType name="Query0630Resp">
<sequence>
<element name="h001_MTI" nillable="true" type="soapenc:string"/>
<element name="h002_VNO" nillable="true" type="soapenc:string"/>
<element name="h003_TDT" nillable="true" type="soapenc:string"/>
<element name="h004_TTM" nillable="true" type="soapenc:string"/>
<element name="f001_MID" nillable="true" type="soapenc:string"/>
<element name="f006_TxnDtTm" nillable="true" type="soapenc:string"/>
<element name="f009_RespCode" nillable="true" type="soapenc:string"/>
<element name="f258_TxnStatDetCde" nillable="true" type="soapenc:string"/>
<element name="f259_TxnStatMsg" nillable="true" type="soapenc:string"/>
<element name="f344_MercCustId" nillable="true" type="soapenc:string"/>
<element name="f005_ExpDate" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f253_CntyCode" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f268_CHName" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f269_IssName" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f288_IssCntrCde" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f346_Token" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f347_TokenShrtNm" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f348_MaskPAN" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f349_CVVMandFLg" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f350_CrdTyp" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f355_CustContcAddr1" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f356_CustContcAddr2" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f357_CustContcAddr3" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f358_CustContcZip" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f359_CustContcStCde" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f360_CustContcTown" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="f361_CustContcCntry" nillable="true" type="impl:ArrayOf_xsd_string"/>
<element name="t001_SHT" nillable="true" type="soapenc:string"/>
<element name="t002_SHV" nillable="true" type="soapenc:string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="PANProfileMaintenanceQueryRequest">
<wsdl:part name="in0" type="impl:Query0600Req"> </wsdl:part>
</wsdl:message>
<wsdl:message name="UPPPaymentQueryRequest">
<wsdl:part name="in0" type="impl:Query0780Req"> </wsdl:part>
</wsdl:message>
<wsdl:message name="PANProfileMaintenanceQueryResponse">
<wsdl:part name="PANProfileMaintenanceQueryReturn" type="impl:Query0610Resp"> </wsdl:part>
</wsdl:message>
<wsdl:message name="PANListQueryRequest">
<wsdl:part name="in0" type="impl:Query0620Req"> </wsdl:part>
</wsdl:message>
<wsdl:message name="PANListQueryResponse">
<wsdl:part name="PANListQueryReturn" type="impl:Query0630Resp"> </wsdl:part>
</wsdl:message>
<wsdl:message name="UPPPaymentQueryResponse">
<wsdl:part name="UPPPaymentQueryReturn" type="impl:Query0790Resp"> </wsdl:part>
</wsdl:message>
<wsdl:portType name="Gateway">
<wsdl:operation name="UPPPaymentQuery" parameterOrder="in0">
<wsdl:input message="impl:UPPPaymentQueryRequest" name="UPPPaymentQueryRequest"> </wsdl:input>
<wsdl:output message="impl:UPPPaymentQueryResponse" name="UPPPaymentQueryResponse"> </wsdl:output>
</wsdl:operation>
<wsdl:operation name="PANProfileMaintenanceQuery" parameterOrder="in0">
<wsdl:input message="impl:PANProfileMaintenanceQueryRequest" name="PANProfileMaintenanceQueryRequest"> </wsdl:input>
<wsdl:output message="impl:PANProfileMaintenanceQueryResponse" name="PANProfileMaintenanceQueryResponse"> </wsdl:output>
</wsdl:operation>
<wsdl:operation name="PANListQuery" parameterOrder="in0">
<wsdl:input message="impl:PANListQueryRequest" name="PANListQueryRequest"> </wsdl:input>
<wsdl:output message="impl:PANListQueryResponse" name="PANListQueryResponse"> </wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="GatewaySoapBinding" type="impl:Gateway">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="UPPPaymentQuery">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="UPPPaymentQueryRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://paymaster.finexus.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="UPPPaymentQueryResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://paymaster.finexus.com" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="PANProfileMaintenanceQuery">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="PANProfileMaintenanceQueryRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://paymaster.finexus.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="PANProfileMaintenanceQueryResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://paymaster.finexus.com" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="PANListQuery">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="PANListQueryRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://paymaster.finexus.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="PANListQueryResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://paymaster.finexus.com" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="GatewayService">
<wsdl:port binding="impl:GatewaySoapBinding" name="Gateway">
<wsdlsoap:address location="https://dev.finexusgroup.com:10501/upp/services/Gateway"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions><?php
namespace com\PayMaster\WebServices;

class UPPPaymentQueryRequestMessage
{
    public function invokeUPPPaymentQueryWebService($query0780)
    {
        $wsdlLocation = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'UPPPaymentQuery.xml';
        $client = new \SoapClient($wsdlLocation);
        $response = $client->__soapCall("UPPPaymentQuery", array($query0780));
        $query0790 = json_decode(json_encode($response),true);
        return $query0790;
    }
}

?>+QPP# VD钤_*f}р֧u&e   GBMB