<?php
namespace eGHL\Hashing; class eGHL_Hash { protected $TransactionType = NULL; protected $ServiceID = NULL; protected $PaymentID = NULL; protected $TxnID = NULL; protected $TxnStatus = NULL; protected $AuthCode = NULL; protected $OrderNumber = NULL; protected $MerchantReturnURL = NULL; protected $MerchantApprovalURL = NULL; protected $MerchantUnApprovalURL = NULL; protected $MerchantCallBackURL = NULL; protected $Amount = NULL; protected $CurrencyCode = NULL; protected $CustIP = NULL; protected $PageTimeout = NULL; protected $CardNo = NULL; protected $Token = NULL; protected $Param6 = NULL; protected $Param7 = NULL; protected $DateTime = NULL; protected $CustEmail = NULL; protected $CustPhone = NULL; private function spcfb627($spa82d3c, $sp9783ac = false) { if (is_null($spa82d3c) && empty($spa82d3c)) { echo get_class($this) . ':' . __LINE__ . ':TYPE MISSING '; return false; } if ($sp9783ac) { if (strtoupper($spa82d3c) == 'HASHVALUE') { return array('TxnID' => true, 'ServiceID' => true, 'PaymentID' => true, 'TxnStatus' => true, 'Amount' => true, 'CurrencyCode' => true, 'AuthCode' => false); } elseif (strtoupper($spa82d3c) == 'HASHVALUE2') { return array('TxnID' => true, 'ServiceID' => true, 'PaymentID' => true, 'TxnStatus' => true, 'Amount' => true, 'CurrencyCode' => true, 'AuthCode' => false, 'OrderNumber' => true, 'Param6' => false, 'Param7' => false); } } else { if (strtoupper($spa82d3c) == 'SALE') { return array('ServiceID' => true, 'PaymentID' => true, 'MerchantReturnURL' => true, 'MerchantApprovalURL' => false, 'MerchantUnApprovalURL' => false, 'MerchantCallBackURL' => false, 'Amount' => true, 'CurrencyCode' => true, 'CustIP' => true, 'PageTimeout' => false, 'CardNo' => false, 'Token' => false); } elseif (in_array(strtoupper($spa82d3c), array('QUERY', 'REVERSAL', 'CAPTURE', 'REFUND'))) { return array('ServiceID' => true, 'PaymentID' => true, 'Amount' => true, 'CurrencyCode' => true); } elseif (strtoupper($spa82d3c) == 'SOP') { return array('ServiceID' => true, 'PaymentID' => true, 'CustIP' => true); } elseif (strtoupper($spa82d3c) == 'SOP2') { return array('ServiceID' => true, 'PaymentID' => true, 'CustEmail' => true, 'CustPhone' => false, 'Token' => true, 'CustIP' => true); } elseif (strtoupper($spa82d3c) == 'SOPBL') { return array('ServiceID' => true, 'DateTime' => true, 'CurrencyCode' => true); } elseif (strtoupper($spa82d3c) == 'SOPCARD') { return array('ServiceID' => true, 'CustEmail' => false, 'CustPhone' => false, 'Token' => true, 'DateTime' => true); } else { return false; } } } private function sp9f3a8e() { $sp1c406e = array('URL', 'hash_components', 'post_args'); $sp83a0f8 = get_object_vars($this); foreach ($sp83a0f8 as $sp6fd0ce => $sp7b2cf0) { if (!in_array($sp6fd0ce, $sp1c406e)) { if (isset($_REQUEST[$sp6fd0ce])) { $this->{$sp6fd0ce} = $_REQUEST[$sp6fd0ce]; } } } } private function sp8a3b2b($sp52f069) { if (!is_array($sp52f069)) { return false; } $sp83a0f8 = get_object_vars($this); foreach ($sp83a0f8 as $sp6fd0ce => $sp7b2cf0) { if (isset($sp52f069[$sp6fd0ce])) { $this->{$sp6fd0ce} = $sp52f069[$sp6fd0ce]; } } $sp83a0f8 = get_object_vars($this); } private function sp150f5c($spa82d3c, $sp9783ac = false) { foreach ($this->spcfb627($spa82d3c, $sp9783ac) as $sp29cb86 => $sp23062e) { if (is_null($this->{$sp29cb86}) && $sp23062e) { echo 'A mandatory hash component "' . $sp29cb86 . '" is missing...<br/>'; return false; } } return true; } private function spbdbe23($spa82d3c, $sp0e822f, $sp9783ac = false) { if (is_null($spa82d3c) && empty($spa82d3c)) { return false; } if (is_null($sp0e822f)) { return false; } if (!$this->sp150f5c($spa82d3c, $sp9783ac)) { return false; } $sp3d9b2b = NULL; foreach ($this->spcfb627($spa82d3c, $sp9783ac) as $sp29cb86 => $sp23062e) { $sp3d9b2b .= $this->{$sp29cb86}; } return $sp3d9b2b; } public function generateHashValueForPaymentInfo($spa82d3c, $sp0e822f, $sp9783ac = false) { $sp7285b1 = hash('sha256', $sp0e822f . $this->spbdbe23($spa82d3c, $sp0e822f, $sp9783ac)); return $sp7285b1; } function __construct($sp52f069) { if (is_null($sp52f069)) { echo 'Payment Info Required'; } else { $this->sp8a3b2b($sp52f069); } } }