Commit 435afa02 authored by Antonio.Suerte's avatar Antonio.Suerte

Help2Pay Migration [Withdrawal Webhook Debugger]

parent b9dc972e
...@@ -77,21 +77,44 @@ class H2PWithdrawalWebhook extends System { ...@@ -77,21 +77,44 @@ class H2PWithdrawalWebhook extends System {
return $params; return $params;
} }
public function listen(){ private function logEvent($message, $logType){
$logDate = date("Y-m-d"); $logDir = NO_STRING;
$response = implode("&", $_POST);
switch($logType){
case VAL_INT_1:
$logDir = $this -> accessLog;
break;
case VAL_INT_2:
$logDir = $this -> errorLog;
break;
case VAL_INT_3:
$logDir = $this -> successLog;
break;
}
$logDate = date("Y-m-d");
$logTimeStamp = date("[Y-m-d H:i:s]");
//log the access details
error_log( error_log(
date("[Y-m-d H:i:s]")."\r\nAccessed: {$response}\r\n\r\n", "{$logTimeStamp}\r\n{$message}\r\n\r\n",
VAL_INT_3, VAL_INT_3,
"{$this -> accessLog}/Log_{$logDate}.log" "{$logDir}/Log_{$logDate}.log"
); );
}
public function listen(){
$response = print_r($_POST, true);
//log the access details
$this -> logEvent("Accessed: {$response}", VAL_INT_1);
if($this -> transactionNum != NO_STRING && $this -> transactionKey != NO_STRING){ if($this -> transactionNum != NO_STRING && $this -> transactionKey != NO_STRING){
$result = $this -> getRowData($this -> accessSelect('SELECT_WITHDRAW_H2P_TEMP', array($this -> transactionNum))); $result = $this -> getRowData($this -> accessSelect('SELECT_WITHDRAW_H2P_TEMP', array($this -> transactionNum)));
if($this -> isLoopData($result)){ if($this -> isLoopData($result)){
$resultData = print_r($result, true);
$this -> logEvent("Withdrawal Transaction Data: {$resultData}", VAL_INT_1);
$memberCode = $this -> getColumnData($result, COLUMN_USER_ACCOUNT); $memberCode = $this -> getColumnData($result, COLUMN_USER_ACCOUNT);
$bankCode = $this -> getColumnData($result, COLUMN_RECEIPT_BANK_NAME); $bankCode = $this -> getColumnData($result, COLUMN_RECEIPT_BANK_NAME);
$language = $this -> getColumnData($result, COLUMN_LANGUAGE); $language = $this -> getColumnData($result, COLUMN_LANGUAGE);
...@@ -117,11 +140,7 @@ class H2PWithdrawalWebhook extends System { ...@@ -117,11 +140,7 @@ class H2PWithdrawalWebhook extends System {
VAR_CS_MAIL_ADDRESS VAR_CS_MAIL_ADDRESS
); );
error_log( $this -> logEvent("success status:\r\n\r\n{$response}", VAL_INT_3);
date("[Y-m-d H:i:s]")."\r\nsuccess status:\r\n\r\n{$response}\r\n\r\n",
VAL_INT_3,
"{$this -> successLog}/Log_{$logDate}.log"
);
break; break;
case "001": case "001":
//update withdraw //update withdraw
...@@ -135,36 +154,20 @@ class H2PWithdrawalWebhook extends System { ...@@ -135,36 +154,20 @@ class H2PWithdrawalWebhook extends System {
VAR_CS_MAIL_ADDRESS VAR_CS_MAIL_ADDRESS
); );
error_log( $this -> logEvent("nfail status:\r\n\r\n{$response}", VAL_INT_2);
date("[Y-m-d H:i:s]")."\r\nfail status:\r\n\r\n{$response}\r\n\r\n",
VAL_INT_3,
"{$this -> errorLog}/Log_{$logDate}.log"
);
break; break;
default: default:
//error, status not valid //error, status not valid
error_log( $this -> logEvent("Error status code invalid:\r\n\r\n{$response}\r\n{$this -> status}", VAL_INT_2);
date("[Y-m-d H:i:s]")."\r\nError status code invalid:\r\n\r\n{$response}\r\n\r\n{$this -> status}\r\n\r\n",
VAL_INT_3,
"{$this -> errorLog}/Log_{$logDate}.log"
);
break; break;
} }
}else{ }else{
//error, member code not valid //error, member code not valid
error_log( $this -> logEvent("Error member code invalid: {$memberCode}", VAL_INT_2);
date("[Y-m-d H:i:s]")."\r\nError member code invalid: {$memberCode}\r\n\r\n",
VAL_INT_3,
"{$this -> errorLog}/Log_{$logDate}.log"
);
} }
}else{ }else{
//error, status not valid //error, status not valid
error_log( $this -> logEvent("Key invalid:\r\n\r\n{$response}", VAL_INT_2);
date("[Y-m-d H:i:s]")."\r\nKey invalid:\r\n\r\n{$response}\r\n\r\n",
VAL_INT_3,
"{$this -> errorLog}/Log_{$logDate}.log"
);
} }
} }
} }
......
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