Commit 229abd6f authored by Antonio.Suerte's avatar Antonio.Suerte

Help2Pay Migration [Deposit Webhook Fix]

parent 04fa9bb1
...@@ -21,7 +21,7 @@ class H2PDepositWebhook extends System { ...@@ -21,7 +21,7 @@ class H2PDepositWebhook extends System {
private function setParameter(){ private function setParameter(){
$this -> referenceId = $this -> getDataPost("Reference"); $this -> referenceId = $this -> getDataPost("Reference");
$this -> status = $this -> getDataPost("Status"); $this -> status = $this -> getDataPost("Status");
$this -> lang = $this -> getDataPost("lang"); $this -> lang = $this -> getDataGet("lang");
$this -> responseURL = "Logs/H2P/deposit_response"; $this -> responseURL = "Logs/H2P/deposit_response";
$this -> responseDbURL = "Logs/H2P/deposit_db_response"; $this -> responseDbURL = "Logs/H2P/deposit_db_response";
...@@ -107,39 +107,37 @@ class H2PDepositWebhook extends System { ...@@ -107,39 +107,37 @@ class H2PDepositWebhook extends System {
return $params; return $params;
} }
private function logTransactionDetails(){ private function logTransactionDetails($content){
$logDate = date("Y-m-d"); $logDate = date("Y-m-d");
$logTimestamp = date("[Y-m-d H:i:s]"); $logTimestamp = date("[Y-m-d H:i:s]");
error_log( error_log(
"{$logTimestamp}\r\n{$this -> referenceId} -deposit_response:\r\n{$this -> status}\r\n", VAL_INT_3, "{$logTimestamp}\r\n{$content}\r\n", VAL_INT_3,
"{$this -> responseURL}/Log_{$logDate}.log"); "{$this -> responseURL}/Log_{$logDate}.log");
chmod("{$this -> responseURL}/Log_{$logDate}.log", 511);
} }
public function listen(){ public function listen(){
$logPostVars = print_r($_POST, true); $logPostVars = print_r($_POST, true);
error_log( $logGetVars = print_r($_GET, true);
date("Y-m-d h:i:s A")."\r\nAccessed\r\n{$logPostVars}\r\n", VAL_INT_3,
"{$this -> responseURL}/Log_".date("Y-m-d").".log");
// check deposit transaction $this -> logTransactionDetails("Accessed\r\nPOST: {$logPostVars}GET: {$logGetVars}");
$depositData = $this -> accessSelect("SELECT_DEPOSIT_BY_TRANSACTION_NUMBER", [$this -> referenceId]);
// fetches temporary transaction data
$temporaryDepositData = $this -> accessSelect("SELECT_DEPOSIT_H2P_TEMP", [$this -> referenceId]);
if($this -> isLoopData($depositData)){ if($this -> isLoopData($temporaryDepositData)){
// fetches temporary transaction data // check deposit transaction
$temporaryDepositData = $this -> accessSelect("SELECT_DEPOSIT_H2P_TEMP", [$this -> referenceId]); $depositData = $this -> accessSelect("SELECT_DEPOSIT_BY_TRANSACTION_NUMBER", [$this -> referenceId]);
if($this -> isLoopData($temporaryDepositData)){ if(!$this -> isLoopData($depositData)){
switch($this -> status){ switch($this -> status){
case "000": case "000":
case "006":{ case "006":{
$tempDepositRowData = $this -> getRowData($temporaryDepositData); $tempDepositRowData = $this -> getRowData($temporaryDepositData);
$this -> accessModify( $this -> accessModify(
"INSERT_WB_DEPOSIT_TRANSACTION", "INSERT_WB_DEPOSIT_TRANSACTION",
$this -> credtingDepositData($tempDepositRowData), $this -> creditingDepositData($tempDepositRowData),
false); false);
$address = NO_STRING; $address = NO_STRING;
...@@ -157,16 +155,19 @@ class H2PDepositWebhook extends System { ...@@ -157,16 +155,19 @@ class H2PDepositWebhook extends System {
$this -> accessModifyCommon('UPDATE_DEPOSIT_ISSENDMAIL', [$this -> referenceId]); $this -> accessModifyCommon('UPDATE_DEPOSIT_ISSENDMAIL', [$this -> referenceId]);
$this -> logTransactionDetails(); $this -> logTransactionDetails("{$this -> referenceId} -deposit_response:\r\n{$this -> status}");
echo "0"; echo "0";
break; break;
} }
default: default:
$this -> logTransactionDetails("Invalid Status Code\r\n{$this -> status}");
break; break;
} }
} }else
} $this -> logTransactionDetails("Transaction already credited\r\n{$this -> referenceId}");
}else
$this -> logTransactionDetails("Invalid H2P Deposit Transaction\r\n{$this -> referenceId}");
} }
} }
......
...@@ -111,6 +111,12 @@ class TestDeposit extends System { ...@@ -111,6 +111,12 @@ class TestDeposit extends System {
*/ */
private $backURI = NO_STRING; private $backURI = NO_STRING;
/**
*
* @var string
*/
private $language = NO_STRING;
public function __construct(){ public function __construct(){
parent::__construct(); parent::__construct();
$this -> setParameter(); $this -> setParameter();
...@@ -134,9 +140,13 @@ class TestDeposit extends System { ...@@ -134,9 +140,13 @@ class TestDeposit extends System {
$this -> amount = $this -> getDataPost("amount"); $this -> amount = $this -> getDataPost("amount");
$this -> bank = $this -> getDataPost("bank"); $this -> bank = $this -> getDataPost("bank");
$this -> note = $this -> getDataPost("note"); $this -> note = $this -> getDataPost("note");
$this -> language = $this -> getDataPost("lang");
if($this -> language == NO_STRING)
$this -> language = "en";
$this -> frontURI = SITE_PROTOCOL."://".SITE_DOMAIN_FULL."/test/help2pay/deposit_status.php"; $this -> frontURI = SITE_PROTOCOL."://".SITE_DOMAIN_FULL."/test/help2pay/deposit_status.php";
$this -> backURI = SITE_PROTOCOL."://".SITE_DOMAIN_FULL."/api/H2PDepositWebhook.php"; $this -> backURI = SITE_PROTOCOL."://".SITE_DOMAIN_FULL."/api/H2PDepositWebhook.php?lang={$this -> language}";
} }
private function validation(){ private function validation(){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment