Commit 04fa9bb1 authored by Antonio.Suerte's avatar Antonio.Suerte

Help2Pay Migration [Initial Commit]

parent dbe1382b
......@@ -78,23 +78,19 @@ class APNWebHook extends System{
private function creditTransaction($tempDepositData){
$comment = "[APN Reference No.]\\n{$tempDepositData["invoice_num"]}";
foreach($tempDepositData as &$data){
$data = "('){$data}(')";
}
$method = VAL_STR_CCDEPOSIT_METHOD;
$this -> accessModify("INSERT_CC_DEPOSIT_TRANSACTION", [
$this -> accessModify("INSERT_WB_DEPOSIT_TRANSACTION", [
$tempDepositData[COLUMN_TRANSACTION_NUMBER],
$tempDepositData[COLUMN_USER_ACCOUNT],
$tempDepositData[COLUMN_AMOUNT],
$tempDepositData[COLUMN_CURRENCY],
"('){$method}(')",
"(')Credit Card Deposit(')",
$method,
"Credit Card Deposit",
$tempDepositData[COLUMN_DEPOSIT_DATE],
$tempDepositData[COLUMN_FEE],
"('){$comment}(')",
$comment,
$tempDepositData[COLUMN_CREATE_TIME],
NO_COUNT,
NO_COUNT,
......
<?php
include_once('config.php');
class H2PDepositWebhook extends System {
private $referenceId = NO_STRING;
private $status = NO_STRING;
private $lang = NO_STRING;
private $responseURL = NO_STRING;
private $responseDbURL = NO_STRING;
public function __construct(){
parent::__construct();
$this -> setParameter();
$this -> validation();
}
private function setParameter(){
$this -> referenceId = $this -> getDataPost("Reference");
$this -> status = $this -> getDataPost("Status");
$this -> lang = $this -> getDataPost("lang");
$this -> responseURL = "Logs/H2P/deposit_response";
$this -> responseDbURL = "Logs/H2P/deposit_db_response";
}
private function validation(){
if(!file_exists($this -> responseURL)) {
mkdir($this -> responseURL, 0777, true);
}
if(!file_exists($this -> responseDbURL)) {
mkdir($this -> responseDbURL, 0777, true);
}
}
private function commentTemplate($row){
return "Bank:".$row['deposit_bank']
.",Merchant:{$this -> getDataPost('Merchant')}"
.",Status:{$this -> getDataPost('Status')}"
.",Currency:{$this -> getDataPost('Currency')}"
.",Amount:{$this -> getDataPost('Amount')}"
.",Datetime:{$this -> getDataPost('Datetime')}"
.",Customer:{$this -> getDataPost('Customer')}"
.",Language:{$this -> getDataPost('Language')}"
.",Reference:{$this -> getDataPost('Reference')}"
.",ID:{$this -> getDataPost('ID')}"
.",Key:{$this -> getDataPost('Key')}"
.",Note:{$this -> getDataPost('Note')}";
}
private function creditingDepositData($tempDepositRowData){
return [
$this -> getColumnData($tempDepositRowData, COLUMN_TRANSACTION_NUMBER),
$this -> getColumnData($tempDepositRowData, COLUMN_USER_ACCOUNT),
$this -> getColumnData($tempDepositRowData, COLUMN_AMOUNT),
$this -> getColumnData($tempDepositRowData, COLUMN_CURRENCY),
$this -> getColumnData($tempDepositRowData, COLUMN_METHOD),
"Local Bank Transfer(Southeast Asia)",
$this -> getColumnData($tempDepositRowData, COLUMN_DEPOSIT_DATE),
$this -> getColumnData($tempDepositRowData, COLUMN_FEE),
$this -> commentTemplate($tempDepositRowData),
$this -> getColumnData($tempDepositRowData, COLUMN_CREATE_TIME),
NO_COUNT,
NO_COUNT,
"Local Bank Transfer(Southeast Asia)"
];
}
private function emailNoticeParams($tempDepositRowData, &$emailAddress, &$language){
$userAccountNum = $this -> getColumnData($tempDepositRowData, COLUMN_USER_ACCOUNT);
$accountDetails = $this -> getRowData($this -> getAccountCommon($userAccountNum));
$fullName = "{$this -> getColumnData($accountDetails, COLUMN_FIRST_NAME)} {$this -> getColumnData($accountDetails, COLUMN_LAST_NAME)}";
// pointer-referenced
$emailAddress = $this -> getColumnData($accountDetails, COLUMN_MAIL);
$language = $this -> getColumnData($accountDetails, COLUMN_LANGUAGE);
$params = [];
if($this -> isLoopData($accountDetails)){
$params = [
$userAccountNum,
$fullName,
$this -> getColumnData($tempDepositRowData, COLUMN_TRANSACTION_NUMBER),
$this -> getColumnData($tempDepositRowData, COLUMN_CREATE_TIME),
$this -> getColumnData($tempDepositRowData, COLUMN_CURRENCY),
$this -> getAmountString(
$this -> getColumnData($tempDepositRowData, COLUMN_AMOUNT),
$this -> getColumnData($tempDepositRowData, COLUMN_CURRENCY)
),
$this -> getColumnData($tempDepositRowData, COLUMN_CURRENCY),
$this -> getAmountString(
$this -> getColumnData($tempDepositRowData, COLUMN_AMOUNT) +
$this -> getColumnData($tempDepositRowData, COLUMN_FEE),
$this -> getColumnData($tempDepositRowData, COLUMN_CURRENCY)
),
$this -> getColumnData($accountDetails, COLUMN_COUNTRY)
];
}
return $params;
}
private function logTransactionDetails(){
$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,
"{$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");
// check deposit transaction
$depositData = $this -> accessSelect("SELECT_DEPOSIT_BY_TRANSACTION_NUMBER", [$this -> referenceId]);
if($this -> isLoopData($depositData)){
// fetches temporary transaction data
$temporaryDepositData = $this -> accessSelect("SELECT_DEPOSIT_H2P_TEMP", [$this -> referenceId]);
if($this -> isLoopData($temporaryDepositData)){
switch($this -> status){
case "000":
case "006":{
$tempDepositRowData = $this -> getRowData($temporaryDepositData);
$this -> accessModify(
"INSERT_WB_DEPOSIT_TRANSACTION",
$this -> credtingDepositData($tempDepositRowData),
false);
$address = NO_STRING;
$language = NO_STRING;
$params = $this -> emailNoticeParams($tempDepositRowData, $address, $language);
if($address != NO_STRING){
$this -> sendMailByTmp("{$this -> lang}/help2pay_deposit_info.xml",
$params,
$address,
VAR_CS_MAIL_ADDRESS,
$language
);
}
$this -> accessModifyCommon('UPDATE_DEPOSIT_ISSENDMAIL', [$this -> referenceId]);
$this -> logTransactionDetails();
echo "0";
break;
}
default:
break;
}
}
}
}
}
$h2pWebhook = new H2PDepositWebhook();
$h2pWebhook -> listen();
\ No newline at end of file
<?php
require_once "config.php";
class H2PWithdrawalVerification extends System {
private $transactionKey;
private $transactionNum;
// directories
private $accessLog;
private $errorLog;
private $verifyLog;
public function __construct(){
parent::__construct();
$this -> setParameter();
$this -> validation();
}
private function setParameter(){
$this -> transactionKey = $this -> getDataGet("transKey", true);
$this -> transactionNum = $this -> getDataGet("transNum", true);
$this -> accessLog = "Logs/H2P_Withdrawal/verification/access";
$this -> errorLog = "Logs/H2P_Withdrawal/verification/error";
$this -> verifyLog = "Logs/H2P_Withdrawal/verification/verify";
}
private function validation(){
if(!@file_exists($this -> accessLog)){
mkdir($this -> accessLog, 0777, true);
}
if(!@file_exists($this -> errorLog)){
mkdir($this -> errorLog, 0777, true);
}
if(!@file_exists($this -> verifyLog)){
mkdir($this -> verifyLog, 0777, true);
}
}
public function listen(){
$logDate = date("Y-m-d");
error_log(
date("[Y-m-d H:i:s]")."\r\nAccessed\r\n\r\n",
VAL_INT_3,
"{$this -> accessLog}/Log_{$logDate}.log");
$uriResponse = $this -> getColumnData($_SERVER, "REQUEST_URI");
if($this -> transactionKey != NO_STRING && $this -> transactionNum != NO_STRING){
$result = $this -> getRowData($this -> accessSelect("SELECT_WITHDRAW_H2P_TEMP", [$this -> transactionNum]));
if($this -> isLoopData($result)){
//get necessary details from result
$key = $this -> getColumnData($result, 'api_key'); //transaction number
if(strcasecmp($key, $this -> transactionKey) === NO_COUNT){
error_log(
date("[Y-m-d H:i:s]")."\r\nVERIFY:\r\n\r\nTRUE {$this -> transactionNum} {$this -> transactionKey}\r\n\r\n",
VAL_INT_3,
"{$this -> verifyLog}/Log_{$logDate}.log"
);
echo "true";
}else{
error_log(
date("[Y-m-d H:i:s]")."\r\nERROR:\r\n"."\r\nFALSE: Key not verified {$this -> transactionNum} {$this -> transactionKey} vs {$key}\r\n\r\n",
VAL_INT_3,
"{$this -> errorLog}/Log_{$logDate}.log"
);
echo "false";
}
}else{
//false
error_log(
date("[Y-m-d H:i:s]")."\r\nERROR:\r\n\r\nFALSE: Not on database {$this -> transactionNum} {$this -> transactionKey}\r\n\r\n",
VAL_INT_3,
"{$this -> errorLog}/Log_{$logDate}.log"
);
echo "false";
}
}else{
//log the error
error_log(
date("[Y-m-d H:i:s]")."\r\nERROR:\r\n\r\nResponse:\r\n{$uriResponse}\r\n",
VAL_INT_3,
"{$this -> errorLog}/Log_{$logDate}.log"
);
echo "false";
}
}
}
$verification = new H2PWithdrawalVerification();
$verification -> listen();
\ No newline at end of file
<?php
include_once('config.php');
class H2PWithdrawalWebhook extends System {
private $transactionNum = NO_STRING;
private $transactionKey = NO_STRING;
private $memberCode = NO_STRING;
private $status = NO_STRING;
// directories
private $successLog;
private $errorLog;
private $accessLog;
public function __construct(){
parent::__construct();
$this -> setParameter();
$this -> validation();
}
private function setParameter(){
$this -> transactionNum = $this -> getDataPost("TransactionID");
$this -> transactionKey = $this -> getDataPost("Key");
$this -> memberCode = $this -> getDataPost("MemberCode");
$this -> status = $this -> getDataPost("Status");
$this -> successLog = "Logs/H2P_Withdrawal/callback/success";
$this -> errorLog = "Logs/H2P_Withdrawal/callback/error";
$this -> accessLog = "Logs/H2P_Withdrawal/callback/access";
}
private function validation(){
if(!file_exists($this -> successLog)) {
mkdir($this -> successLog, 0777, true);
}
if(!file_exists($this -> errorLog)) {
mkdir($this -> errorLog, 0777, true);
}
if(!file_exists($this -> accessLog)) {
mkdir($this -> accessLog, 0777, true);
}
}
private function emailParams($status, $result){
$params = [];
$memberCode = $this -> getColumnData($result, COLUMN_USER_ACCOUNT);
$amount = $this -> getColumnData($result, COLUMN_AMOUNT);
switch($status){
case "000":
$date = date('Y-m-d H:i:s');
$newdate = strtotime ('-1 hour' , strtotime($date)) ;
$newdate = date('Y-m-d H:i:s', $newdate);
$params = [
$memberCode,
$this -> getUserNameCommon($memberCode),
$this -> getColumnData($result, COLUMN_CURRENCY),
number_format($amount, 2, ".", NO_STRING),
$newdate
];
break;
case "001":
$params = [
$memberCode,
$this -> getUserNameCommon($memberCode)
];
break;
}
return $params;
}
public function listen(){
$logDate = date("Y-m-d");
$response = implode("&", $_POST);
//log the access details
error_log(
date("[Y-m-d H:i:s]")."\r\nAccessed: {$response}\r\n\r\n",
VAL_INT_3,
"{$this -> accessLog}/Log_{$logDate}.log"
);
if($this -> transactionNum != NO_STRING && $this -> transactionKey != NO_STRING){
$result = $this -> getRowData($this -> accessSelect('SELECT_WITHDRAW_H2P_TEMP', array($this -> transactionNum)));
if($this -> isLoopData($result)){
$memberCode = $this -> getColumnData($result, COLUMN_USER_ACCOUNT);
$bankCode = $this -> getColumnData($result, COLUMN_RECEIPT_BANK_NAME);
$language = $this -> getColumnData($result, COLUMN_LANGUAGE);
if(strcasecmp($this -> transactionKey, $this -> getColumnData($result, "api_key")) === 0){
$param = [];
if($this -> memberCode == $memberCode){
$param[] = $this -> transactionNum;
$param[] = $response.'Bank_code:'.$bankCode;
switch($this -> status){
case "000":
//update withdraw
$param[] = VAL_INT_2;
$this -> accessModifyCommon('UPDATE_WITHDRAW_H2P_STATUS', $param);
$this -> accessModifyCommon('UPDATE_WITHDRAW_H2P_TEMP_STATUS', $param);
$this -> sendMailByTmp(
"{$language}/withdraw_h2p_success.xml",
$this -> emailParams($this -> status, $result),
$this -> getUserEMailCommon($memberCode),
VAR_CS_MAIL_ADDRESS
);
error_log(
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;
case "001":
//update withdraw
$param[] = VAL_INT_5;
$this -> accessModifyCommon('UPDATE_WITHDRAW_H2P_STATUS', $param);
$this -> accessModifyCommon('UPDATE_WITHDRAW_H2P_TEMP_STATUS', $param);
$this -> sendMailByTmp("{$language}/withdraw_h2p_fail.xml",
$this -> emailParams($this -> status, $result),
$this -> getUserEMailCommon($memberCode),
VAR_CS_MAIL_ADDRESS
);
error_log(
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;
default:
//error, status not valid
error_log(
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;
}
}else{
//error, member code not valid
error_log(
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{
//error, status not valid
error_log(
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"
);
}
}
}
}
}
$withdrawal = new H2PWithdrawalWebhook();
$withdrawal -> listen();
\ No newline at end of file
<?php
include_once $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'config.php';
class help2PayAPI {
class help2PayAPI extends System {
private $callback_url = H2P_CALLBACKURL;
private $ip = SYSTEM_IP;
private $merchant_code = H2P_MERCHANT_CODE;
private $security_code = H2P_SECURITY_CODE;
private $payoutUrl = NO_STRING;
private $ip = NO_STRING;
private $merchant_code = NO_STRING;
private $security_code = NO_STRING;
public function __construct(){
parent::__construct();
$this -> fillCredentials();
}
private function fillCredentials(){
$h2pSettings = $this -> getRowData($this -> accessSelect("SELECT_DEV_SETTING", ["help2pay_conf"]));
if($this -> isLoopData($h2pSettings)){
$h2pSettings = json_decode($this -> getColumnData($h2pSettings, "dev_setting_value"));
$this -> payoutUrl = $h2pSettings -> payout_url;
$this -> ip = $h2pSettings -> ip_address;
$this -> merchant_code = $h2pSettings -> merchant_code;
$this -> security_code = $h2pSettings -> security_code;
$this -> payoutUrl = str_replace("{merchantcode}", $this -> merchant_code, $this -> payoutUrl);
}
}
/*-------------------------------------------------------------------------
* @function_name: generateRequestData
* "@description : generates the request data
......@@ -30,7 +52,6 @@ class help2PayAPI {
'toBankAccountNumber' => $data['toBankAccountNumber'],
);
return $requestData;
}
......@@ -41,19 +62,28 @@ class help2PayAPI {
* @return : key string
-------------------------------------------------------------------------*/
public function generateKey($data){
$strKey=NO_STRING;
$transaction_id = $data['TransactionID'];
$member_code = $data['MemberCode'];
$amount = $data['Amount'];
$currency = $data['CurrencyCode'];
$transaction_date_time = $data['TransactionDateTime'];
$bank_account_number = $data['toBankAccountNumber'];
$strKey = $this -> merchant_code.$transaction_id.$member_code.$amount.$currency.$transaction_date_time.$bank_account_number.$this -> security_code;
$key = md5($strKey);
public function generateKey($data, &$rawKeyForm){
$strKey = NO_STRING;
$transaction_id = $data['TransactionID'];
$member_code = $data['MemberCode'];
$amount = $data['Amount'];
$currency = $data['CurrencyCode'];
$transaction_date_time = $data['TransactionDateTime'];
$bank_account_number = $data['toBankAccountNumber'];
$strKey = $this -> merchant_code
.$transaction_id
.$member_code
.$amount
.$currency
.$transaction_date_time
.$bank_account_number
.$this -> security_code;
$rawKeyForm = $strKey;
$key = md5($strKey);
return $key;
}
......@@ -64,13 +94,22 @@ class help2PayAPI {
* @return : array response data ; bool - false (if creation is successful, returns response data else returns false)
-------------------------------------------------------------------------*/
public function submitPayoutRequest($data){
//set curl parameters
$ch = curl_init('https://app.racethewind.net/merchantpayout/M0103'); //请求的URL地址
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$ch = curl_init($this -> payoutUrl); //请求的URL地址
curl_setopt_array($ch, [
CURLOPT_URL => $this -> payoutUrl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "utf8",
CURLOPT_POSTFIELDS => http_build_query($data),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Content-type: application/x-www-form-urlencoded"
]
]);
$responseData = curl_exec($ch);
//check if curl failed
......@@ -78,35 +117,11 @@ class help2PayAPI {
return false;
}
curl_close($ch);
//$responseData = json_decode($responseData,true);
if(count($responseData) > 0) {
return $responseData;
} else {
return false;
}
}
/*-------------------------------------------------------------------------
* @function_name: verifyCallbackKey
* "@description : Generates key for the the callback verification
* @parameter : $key, $transaction_id, $member_code, $amount, $currency, $status from db table
* @return : key string
-------------------------------------------------------------------------*/
public function verifyCallbackKey($key, $transaction_id, $member_code, $amount, $currency, $status){
$strKey=NO_STRING;
$upperKey= strtoupper($key);
$amount = number_format((float)$amount, 2, '.', '');
$strKey = $this -> merchant_code.$transaction_id.$member_code.$amount.$currency.$status.$this -> security_code;
$veriKey = md5($strKey);
return $veriKey;
}
}
<?php
include_once('../system/lib/config.php');
$system = new System();
$ReferenceID = $system -> getDataPost('Reference', true, false, false, true);
$Status = $system -> getDataPost('Status', true);
$lang = $_REQUEST['lang'];
//error_log paths
$apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api';
$responseUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P'.DIRECTORY_SEPARATOR.'deposit_response';
$responseDbUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P'.DIRECTORY_SEPARATOR.'deposit_db_response';
//check if directory exists if not, create directory
if(!file_exists($responseUrl)) {
mkdir($responseUrl, 0777, true);
}
if(!file_exists($responseDbUrl)) {
mkdir($responseDbUrl, 0777, true);
}
$sqlObject = new mysql($system->getConfigValue(SECTION_DB,HOST_NAME),$system->getConfigValue(SECTION_DB,USER_NAME),$system->getConfigValue(SECTION_DB,LOGIN_PASS),$system->getConfigValue(SECTION_DB,TARGET_DB_NAME),'','UTF8');
$system -> transactionNumber = $system -> getDataPost("Reference");
//// GET data from t_deposit
$sqlstrR = 'select * from t_deposit where transaction_number = "'.$ReferenceID.'"';
$resultR = $sqlObject -> query($sqlstrR);
$rowR = $sqlObject -> fetch_assoc($resultR);
if(count($rowR) == 0) {
//// GET data from temporary
$sqlstr = 'select * from t_deposit_help2pay_temporary where transaction_number = "'.$ReferenceID.'"';
$result = $sqlObject -> query($sqlstr);
$row = $sqlObject -> fetch_assoc($result);
if(count($row) > 0){
if($Status == "000" || $Status == "006") {
$sqlstr2 = 'select * from t_deposit where transaction_number = "'.$ReferenceID.'"';
$result2 = $sqlObject -> query($sqlstr2);
$row2 = $sqlObject -> fetch_assoc(2);
if($row2 == NULL){
$comment = "Bank:".$row['deposit_bank']
.",Merchant:".$system -> getDataPost('Merchant', true)
.",Status:".$system -> getDataPost('Status', true)
.",Currency:".$system -> getDataPost('Currency', true)
.",Amount:".$system -> getDataPost('Amount', true)
.",Datetime.".$system -> getDataPost('Datetime', true)
.",Customer:".$system -> getDataPost('Customer', true)
.",Language:".$system -> getDataPost('Language', true)
.",Reference:".$system -> getDataPost('Reference', true)
.",ID:".$system -> getDataPost('ID', true)
.",Key:".$system -> getDataPost('Key', true)
.",Note:".$system -> getDataPost('Note', true);
$HELP2PAY['Model'] = array();
$HELP2PAY['Model']['transaction_number'] = $row['transaction_number'];
$HELP2PAY['Model']['user_account'] = $row['user_account'];
$HELP2PAY['Model']['amount'] = $row['amount'];
$HELP2PAY['Model']['currency'] = $row['currency'];
$HELP2PAY['Model']['method'] = $row['method'];
$HELP2PAY['Model']['isSendMail'] = '0';
$HELP2PAY['Model']['deposit_date'] = $row['deposit_date'];
$HELP2PAY['Model']['deposit_bank'] = "Local Bank Transfer(Southeast Asia)";
$HELP2PAY['Model']['fee'] = '0';
$HELP2PAY['Model']['message'] = "Local Bank Transfer(Southeast Asia)";
$HELP2PAY['Model']['comment'] = $comment;
$HELP2PAY['Model']['create_time'] = $row['create_time'];
$HELP2PAY['Model']['process_user'] = '9999';
$HELP2PAY['Model']['old_filename'] = "";
$HELP2PAY['Model']['new_filename'] = "";
$HELP2PAY['Model']['type'] = '0';
$HELP2PAY['Model']['err_flg'] = '0';
$HELP2PAY['Model']['msecond'] = "0";
$sqlObject = new mysql($system->getConfigValue(SECTION_DB,HOST_NAME),$system->getConfigValue(SECTION_DB,USER_NAME),$system->getConfigValue(SECTION_DB,LOGIN_PASS),$system->getConfigValue(SECTION_DB,TARGET_DB_NAME),'','UTF8');
$sql = "insert into t_deposit";
//进deposit表的sql方法
$strsql = $sqlObject->Insertsql($HELP2PAY['Model']);
$sql .= $strsql;
$sqlObject->query($sql);
// EMAIL PART
$rowForUser = $system -> getRowData($system -> getAccountCommon($row['user_account']));
$params = array();
$params[] = $row['user_account'];
$params[] = $system -> getColumnData($rowForUser, 'first_name')." ".$system -> getColumnData($rowForUser, 'last_name');
$params[] = $row['transaction_number'];
$params[] = $row['create_time'];
$params[] = $row['currency'];
$params[] = $system -> getAmountString($row['amount'], $row['currency']);
$params[] = $row['currency'];
$params[] = $system -> getAmountString(($row['amount'] + $row['fee']), $row['currency']);
$params[] = $system -> getColumnData($rowForUser, 'country');
// SEND on Template
if($lang == "id") {
$language = "id";
} else {
$language = "en";
}
$system -> sendMailByTmp($language.DIRECTORY_SEPARATOR.'help2pay_deposit_info.xml'
, $params
, $system -> getColumnData($rowForUser, COLUMN_MAIL)
, VAR_CS_MAIL_ADDRESS
, $system -> getColumnData($rowForUser, 'language'));
$system -> accessModifyCommon('UPDATE_DEPOSIT_ISSENDMAIL',array($ReferenceID));
}
}
}
}
//log the transaction details
error_log(date("[Y-m-d H:i:s]")."\r\n".$ReferenceID.' -deposit_response:' ."\r\n". $Status ."\r\n", 3, $responseUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($responseUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
echo "0";
?>
<?php
// include_once $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'config.php';
// include_once $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'api'.DIRECTORY_SEPARATOR.'help2PayAPI.php';
// include_once('config.php');
include_once('../config.php');
include_once('help2PayAPI.php');
//instantiate ModelClassEx
$system = new System();
$param = array();
//instantiate api class
$help2PayAPI = new help2PayAPI();
//error_log paths
// $apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api';
$apiPath = '../api';
$successUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P_Withdrawal'.DIRECTORY_SEPARATOR.'callback'.DIRECTORY_SEPARATOR.'success';
$errorUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P_Withdrawal'.DIRECTORY_SEPARATOR.'callback'.DIRECTORY_SEPARATOR.'error';
$accessLogUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P_Withdrawal'.DIRECTORY_SEPARATOR.'callback'.DIRECTORY_SEPARATOR.'access';
//check if directory exists if not, create directory
if(!file_exists($successUrl)) {
mkdir($successUrl, 0777, true);
}
if(!file_exists($errorUrl)) {
mkdir($errorUrl, 0777, true);
}
if(!file_exists($accessLogUrl)) {
mkdir($accessLogUrl, 0777, true);
}
//log the access details
error_log(date("[Y-m-d H:i:s]")."\r\n".'Accessed' ."\r\n\r\n", 3, $accessLogUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($accessLogUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
//check post parameters
if(!empty($_POST)){
//get the POST body
$response = implode("&", $_POST);
//get transaction from database
$res = $system -> getRowData($system -> accessSelect('SELECT_WITHDRAW_H2P_TEMP', array($_POST['TransactionID'])));
if(count($res) > 0){
//get necessary details from result
$transaction_id = $system -> getColumnData($res, 'transaction_number'); //transaction number
$member_code = $system -> getColumnData($res, 'user_account'); //user account
$amount = $system -> getColumnData($res, 'amount'); //amount
$currency = $system -> getColumnData($res, 'currency'); //currency
$language = $system -> getColumnData($res, 'language'); //language
$bankCode = $system -> getColumnData($res, 'receipt_bank_name'); //language
$veriKey = $help2PayAPI -> verifyCallbackKey($_POST['Key'], $transaction_id, $member_code, $amount, $currency, $_POST['Status']);
$veriKeyUpper = strtoupper($veriKey);
if($_POST['Key'] == $veriKey || $_POST['Key'] == $veriKeyUpper) {
$param[] = $_POST['TransactionID'];
$param[] = $response.'Bank_code:'.$bankCode;
//check if state is completed
if($_POST['Status'] == '000') {
if($member_code == $_POST['MemberCode']){
//update withdraw
$param[] = VAL_INT_2;
$system->accessModifyCommon('UPDATE_WITHDRAW_H2P_STATUS', $param);
$system->accessModifyCommon('UPDATE_WITHDRAW_H2P_TEMP_STATUS', $param);
//create email parameters
$date = date('Y-m-d H:i:s');
$newdate = strtotime ( '-1 hour' , strtotime ( $date ) ) ;
$newdate = date( 'Y-m-d H:i:s' , $newdate );
$params = array();
$params[] = $member_code;
$params[] = $system -> getUserNameCommon($member_code);
$params[] = $currency;
$params[] = number_format($amount,2,'.','');
//$params[] = date_format(date_create($_POST['TransactionDatetime']), 'Y-m-d H:i:s');
$params[] = $newdate;
//send email
$system -> sendMailByTmp($language.DIRECTORY_SEPARATOR.'withdraw_h2p_success.xml'
, $params
, $system -> getUserEMailCommon($member_code)
, VAR_CS_MAIL_ADDRESS);
//log details
error_log(date("[Y-m-d H:i:s]")."\r\n".'success status:' ."\r\n\r\n".$response."\r\n\r\n", 3, $successUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($successUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
}else{
//error, member code not valid
error_log(date("[Y-m-d H:i:s]")."\r\n".'Error member code invalid:' ."\r\n\r\n".$response."\r\n\r\n".$member_code."\r\n\r\n", 3, $errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
}
}else if($_POST['Status'] == '001'){
//send email
if($member_code == $_POST['MemberCode']){
//update withdraw
$param[] = VAL_INT_5;
$system->accessModifyCommon('UPDATE_WITHDRAW_H2P_STATUS', $param);
$system->accessModifyCommon('UPDATE_WITHDRAW_H2P_TEMP_STATUS', $param);
//create email parameters
$params = array();
$params[] = $member_code;
$params[] = $system -> getUserNameCommon($member_code);
//send email
$system -> sendMailByTmp($language.DIRECTORY_SEPARATOR.'withdraw_h2p_fail.xml'
, $params
, $system -> getUserEMailCommon($member_code)
, VAR_CS_MAIL_ADDRESS);
//log details
error_log(date("[Y-m-d H:i:s]")."\r\n".'fail status:' ."\r\n\r\n".$response."\r\n\r\n", 3, $successUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($successUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
}else{
//error, member code not valid
error_log(date("[Y-m-d H:i:s]")."\r\n".'Error member code invalid:' ."\r\n\r\n".$response."\r\n\r\n".$member_code."\r\n\r\n", 3, $errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
}
}else{
//error, status not valid
error_log(date("[Y-m-d H:i:s]")."\r\n".'Error status code invalid:' ."\r\n\r\n".$response."\r\n\r\n".$_POST['Status']."\r\n\r\n", 3, $errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
}
}else{
//error, status not valid
error_log(date("[Y-m-d H:i:s]")."\r\n".'Key invalid:' ."\r\n\r\n".$response."\r\n\r\n", 3, $errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
}
}
}
<?php
// include_once $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'config.php';
// include_once $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'api'.DIRECTORY_SEPARATOR.'help2PayAPI.php';
// include_once('config.php');
include_once('../config.php');
include_once('help2PayAPI.php');
//instantiate ModelClassEx
$system = new System();
//instantiate api class
$help2PayAPI = new help2PayAPI();
//error_log paths
// $apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api';
$apiPath = '../api';
$accessLogUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P_Withdrawal'.DIRECTORY_SEPARATOR.'verification'.DIRECTORY_SEPARATOR.'access';
$errorUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P_Withdrawal'.DIRECTORY_SEPARATOR.'verification'.DIRECTORY_SEPARATOR.'error';
$verifyUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P_Withdrawal'.DIRECTORY_SEPARATOR.'verification'.DIRECTORY_SEPARATOR.'verify';
//check if directory exists if not, create directory
if(!file_exists($accessLogUrl)) {
mkdir($accessLogUrl, 0777, true);
}
if(!file_exists($errorUrl)) {
mkdir($errorUrl, 0777, true);
}
if(!file_exists($verifyUrl)) {
mkdir($verifyUrl, 0777, true);
}
//log the error details
error_log(date("[Y-m-d H:i:s]")."\r\n".'Accessed' ."\r\n\r\n", 3, $accessLogUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($accessLogUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
//check get parameters
if(!empty($_GET)){
//get response parameters
$uri_response = $_SERVER['REQUEST_URI'];
$responseArray = explode("?", $uri_response);
$response = $responseArray[1];
if(isset($_REQUEST['transId']) && isset($_REQUEST['key'])){
//get transaction from database
$res = $system -> getRowData($system -> accessSelect('SELECT_WITHDRAW_H2P_TEMP', array($_REQUEST['transId'])));
if(count($res) > 0){
//get necessary details from result
$key = $system -> getColumnData($res, 'api_key'); //transaction number
$key = strtoupper($key);
if($key==$_REQUEST['key']){
error_log(date("[Y-m-d H:i:s]")."\r\n".'VERIFY:' ."\r\n"."\r\nTRUE ".$_REQUEST['transId']." ".$_REQUEST['key']."\r\n\r\n", 3, $verifyUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($verifyUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
echo "true";
}else{
error_log(date("[Y-m-d H:i:s]")."\r\n".'ERROR:' ."\r\n"."\r\nFALSE: Key not verified ".$_REQUEST['transId']." ".$_REQUEST['key']." vs ".$key."\r\n\r\n", 3, $verifyUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
echo "false";
}
}else{
//false
error_log(date("[Y-m-d H:i:s]")."\r\n".'ERROR:' ."\r\n"."\r\nFALSE: Not on database ".$_REQUEST['transId']." ".$_REQUEST['key']."\r\n\r\n", 3, $verifyUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
echo "false";
}
}else{
//log the error
error_log(date("[Y-m-d H:i:s]")."\r\n".'ERROR:' ."\r\n"."\r\nresponse:\r\n". $response ."\r\n", 3, $errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -67,7 +67,6 @@ class WithdrawModelClass extends ModelClassEx {
// チェック
$this -> validate();
} catch (Exception $e) {
throw $e;
}
......@@ -2141,26 +2140,25 @@ class WithdrawModelClass extends ModelClassEx {
}
public function getOutStatus()
{
$account = $this->getUserData(PARAM_USER_ACCOUNT);
$rs = $this -> getAccountCommon($account);
$row = $this -> getRowData($rs);
$accountType = $this -> getColumnData($row, COLUMN_ACCOUNT_TYPE);
$rtn = array();
$array_list_IBT = array(
'81691034',//Restine
'42156169'// New iWallet 会計用 Corporate
);
if(in_array($this->getUserData(PARAM_USER_ACCOUNT), $array_list_IBT)){
$method = getOutMoney();
} else {
$method = getOouMoney();
}
$rs = $this -> getAccountCommon($account);
$row = $this -> getRowData($rs);
$accountType = $this -> getColumnData($row, COLUMN_ACCOUNT_TYPE);
$rtn = array();
$array_list_IBT = array(
'81691034',//Restine
'42156169'// New iWallet 会計用 Corporate
);
if(in_array($this->getUserData(PARAM_USER_ACCOUNT), $array_list_IBT)){
$method = getOutMoney();
} else {
$method = getOouMoney();
}
$lang = $this -> getLangage();
foreach ($method as $key => $value) {
$solution = ($value[1] == 'Flat3') ? PARAM_WITHDRAW_FLAT3_METHOD : (($value[1] == 'SDPay') ? PARAM_WITHDRAW_LBTC_METHOD : (($value[1] == 'H2P') ? PARAM_WITHDRAW_H2P_METHOD : PARAM_WITHDRAW_IBT_METHOD));
......@@ -2686,91 +2684,102 @@ class WithdrawModelClass extends ModelClassEx {
public function sendH2PRequest(){
$language = $this -> getLangage();
//prep log path
$apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api';
$errorUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P_Withdrawal'.DIRECTORY_SEPARATOR.'sending_request'.DIRECTORY_SEPARATOR.'error';
$requestUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P_Withdrawal'.DIRECTORY_SEPARATOR.'sending_request'.DIRECTORY_SEPARATOR.'request';
//require api file
include $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'api'.DIRECTORY_SEPARATOR.'help2PayAPI.php';
//instantiate api class
$help2PayAPI = new help2PayAPI();
//start request
$data = array(
'TransactionID' => $this -> transactionId,
'CurrencyCode' => $this -> currency,
'MemberCode' => $this -> getUserData(PARAM_USER_ACCOUNT),
'Amount' => number_format((float)$this -> amount, 2, '.', ''),
'TransactionDateTime' => date('YmdHis'),
'TransactionDateTime2' => date('Y-m-d h:i:sA'),
'BankCode' => $this -> receiptBankName,
'toBankAccountName' => $this -> accountName,
'toBankAccountNumber' => $this -> accountNumber,
);
//generate key
$key = $help2PayAPI -> generateKey($data);
//save key to db
$param = array();
$param[] = $this -> transactionId;
$param[] = $key;
$param[] = $language;
$param[] = $this -> receiptBankName;
$this->accessModify('UPDATE_WITHDRAW_H2P_KEY', $param);
//send request
$requestData = $help2PayAPI -> generateRequestData($data, $key); //generate request data
$requestDataLog = implode(" ", $requestData); //generate request data log
$res = $help2PayAPI -> submitPayoutRequest($requestData); //create channel
//check if create request is successful
if($res != NULL) {
$xml = new SimpleXMLElement($res);
$statusCode = $xml->statusCode;
$message = $xml->message;
$date = date('Y-m-d H:i:s'); //created date
if($statusCode == 000) {
if(!file_exists($requestUrl)) {
mkdir($requestUrl, 0777, true);
}
error_log(date("[Y-m-d H:i:s]")."\r\n".'REQUEST:' ."\r\n"."\r\n". $requestDataLog ."\r\n\r\n\r\n\r\n", 3, $requestUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($requestUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
return true;
}elseif($statusCode == 001){
if(!file_exists($errorUrl)) {
mkdir($errorUrl, 0777, true);
}
error_log(date("[Y-m-d H:i:s]")."\r\n".'ERROR:' .$this -> transactionId."\r\n"."\r\nMessage:\r\n". $message ."\r\n\r\n\r\n\r\n", 3, $errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
return false;
}else{
//logerror of invalid statuscode
if(!file_exists($errorUrl)) {
mkdir($errorUrl, 0777, true);
}
error_log(date("[Y-m-d H:i:s]")."\r\n".'Invalid Status Code ERROR' .$this -> transactionId."\r\n", 3, $errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
return false;
}
} else { //create request failed
$this -> popUpSessionMessage(ERROR, 'E_ERROR_H2P_API_NULL', array());
$this -> setType(TYPE_WITHDRAW_H2P_INPUT);
return;
}
$language = $this -> getLangage();
//prep log path
$apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api';
$errorUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P_Withdrawal'.DIRECTORY_SEPARATOR.'sending_request'.DIRECTORY_SEPARATOR.'error';
$requestUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P_Withdrawal'.DIRECTORY_SEPARATOR.'sending_request'.DIRECTORY_SEPARATOR.'request';
//require api file
include $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'api'.DIRECTORY_SEPARATOR.'help2PayAPI.php';
//instantiate api class
$help2PayAPI = new help2PayAPI();
//start request
$data = array(
'TransactionID' => $this -> transactionId,
'CurrencyCode' => $this -> currency,
'MemberCode' => $this -> getUserData(PARAM_USER_ACCOUNT),
'Amount' => number_format((float)$this -> amount, 2, '.', ''),
'TransactionDateTime' => date('YmdHis'),
'TransactionDateTime2' => date('Y-m-d h:i:sA'),
'BankCode' => $this -> receiptBankName,
'toBankAccountName' => $this -> accountName,
'toBankAccountNumber' => $this -> accountNumber,
);
$raw = NO_STRING;
//generate key
$key = $help2PayAPI -> generateKey($data, $raw);
//save key to db
$param = array();
$param[] = $this -> transactionId;
$param[] = $key;
$param[] = $language;
$param[] = $this -> receiptBankName;
$this -> accessModify('UPDATE_WITHDRAW_H2P_KEY', $param);
//send request
$requestData = $help2PayAPI -> generateRequestData($data, $key); //generate request data
$requestDataLog = implode(" ", $requestData); //generate request data log
$res = $help2PayAPI -> submitPayoutRequest($requestData); //create channel
//check if create request is successful
if($res != NULL) {
$xml = new SimpleXMLElement($res);
$statusCode = $xml->statusCode;
$message = $xml->message;
$date = date('Y-m-d H:i:s'); //created date
if($statusCode == 000) {
if(!file_exists($requestUrl)) {
mkdir($requestUrl, 0777, true);
}
error_log("[{$date}]\r\nREQUEST:\r\n\r\n{$requestDataLog}\r\n\r\n\r\n\r\n",
VAL_INT_3,
$requestUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($requestUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log', 511);
return true;
}elseif($statusCode == 001){
if(!file_exists($errorUrl)) {
mkdir($errorUrl, 0777, true);
}
error_log("\n\n".print_r($requestData, true)."\n\n".print_r($res, true)."\n\n{$raw}\n\n{$key}",
VAL_INT_3,
$errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
error_log("[{$date}]\r\nERROR:{$this -> transactionId}\r\n\r\nMessage:\r\n{$message}\r\n\r\n\r\n\r\n",
VAL_INT_3,
$errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log', 511);
return false;
}else{
//logerror of invalid statuscode
if(!file_exists($errorUrl)) {
mkdir($errorUrl, 0777, true);
}
error_log("[{$date}]\r\nInvalid Status Code ERROR{$this -> transactionId}\r\n",
VAL_INT_3,
$errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
return false;
}
} else { //create request failed
$this -> popUpSessionMessage(ERROR, 'E_ERROR_H2P_API_NULL', array());
$this -> setType(TYPE_WITHDRAW_H2P_INPUT);
return;
}
}
}
......@@ -371,10 +371,19 @@ define('TYPE_H2P_STATUS', 'h2p_status');
define('TYPE_H2P_FAIL', 'h2p_fail');
define('TYPE_H2P_PENDING', 'h2p_pending');
define('TYPE_H2P_NOTICE_KYC', 'h2p_notice_kyc');
define('HELP2PAY_URL','https://api.racethewind.net/MerchantTransfer');
define('HELP2PAY_CUSTOMERMERCHANT','M0103');
define('HELP2PAY_SECURITYCODE','FJCfJRGRZDXSX7j');
define('HELP2PAY_CALLBACKURL', 'https://secure.'.SITE_DOMAIN.'/api/help2pay_webhook.php');
define('HELP2PAY_CALLBACKURL', SITE_PROTOCOL.'://'.SITE_DOMAIN_FULL.'/api/H2PDepositWebhook.php');
//Help2Pay withdrawal type constants start
define('TYPE_WITHDRAW_H2P_INPUT', 'withdraw_h2p_input');
define('TYPE_WITHDRAW_H2P_CONFIRM', 'withdraw_h2p_confirm');
define('TYPE_WITHDRAW_H2P_COMPLETE', 'withdraw_h2p_complete');
define('TYPE_WITHDRAW_H2P_SUCCESS', 'withdraw_h2p_success');
define('TYPE_WITHDRAW_H2P_FAIL', 'withdraw_h2p_fail');
define('TYPE_WITHDRAW_H2P_BACK', 'withdraw_h2p_back');
define('TYPE_WITHDRAW_H2P_LOCKED', 'withdraw_h2p_locked');
//Help2Pay withdrawal type constants end
define('H2P_CALLBACKURL', SITE_PROTOCOL.'://'.SITE_DOMAIN_FULL.'/api/H2PWithdrawalWebhook.php');
//admin user
define('TYPE_ADMIN_USER_SEARCH_ALL', 'admin_user_search_all');
......@@ -395,21 +404,6 @@ define('TYPE_EXPORT_ADMIN_FAIL_LIST', 'export_admin_fail_list');
define('VAL_STR_BIT_FEE_VAL','3.50');
//Help2Pay withdrawal type constants start
define('TYPE_WITHDRAW_H2P_INPUT', 'withdraw_h2p_input');
define('TYPE_WITHDRAW_H2P_CONFIRM', 'withdraw_h2p_confirm');
define('TYPE_WITHDRAW_H2P_COMPLETE', 'withdraw_h2p_complete');
define('TYPE_WITHDRAW_H2P_SUCCESS', 'withdraw_h2p_success');
define('TYPE_WITHDRAW_H2P_FAIL', 'withdraw_h2p_fail');
define('TYPE_WITHDRAW_H2P_BACK', 'withdraw_h2p_back');
define('TYPE_WITHDRAW_H2P_LOCKED', 'withdraw_h2p_locked');
//Help2Pay withdrawal type constants end
define('H2P_MERCHANT_CODE','M0103');
define('H2P_SECURITY_CODE','FJCfJRGRZDXSX7j');
define('H2P_CALLBACKURL', 'https://secure.'.SITE_DOMAIN.'/api/payoutH2PCallback.php');
define('SYSTEM_IP', '52.74.25.29');
//NEW SD API
define('SD_MERCHANT_CODE', 'M1000100');
define('SD_PUBLIC_KEY', '-----BEGIN PUBLIC KEY-----
......
......@@ -11721,7 +11721,7 @@ WHERE
)
</INSERT_TEMP_CCDEPOSIT>
<INSERT_CC_DEPOSIT_TRANSACTION>
<INSERT_WB_DEPOSIT_TRANSACTION>
INSERT into t_deposit (
transaction_number,
user_account,
......@@ -11737,21 +11737,21 @@ WHERE
err_flg,
message
) values (
__ELEMENT01__,
__ELEMENT02__,
__ELEMENT03__,
__ELEMENT04__,
__ELEMENT05__,
__ELEMENT06__,
__ELEMENT07__,
__ELEMENT08__,
__ELEMENT09__,
__ELEMENT10__,
__ELEMENT11__,
__ELEMENT12__,
__ELEMENT13__
'__ELEMENT01__',
'__ELEMENT02__',
'__ELEMENT03__',
'__ELEMENT04__',
'__ELEMENT05__',
'__ELEMENT06__',
'__ELEMENT07__',
'__ELEMENT08__',
'__ELEMENT09__',
'__ELEMENT10__',
'__ELEMENT11__',
'__ELEMENT12__',
'__ELEMENT13__'
)
</INSERT_CC_DEPOSIT_TRANSACTION>
</INSERT_WB_DEPOSIT_TRANSACTION>
<UPDATE_TEMP_CCDEPOSIT>
UPDATE t_deposit_credit_card_temporary
......@@ -13433,6 +13433,56 @@ WHERE
transaction_time
</LIST_USER_TRANSACTION_FOR_SUSPENSION_CHECKING>
<SELECT_DEPOSIT_H2P_TEMP>
SELECT
*
FROM
t_deposit_help2pay_temporary
WHERE
transaction_number = '__ELEMENT01__'
</SELECT_DEPOSIT_H2P_TEMP>
<INSERT_DEPOSIT_H2P_TEMP>
INSERT INTO t_deposit_help2pay_temporary
(
transaction_number,
user_account,
amount,
adjusted_amount,
currency,
method,
deposit_date,
deposit_bank,
fee,
message,
comment,
create_time,
process_user,
type,
err_flg,
status
)
values
(
'__ELEMENT01__',
'__ELEMENT02__',
'__ELEMENT03__',
'__ELEMENT04__',
'__ELEMENT05__',
'__ELEMENT06__',
'__ELEMENT07__',
'__ELEMENT08__',
'__ELEMENT09__',
'__ELEMENT10__',
'__ELEMENT11__',
'__ELEMENT12__',
'__ELEMENT13__',
'__ELEMENT14__',
'__ELEMENT15__',
'__ELEMENT16__'
)
</INSERT_DEPOSIT_H2P_TEMP>
<SELECT_WITHDRAW_H2P_TEMP>
SELECT
*
......
<?php
include_once '../../system/lib/config.php';
class TestDepositStatus extends System {
/**
*
* @var string
*/
private $referer = NO_STRING;
/**
*
* @var string
*/
private $reference = NO_STRING;
/**
*
* @var string
*/
private $status = NO_STRING;
/**
*
* @var string
*/
private $amount = NO_STRING;
/**
*
* @var string
*/
private $currency = NO_STRING;
/**
*
* @var string
*/
private $fee = NO_STRING;
/**
*
* @var string
*/
private $createTime = NO_STRING;
/**
*
* @var string
*/
private $userAccount = NO_STRING;
public function __construct(){
parent::__construct();
$this -> setParameter();
$this -> validation();
}
private function setParameter(){
$this -> referer = $this -> getColumnData($_SERVER, "HTTP_REFERER");
$this -> reference = $this -> getDataPost("Reference");
$this -> status = $this -> getDataPost("Status");
$this -> userAccount = $this -> getDataPost("Customer");
}
private function validation(){
$validationRemarks = [];
if($this -> status == NO_STRING){
$validationRemarks[] = json_encode([
"code" => "01",
"message" => "No status code found"
]);
}
if($this -> userAccount != NO_STRING){
$account = $this -> getRowData($this -> getAccountCommon($this -> userAccount));
if(!$this -> getColumnData($account, COLUMN_TEST_ACCOUNT_FLG)){
$validationRemarks[] = json_encode([
"code" => "02",
"message" => "User Account ({$this -> customer}) must be under tester category"
]);
}
}
if($this -> isLoopData($validationRemarks)){
echo "<pre>";
die(print_r($validationRemarks, true));
}
}
public function listen(){
switch($this -> status){
case "000":
case "006":{
$tempRow = $this -> accessSelect("SELECT_DEPOSIT_H2P_TEMP", [$this -> getDataPost("Reference")]);
if($this -> isLoopData($tempRow)){
$tempRow = $this -> getRowData($tempRow);
if(strcmp($this -> getColumnData($tempRow, COLUMN_USER_ACCOUNT), $this -> userAccount) !== 0){
die("Ownership was falsified!");
}
$processedTransaction = $this -> accessSelect("SELECT_DEPOSIT_BY_TRANSACTION_NUMBER", [$this -> getDataPost("Reference")]);
if(!$this -> isLoopData($processedTransaction)){
$comment = "Bank:".$this -> getColumnData($tempRow, 'deposit_bank')
.",Merchant:{$this -> getDataPost('Merchant')}"
.",Status:{$this -> getDataPost('Status')}"
.",Currency:{$this -> getDataPost('Currency')}"
.",Amount:{$this -> getDataPost('Amount')}"
.",Datetime:{$this -> getDataPost('Datetime')}"
.",Customer:{$this -> getDataPost('Customer')}"
.",Language:{$this -> getDataPost('Language')}"
.",Reference:{$this -> getDataPost('Reference')}"
.",ID:{$this -> getDataPost('ID')}"
.",Key:{$this -> getDataPost('Key')}"
.",Note:{$this -> getDataPost('Note')}";
$toInsert = [
$this -> getColumnData($tempRow, COLUMN_TRANSACTION_NUMBER),
$this -> getColumnData($tempRow, COLUMN_USER_ACCOUNT),
$this -> getColumnData($tempRow, COLUMN_AMOUNT),
$this -> getColumnData($tempRow, COLUMN_CURRENCY),
$this -> getColumnData($tempRow, COLUMN_METHOD),
"Local Bank Transfer(Southeast Asia)",
$this -> getColumnData($tempRow, COLUMN_DEPOSIT_DATE),
$this -> getColumnData($tempRow, COLUMN_FEE),
$comment,
$this -> getColumnData($tempRow, COLUMN_CREATE_TIME),
NO_COUNT,
NO_COUNT,
"Local Bank Transfer(Southeast Asia)"
];
$this -> accessModify("INSERT_WB_DEPOSIT_TRANSACTION", $toInsert, false);
$processedTransaction = $this -> accessSelect("SELECT_DEPOSIT_BY_TRANSACTION_NUMBER", [$this -> getDataPost("Reference")]);
}
$this -> fee = $this -> intToCurrency(
round(bcmul($this -> getColumnData($tempRow, COLUMN_AMOUNT),
VAL_STR_H2P_FEE, VAL_INT_4)), PERCENT);
$this -> createTime = $this -> getColumnData($tempRow, COLUMN_CREATE_TIME);
$this -> amount = $this -> getColumnData($tempRow, COLUMN_AMOUNT);
$this -> currency = $this -> getColumnData($tempRow, COLUMN_CURRENCY);
$this -> sendHelp2PaySuccessMail();
include_once "template/deposit_success.php";
}
break;
}
case "009":
echo "Pending Transaction";
break;
default:
$this -> sendHelp2PayFailMail();
include_once "template/deposit_failed.php";
break;
}
}
private function getSendHelp2PaySuccessData() {
// 変数宣言部
$rtn = array();
// パラメータの設定
$rtn[] = $this -> userAccount; // 口座番号(1)
$rtn[] = $this -> getNameCommon($this -> userAccount); // 氏名(2)
$rtn[] = $this -> reference; // 取引番号(3)
$rtn[] = $this -> createTime; // 取引時刻(4)
$rtn[] = $this -> currency; // 決済通貨(5)
$rtn[] = $this -> getAmountString($this -> amount, $this -> currency); // 決済金額(6)
$rtn[] = $this -> currency; // 反映通貨(7)
$rtn[] = $this -> getAmountString(($this -> amount + $this -> fee), $this -> currency); // 反映金額(8)
$rtn[] = "NOC"; // Not-A-Country
return $rtn;
}
private function sendHelp2PaySuccessMail(){
$params = '';
// 変数宣言部
$params = $this -> getSendHelp2PaySuccessData();
// メールを送信(ユーザ)
$this -> sendMailByTmp('en/help2pay_deposit_info.xml'
, $params
, $this -> getEMailCommon($this -> getColumnData($params, NO_COUNT))
, VAR_CS_MAIL_ADDRESS
, $this -> getLangage());
}
private function getSendHelp2PayFailData() {
$this -> userAccount = $this -> getDataPost("Customer");
// 変数宣言部
$rtn = array();
$rtn[] = $this -> userAccount; // 口座番号
$rtn[] = $this -> getNameCommon($this -> userAccount); // 氏名
return $rtn;
}
private function sendHelp2PayFailMail(){
// 変数宣言部
$params = $this -> getSendHelp2PayFailData();
// メールを送信(ユーザ)
$this -> sendMailByTmp('en/help2pay_deposit_info_fail.xml'
, $params
, $this -> getEMailCommon($this -> getColumnData($params, NO_COUNT))
, VAR_CS_MAIL_ADDRESS
, $this -> getLangage());
}
public function getv($varname){
if(isset($this -> $varname))
return $this -> $varname;
else
return NO_STRING;
}
}
$depositStatus = new TestDepositStatus();
$depositStatus -> listen();
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title>H2P Deposit Failed</title>
</head>
<body>
<h4><code>Failed to credit Deposit Transaction</code></h4>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="ja">
<head>
<title>H2P Deposit Form</title>
</head>
<body>
<form action="<?=$this -> getv("transferURL")?>" method="POST">
<h4>Ready to redirection.</h4>
<table>
<tr>
<td>Merchant Code</td>
<td><?=$this -> getv("merchantCode")?></td>
</tr>
<tr>
<td>Currency</td>
<td><?=$this -> getv("currency")?></td>
</tr>
<tr>
<td>Customer</td>
<td><?=$this -> getv("customer")?></td>
</tr>
<tr>
<td>Reference</td>
<td><?=$this -> getv("reference")?></td>
</tr>
<tr>
<td>Raw Key</td>
<td><?=$this -> getv("rawKey")?></td>
</tr>
<tr>
<td>Transaction Key</td>
<td><?=$this -> getv("transKey")?></td>
</tr>
<tr>
<td>Deposit Amount</td>
<td><?=$this -> getv("amount")?></td>
</tr>
<tr>
<td>Customer Amount</td>
<td><?=sprintf("%.2f", $this -> getv("formattedAmount"))?></td>
</tr>
<tr>
<td>Note</td>
<td><?=$this -> getv("note")?></td>
</tr>
<tr>
<td>Customer DateTime</td>
<td><?=$this -> getv("transDateTime")?></td>
</tr>
<tr>
<td>Bank</td>
<td><?=$this -> getv("bank")?></td>
</tr>
<tr>
<td>Front URI</td>
<td><?=$this -> getv("frontURI")?></td>
</tr>
<tr>
<td>Back URI</td>
<td><?=$this -> getv("backURI")?></td>
</tr>
</table>
<input type="hidden" name="Merchant" value="<?=$this -> getv("merchantCode")?>">
<input type="hidden" name="Currency" value="<?=$this -> getv("currency")?>">
<input type="hidden" name="Customer" value="<?=$this -> getv("customer")?>">
<input type="hidden" name="Reference" value="<?=$this -> getv("reference")?>">
<input type="hidden" name="Key" value="<?=$this -> getv("transKey")?>">
<input type="hidden" name="Amount" value="<?=$this -> getv("formattedAmount")?>">
<input type="hidden" name="Note" value="<?=$this -> getv("note")?>">
<input type="hidden" name="Datetime" value="<?=$this -> getv("transDateTime")?>">
<input type="hidden" name="FrontURI" value="<?=$this -> getv("frontURI")?>">
<input type="hidden" name="BackURI" value="<?=$this -> getv("backURI")?>">
<input type="hidden" name="language" value="en-us">
<input type="hidden" name="bank" value="<?=$this -> getv("bank")?>">
<input type="hidden" name="ClientIP" value="<?=$this -> getv("ipAddress")?>">
<input type="submit" value="Proceed">
</form>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="ja">
<head>
<title>Deposit Successful</title>
</head>
<body>
<h4>Deposit Successfully done.</h4>
<table>
<tr>
<td>Referer</td>
<td><?=$this -> getv("referer")?></td>
</tr>
<tr>
<td>User Account</td>
<td><?=$this -> getv("userAccount")?></td>
</tr>
<tr>
<td>Reference</td>
<td><?=$this -> getv("reference")?></td>
</tr>
<tr>
<td>Debit Amount</td>
<td><?=$this -> getv("currency")?> <?=$this -> getDataPost("Amount")?></td>
</tr>
<tr>
<td>Credit Amount</td>
<td><?=$this -> getv("currency")?> <?=$this -> getv("amount")?></td>
</tr>
</table>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
<?php
include_once '../../system/lib/config.php';
class TestDeposit extends System {
/**
*
* @var string
*/
private $customer = NO_STRING;
/**
*
* @var string
*/
private $currency = NO_STRING;
/**
*
* @var string
*/
private $reference = NO_STRING;
/**
*
* @var string
*/
private $amount = NO_STRING;
/**
*
* @var string
*/
private $securityCode = NO_STRING;
/**
*
* @var string
*/
private $ipAddress = NO_STRING;
/**
*
* @var string
*/
private $bank = NO_STRING;
/**
*
* @var string
*/
private $transferURL = NO_STRING;
/**
*
* @var string
*/
private $merchantCode = NO_STRING;
/**
*
* @var string
*/
private $rawKey = NO_STRING;
/**
*
* @var string
*/
private $transKey = NO_STRING;
/**
*
* @var string
*/
private $note = NO_STRING;
/**
*
* @var double
*/
private $fee = NO_COUNT;
/**
*
* @var string
*/
private $formattedAmount = NO_COUNT;
/**
*
* @var boolean
*/
private $usingPotMethod = false;
/**
*
* @var string
*/
private $transDateTime = NO_STRING;
/**
*
* @var string
*/
private $frontURI = NO_STRING;
/**
*
* @var string
*/
private $backURI = NO_STRING;
public function __construct(){
parent::__construct();
$this -> setParameter();
$this -> validation();
}
private function setParameter(){
$h2pSettings = $this -> getRowData($this -> accessSelect("SELECT_DEV_SETTING", ["help2pay_conf"]));
if($this -> isLoopData($h2pSettings)){
$h2pSettings = json_decode($this -> getColumnData($h2pSettings, "dev_setting_value"));
$this -> merchantCode = $h2pSettings -> merchant_code;
$this -> transferURL = $h2pSettings -> transfer_url;
$this -> ipAddress = $_SERVER["REMOTE_ADDR"];
$this -> securityCode = $h2pSettings -> security_code;
}
$this -> customer = $this -> getDataPost("customer");
$this -> currency = $this -> getDataPost("currency");
$this -> amount = $this -> getDataPost("amount");
$this -> bank = $this -> getDataPost("bank");
$this -> note = $this -> getDataPost("note");
$this -> frontURI = SITE_PROTOCOL."://".SITE_DOMAIN_FULL."/test/help2pay/deposit_status.php";
$this -> backURI = SITE_PROTOCOL."://".SITE_DOMAIN_FULL."/api/H2PDepositWebhook.php";
}
private function validation(){
$validationRemarks = [];
if(strcasecmp($this -> getColumnData($_SERVER, "REQUEST_METHOD"), "POST") !== 0){
$validationRemarks[] = json_encode([
"code" => "01",
"message" => "Invalid Request Method ({$_SERVER["REQUEST_METHOD"]})"
]);
}else{
$this -> usingPotMethod = true;
}
$account = $this -> getRowData($this -> getAccountCommon($this -> customer));
if($this -> isLoopData($account)){
if(!$this -> getColumnData($account, COLUMN_TEST_ACCOUNT_FLG)){
$validationRemarks[] = json_encode([
"code" => "02",
"message" => "User Account ({$this -> customer}) must be under tester category"
]);
}
}else{
$validationRemarks[] = json_encode([
"code" => "03",
"message" => "Invalid User Account ({$this -> customer})"
]);
}
if($this -> isLoopData($validationRemarks)){
echo "<pre>";
die(print_r($validationRemarks, true));
}
$this -> reference = $this -> getTransactionNumberCommon(VAR_TRANSACTION_DEPOSIT);
}
private function buildData(){
date_default_timezone_set('Asia/Manila');
$this -> transDateTime = date("Y-m-d h:i:s A");
$this -> fee = $this -> intToCurrency(round(bcmul($this -> amount, VAL_STR_H2P_FEE, VAL_INT_4)), PERCENT);
$this -> formattedAmount = str_replace(
",",
NO_STRING,
$this -> formatCurrency(($this -> amount + $this -> fee), $this -> currency)
);
$militaryTime = date("YmdHis", strtotime($this -> transDateTime));
$this -> rawKey = $this -> merchantCode
.$this -> reference
.$this -> customer
.sprintf("%.2f", $this -> formattedAmount)
.$this -> currency
.$militaryTime
.$this -> securityCode
.$this -> ipAddress;
$this -> transKey = md5($this -> rawKey);
}
private function storeTemporaryDepositData(){
$this -> accessModify("INSERT_DEPOSIT_H2P_TEMP", [
$this -> reference,
$this -> customer,
$this -> amount,
$this -> formattedAmount,
$this -> currency,
VAL_STR_H2P_METHOD,
date("Y-m-d H:i:s"),
$this -> bank,
str_replace(",", NO_STRING, $this -> formatCurrency($this -> fee, $this -> currency)),
"Local Bank Transfer (Southeast Asia)",
"via IWL Tester Edge",
date("Y-m-d H:i:s"),
'9999',
NO_COUNT,
NO_COUNT,
NO_COUNT
]);
}
public function getv($varname){
if(isset($this -> $varname))
return $this -> $varname;
else
return NO_STRING;
}
public function display(){
if($this -> usingPotMethod){
$this -> buildData();
$this -> storeTemporaryDepositData();
}
include_once "template/deposit_form.php";
}
}
$deposit = new TestDeposit();
$deposit -> display();
\ No newline at end of file
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