Commit f168ba94 authored by Antonio.Suerte's avatar Antonio.Suerte

Help2Pay Migration [Deposit Webhook Fix]

parent bac49866
......@@ -21,7 +21,7 @@ class H2PDepositWebhook extends System {
private function setParameter(){
$this -> referenceId = $this -> getDataPost("Reference");
$this -> status = $this -> getDataPost("Status");
$this -> lang = $this -> getDataPost("lang");
$this -> lang = $this -> getDataGet("lang");
$this -> responseURL = "Logs/H2P/deposit_response";
$this -> responseDbURL = "Logs/H2P/deposit_db_response";
......@@ -107,39 +107,37 @@ class H2PDepositWebhook extends System {
return $params;
}
private function logTransactionDetails(){
private function logTransactionDetails($content){
$logDate = date("Y-m-d");
$logTimestamp = date("[Y-m-d H:i:s]");
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");
chmod("{$this -> responseURL}/Log_{$logDate}.log", 511);
}
public function listen(){
$logPostVars = print_r($_POST, true);
error_log(
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");
$logPostVars = print_r($_POST, true);
$logGetVars = print_r($_GET, true);
// check deposit transaction
$depositData = $this -> accessSelect("SELECT_DEPOSIT_BY_TRANSACTION_NUMBER", [$this -> referenceId]);
$this -> logTransactionDetails("Accessed\r\nPOST: {$logPostVars}GET: {$logGetVars}");
// fetches temporary transaction data
$temporaryDepositData = $this -> accessSelect("SELECT_DEPOSIT_H2P_TEMP", [$this -> referenceId]);
if($this -> isLoopData($depositData)){
// fetches temporary transaction data
$temporaryDepositData = $this -> accessSelect("SELECT_DEPOSIT_H2P_TEMP", [$this -> referenceId]);
if($this -> isLoopData($temporaryDepositData)){
// check deposit transaction
$depositData = $this -> accessSelect("SELECT_DEPOSIT_BY_TRANSACTION_NUMBER", [$this -> referenceId]);
if($this -> isLoopData($temporaryDepositData)){
if(!$this -> isLoopData($depositData)){
switch($this -> status){
case "000":
case "006":{
case "006":{
$tempDepositRowData = $this -> getRowData($temporaryDepositData);
$this -> accessModify(
"INSERT_WB_DEPOSIT_TRANSACTION",
$this -> credtingDepositData($tempDepositRowData),
$this -> creditingDepositData($tempDepositRowData),
false);
$address = NO_STRING;
......@@ -157,16 +155,19 @@ class H2PDepositWebhook extends System {
$this -> accessModifyCommon('UPDATE_DEPOSIT_ISSENDMAIL', [$this -> referenceId]);
$this -> logTransactionDetails();
$this -> logTransactionDetails("{$this -> referenceId} -deposit_response:\r\n{$this -> status}");
echo "0";
break;
}
default:
$this -> logTransactionDetails("Invalid Status Code\r\n{$this -> status}");
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 {
*/
private $backURI = NO_STRING;
/**
*
* @var string
*/
private $language = NO_STRING;
public function __construct(){
parent::__construct();
$this -> setParameter();
......@@ -134,9 +140,13 @@ class TestDeposit extends System {
$this -> amount = $this -> getDataPost("amount");
$this -> bank = $this -> getDataPost("bank");
$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 -> 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(){
......
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