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

Help2Pay Migration [Initial Commit]

parent dbe1382b
......@@ -79,22 +79,18 @@ 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
......@@ -30,7 +52,6 @@ class help2PayAPI {
'toBankAccountNumber' => $data['toBankAccountNumber'],
);
return $requestData;
}
......@@ -41,8 +62,8 @@ class help2PayAPI {
* @return : key string
-------------------------------------------------------------------------*/
public function generateKey($data){
$strKey=NO_STRING;
public function generateKey($data, &$rawKeyForm){
$strKey = NO_STRING;
$transaction_id = $data['TransactionID'];
$member_code = $data['MemberCode'];
......@@ -51,7 +72,16 @@ class help2PayAPI {
$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;
$strKey = $this -> merchant_code
.$transaction_id
.$member_code
.$amount
.$currency
.$transaction_date_time
.$bank_account_number
.$this -> security_code;
$rawKeyForm = $strKey;
$key = md5($strKey);
......@@ -64,12 +94,21 @@ 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);
......@@ -79,34 +118,10 @@ class help2PayAPI {
}
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);
}
}
......@@ -6,13 +6,13 @@ include_once('template/base_head.php');
<!-- サイドバー -->
<aside id="colLeft">
<h1><a href="/en/menu"><img src="../img/logo.png" alt="<?php echo SITE_NAME; ?>"></a></h1>
<?php include_once('template/base_sidebar.php'); ?>
<?php include_once('template/base_sidebar.php'); ?>
</aside>
<!-- /サイドバー -->
<!-- メインカラム -->
<div id="colMain">
<div class="mainIn">
<?php include_once('template/base_nav.php'); ?>
<?php include_once('template/base_nav.php'); ?>
<article>
<div class="article-heading">
<h2><?php echo $page_title; ?></h2>
......@@ -26,7 +26,11 @@ include_once('template/base_head.php');
<table class="table col bdr default odd fontM summaryT">
<tr>
<th width="30%">Country</th>
<td ><div id="country" name="country" class="country"><?php echo $this -> echoCountryNameH2P(); ?></div></td>
<td>
<div id="country" class="country">
<?php echo $this -> echoCountryNameH2P(); ?>
</div>
</td>
</tr>
<tr><th>Currency</th>
<td><?php $this -> dispH2PCurrency(); ?></td>
......@@ -42,20 +46,17 @@ include_once('template/base_head.php');
<input type="text" value="" placeholder="" id="depositmoney" name="depositmoney" onblur="setAmount();">
</div><div class="tips"><div class="Validform_checktip"></div></div>
</div>
</td>
</tr>
<tr>
<th>Remitting Bank</th>
<td>
<select name="bank" id="bank_name">
<option disabled="" selected="">Please select a bank</option>
<option>Please select a bank</option>
<?php $this -> displayLocalBankListPerCurrency(); ?>
</select>
</td>
</tr>
</table>
<br>
<strong class="redtext">Note:</strong>
......@@ -95,7 +96,7 @@ include_once('template/base_head.php');
</div>
<!-- /メインカラム -->
</div>
<?php include_once('template/base_foot.php'); ?>
<?php include_once('template/base_foot.php'); ?>
</div>
<script src="../js/ui-choose-bind.js"></script>
<script src="../js/deposit.js" type="text/javascript"></script>
......
......@@ -18,8 +18,17 @@ class DepositModelClass extends ModelClassEx {
private $file = null; //uploaded image
// 別の入金Solutionの変数
private $validCalculation; // CCD
private $token; // CCD
private $validCalculation = NO_STRING; // CCD
private $token = NO_STRING; // CCD
private $formattedAmount = NO_STRING; // H2P
private $ipAddress = NO_STRING; // H2P
private $h2pTransferUrl = NO_STRING; // H2P
private $h2pCallbackURL = NO_STRING; // H2P
private $h2pSecurityCode = NO_STRING; // H2P
private $h2pMerchantID = NO_STRING; // H2P
private $userAccount = NO_STRING; // 一般的な
private $bank = NO_STRING; // 一般的な
/*-------------------------------------------------------------------------
* @function_name: コントロールパネルシステムindexモデルクラスコンストラクタ
......@@ -251,6 +260,7 @@ class DepositModelClass extends ModelClassEx {
* @return : TRUE:成功、FALSE:失敗
-------------------------------------------------------------------------*/
public function validate() {
session_regenerate_id();
// 変数宣言部
$rtn = true;
$fee = NO_COUNT;
......@@ -2179,7 +2189,7 @@ class DepositModelClass extends ModelClassEx {
$rtn = false;
}
if($rtn==false){
if(!$rtn){
$this -> setType(TYPE_H2P_INPUT);
return;
}
......@@ -2336,7 +2346,7 @@ class DepositModelClass extends ModelClassEx {
// Check if executive
$this -> isExecutive = $this -> checkUnlimitedStatus($this -> getUserData(PARAM_USER_ACCOUNT));
// GET AMOUNT
$this -> amount = str_replace(",","",$this -> getDataPost('amount'));
$this -> amount = str_replace(",", NO_STRING, $this -> getDataPost('amount'));
if(!$this -> checkNull($this -> amount)){
$this -> popUpSessionMessage(ERROR, 'E_VALIDATE_HELP2PAY_DEVELOPER_TOOLS', array());
$this -> setType('');
......@@ -2349,18 +2359,21 @@ class DepositModelClass extends ModelClassEx {
return;
}
// Get CustomerID Needed by the gateway
$this -> custName = $this -> getColumnData($this -> account, PARAM_USER_ACCOUNT);
$this -> userAccount = $this -> getColumnData($this -> account, PARAM_USER_ACCOUNT);
// GET Bank
$this -> bank = $this -> getDataPost('bank');
// GET Currency
$this -> fee = $this -> intToCurrency(round(bcmul($this -> amount, VAL_STR_H2P_FEE, 4)),PERCENT);
$sqlObject = new mysql($this->getConfigValue(SECTION_DB,HOST_NAME),$this->getConfigValue(SECTION_DB,USER_NAME),$this->getConfigValue(SECTION_DB,LOGIN_PASS),$this->getConfigValue(SECTION_DB,TARGET_DB_NAME),'','UTF8');
$this -> fee = $this -> intToCurrency(round(bcmul($this -> amount, VAL_STR_H2P_FEE, 4)), PERCENT);
$country = $this->dispCountryCommon($this -> getColumnData($this -> account, PARAM_COUNTRY));
$countryList = array('Indonesia', 'Malaysia', 'Thailand', 'Vietnam');
$bypassValue = ($this -> getUserBypassValue(PARAM_DEPOSIT,VAL_STR_H2P_METHOD,($this -> getUserData(PARAM_USER_ACCOUNT))));
if((in_array($country,$countryList,TRUE)) && !$bypassValue){
$bypassValue = $this -> getUserBypassValue(
PARAM_DEPOSIT,
VAL_STR_H2P_METHOD,
$this -> getUserData(PARAM_USER_ACCOUNT)
);
if((in_array($country,$countryList,TRUE) && !$bypassValue) || isset($this -> country)){
// GET CURRENCY PER COUNTRY
if($country == "Indonesia"){
$this -> currency = "IDR";
......@@ -2371,19 +2384,6 @@ class DepositModelClass extends ModelClassEx {
} else if($country == "Malaysia"){
$this -> currency = "MYR";
}
}else{
if(isset($this -> country)){
// GET CURRENCY PER COUNTRY
if($this -> country == "Indonesia"){
$this -> currency = "IDR";
} else if($this -> country == "Vietnam"){
$this -> currency = "VND";
} else if($this -> country == "Thailand"){
$this -> currency = "THB";
} else if($this -> country == "Malaysia"){
$this -> currency = "MYR";
}
}
}
// CHECK IF AMOUNT IS CHANGE ON DEVELOPER TOOL
......@@ -2451,66 +2451,65 @@ class DepositModelClass extends ModelClassEx {
$this -> popUpSessionMessage(ERROR, 'E_REQUIRED_HELP2PAY_NOTAGGREE_OTHER', array());
$this -> setType(TYPE_H2P_CONFIRM);
} else {
$h2pSettings = $this -> getRowData($this -> accessSelect("SELECT_DEV_SETTING", ["help2pay_conf"]));
if($this -> isLoopData($h2pSettings)){
$h2pSettings = json_decode($this -> getColumnData($h2pSettings, "dev_setting_value"));
$this -> h2pTransferUrl = $h2pSettings -> transfer_url;
$this -> h2pSecurityCode = $h2pSettings -> security_code;
$this -> h2pMerchantID = $h2pSettings -> merchant_code;
}
// Need to remove the comma in the amount
$this-> Formatamount = str_replace(",","",$this -> formatCurrency(($this -> amount + $this -> fee), $this -> currency));
$this-> h2p_url = HELP2PAY_URL;
$this -> formattedAmount = str_replace(
",",
NO_STRING,
$this -> formatCurrency(($this -> amount + $this -> fee), $this -> currency));
// GET IP ADDRESS
if(! empty($_SERVER['REMOTE_ADDR']) ) {
$this -> customer_ip_address = $_SERVER["REMOTE_ADDR"];
}
else {
$this -> customer_ip_address = empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? '' : $_SERVER['HTTP_X_FORWARDED_FOR'];
}
$this -> ipAddress = $this -> getColumnData($_SERVER, "HTTP_X_FORWARDED_FOR");
if($this -> getColumnData($_SERVER, "REMOTE_ADDR") != NO_STRING)
$this -> ipAddress = $this -> getColumnData($_SERVER, "REMOTE_ADDR");
// Get Customer ReferenceID
$this -> customer_ref = $this -> getTransactionNumberCommon(VAR_TRANSACTION_DEPOSIT);
$this -> referenceNo = $this -> getTransactionNumberCommon(VAR_TRANSACTION_DEPOSIT);
// Get Amount
//$this -> customer_amount = sprintf('%0.2f',$this -> getDataPost('amount'),2);
$this -> customer_amount = $this -> Formatamount.".00";
// Get Merchant
$this -> customer_merchant = HELP2PAY_CUSTOMERMERCHANT;
// Get Customer
$this -> customer_name = $this -> custName;
// Get Customer Currency
$this -> customer_currency = $this -> currency;
// Get Customer Security Code
$this -> customer_securitycode = HELP2PAY_SECURITYCODE;
$this -> customer_amount = "{$this -> formattedAmount}.00";
// Get Customer Note
$this -> customer_note = "Note";
// Get Customer Bank
$this -> customer_bank = $this -> bank;
// Get Customer language
$this -> customer_language = "en-us";
// Get Back URI
$language = $this -> getLangage();
$this -> customer_backuri = HELP2PAY_CALLBACKURL."?lang=".$language;
//$this -> customer_backuri = "http://requestbin.fullcontact.com/1fnoref1";
$this -> h2pCallbackURL = HELP2PAY_CALLBACKURL."?lang=".$language;
//SAVE TO DATABASE
$transactionNumber = $this -> customer_ref;
$HELP2PAY['Model'] = array();
$HELP2PAY['Model']['transaction_number'] = $this -> customer_ref;
$HELP2PAY['Model']['user_account'] = $this -> getUserData(PARAM_USER_ACCOUNT);
$HELP2PAY['Model']['amount'] = $this -> amount;
$HELP2PAY['Model']['adjusted_amount'] = $this -> Formatamount;
$HELP2PAY['Model']['currency'] = $this -> customer_currency;
$HELP2PAY['Model']['method'] = 'Help2Pay';
$HELP2PAY['Model']['deposit_date'] = date("Y-m-d H:i:s");
$HELP2PAY['Model']['deposit_bank'] = $this -> getDataPost('bank');
$HELP2PAY['Model']['fee'] = str_replace(",","",$this -> formatCurrency($this -> fee, $this -> currency));
$HELP2PAY['Model']['message'] = "Local Bank Transfer (Southeast Asia)";
$HELP2PAY['Model']['comment'] = "via Front Page";
$HELP2PAY['Model']['create_time'] = date("Y-m-d H:i:s");
$HELP2PAY['Model']['process_user'] = '9999';
$HELP2PAY['Model']['type'] = '0';
$HELP2PAY['Model']['err_flg'] = '0';
$HELP2PAY['Model']['status'] = '0';
$sql = "insert into t_deposit_help2pay_temporary ";
//进deposit表的sql方法
$strsql = $sqlObject->Insertsql($HELP2PAY['Model']);
$sql .= $strsql;
$sqlObject->query($sql);
$transactionNumber = $this -> referenceNo;
$this -> accessModify("INSERT_DEPOSIT_H2P_TEMP", [
$this -> referenceNo,
$this -> getUserData(PARAM_USER_ACCOUNT),
$this -> amount,
$this -> formattedAmount,
$this -> currency,
VAL_STR_H2P_METHOD,
date("Y-m-d H:i:s"),
$this -> getDataPost('bank'),
str_replace(",", NO_STRING, $this -> formatCurrency($this -> fee, $this -> currency)),
"Local Bank Transfer (Southeast Asia)",
"via Front Page",
date("Y-m-d H:i:s"),
'9999',
NO_COUNT,
NO_COUNT,
NO_COUNT
]);
// Need to set up the time as it error on third party
date_default_timezone_set('Asia/Manila');
......@@ -2522,7 +2521,7 @@ class DepositModelClass extends ModelClassEx {
$customer_minutes = date('i:s A');
$this -> customer_date = $customer_year." ".$customer_Hour.":".$customer_minutes;
$reqinfo = "[date:".$this -> customer_date."][amount:".$this -> customer_amount."][merchant:".$this -> customer_merchant."][customerName:".$this -> customer_name."][currency:".$this -> customer_currency."][customerSecurityCode:".$this -> customer_securitycode."][customerBank:".$this -> customer_bank."]";
$reqinfo = "[date:".$this -> customer_date."][amount:".$this -> customer_amount."][merchant:".$this -> h2pMerchantID."][customerName:".$this -> userAccount."][currency:".$this -> currency."][customerSecurityCode:".$this -> h2pSecurityCode."][customerBank:".$this -> bank."]";
//SAVE LOGS
$apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api';
$requestUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P'.DIRECTORY_SEPARATOR.'deposit_request';
......@@ -2533,12 +2532,18 @@ class DepositModelClass extends ModelClassEx {
}
//log the transaction details
error_log(date("[Y-m-d H:i:s]")."\r\nRequest[".$this -> customer_ref."]:" ."\r\n". $reqinfo ."\r\n", 3, $requestUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
error_log(date("[Y-m-d H:i:s]")."\r\nRequest[".$this -> referenceNo."]:" ."\r\n". $reqinfo ."\r\n", 3, $requestUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
chmod($requestUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
// Get KEY
$customer_dateconverted = date('YmdHis');
$customer_data = $this->customer_merchant.$this->customer_ref.$this->customer_name.$this->customer_amount.$this->customer_currency.$customer_dateconverted.$this->customer_securitycode.$this->customer_ip_address;
$customer_data = $this -> h2pMerchantID
.$this -> referenceNo
.$this -> userAccount
.$this -> customer_amount
.$this -> currency
.date('YmdHis')
.$this -> h2pSecurityCode
.$this -> ipAddress;
$this -> customer_key = md5($customer_data);
$this -> customer_data = $customer_data;
......@@ -2546,70 +2551,80 @@ class DepositModelClass extends ModelClassEx {
} else if($this -> getType() == TYPE_H2P_STATUS) {
unset($_SESSION['H2PCurrency']);
if($this -> getDataPost("Status") == null) {
if($this -> getDataPost("Status") == NO_STRING) {
$this -> setType('');
return;
}
$this -> status = $this -> getDataPost("Status");
$sqlObject = new mysql($this->getConfigValue(SECTION_DB,HOST_NAME),$this->getConfigValue(SECTION_DB,USER_NAME),$this->getConfigValue(SECTION_DB,LOGIN_PASS),$this->getConfigValue(SECTION_DB,TARGET_DB_NAME),'','UTF8');
$this -> transationNumber = $this -> getDataPost("Reference");
//// GET data from temporary
$sqlstr = 'select * from t_deposit_help2pay_temporary where transaction_number = "'.$this -> transationNumber.'"';
$result = $sqlObject -> query($sqlstr);
$row = $sqlObject -> fetch_assoc($result);
if($this -> status == "000" || $this -> status == "006") {
//// SAVE TO DATABASE
if(count($row) > 0){
$sqlstr2 = 'select * from t_deposit where transaction_number = "'.$this -> transationNumber.'"';
$result2 = $sqlObject -> query($sqlstr2);
$row2 = $sqlObject -> fetch_assoc($result2);
if($row2 == NULL){
$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'] = $row['message'];
$HELP2PAY['Model']['comment'] = "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');
$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($this->getConfigValue(SECTION_DB,HOST_NAME),$this->getConfigValue(SECTION_DB,USER_NAME),$this->getConfigValue(SECTION_DB,LOGIN_PASS),$this->getConfigValue(SECTION_DB,TARGET_DB_NAME),'','UTF8');
$sql = "insert into t_deposit";
//进deposit表的sql方法
$strsql = $sqlObject->Insertsql($HELP2PAY['Model']);
$sql .= $strsql;
$sqlObject->query($sql);
}
// Send Mail
$this -> setDeposit($this -> getRowData($this -> accessSelect('SELECT_DEPOSIT_BY_TRANSACTION_NUMBER', array($this -> transationNumber))));
$this -> fee = $this -> intToCurrency(round(bcmul($row['amount'], VAL_STR_H2P_FEE, 4)),PERCENT);
// $this -> sendHelp2PaySuccessMail();
// $this -> accessModifyCommon('UPDATE_DEPOSIT_ISSENDMAIL',array($this -> transationNumber));
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);
$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 -> setDeposit($this -> getRowData($processedTransaction));
$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 -> transationNumber = $this -> getColumnData($tempRow, COLUMN_TRANSACTION_NUMBER);
$this -> sendHelp2PaySuccessMail();
}
break;
}
$this -> fee = $this -> intToCurrency(round(bcmul($row['amount'], VAL_STR_H2P_FEE, 4)),PERCENT);
$this -> createTime = $row['create_time'];
$this -> amount = $row['amount'];
$this -> currency = $row['currency'];
$this -> transationNumber = $row['transaction_number'];
} else if($this -> status == "009") {
case "009":
$this -> setType(TYPE_H2P_PENDING);
} else {
break;
default:
$this -> sendHelp2PayFailMail();
$this -> setType(TYPE_H2P_FAIL);
break;
}
}else if($this -> getType() == TYPE_CPS_INPUT
|| $this -> getType() == TYPE_CPS_CONFIRM
|| $this -> getType() == TYPE_CPS_COMPLETE
......@@ -2640,7 +2655,6 @@ class DepositModelClass extends ModelClassEx {
return;
}
}
}
if($this -> getType() == TYPE_CPS_BACK){
......@@ -2648,7 +2662,6 @@ class DepositModelClass extends ModelClassEx {
return;
}
if($this -> getType() == TYPE_CPS_CONFIRM){
// Validate amount if its a number
if (!is_numeric($this -> amount)) {
......@@ -2686,10 +2699,8 @@ class DepositModelClass extends ModelClassEx {
$_SESSION['CPS']['amount'] = $this -> amount;
$_SESSION['CPS']['fee'] = $this -> fee;
$_SESSION['CPS']['Actual'] = $totalDepositAmount;
}
//if type is send
if($this -> getType() == TYPE_CPS_SEND) {
$apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api';
......@@ -2847,17 +2858,17 @@ class DepositModelClass extends ModelClassEx {
$member = $this -> getRowData($this -> getAccountCommon($this -> getUserData(PARAM_USER_ACCOUNT)), 0);
$snaps -> setDepositDetails([
"firstName" => $member[PARAM_FIRST_NAME],
"lastName" => $member[PARAM_LAST_NAME],
"firstName" => $this -> getColumnData($member, PARAM_FIRST_NAME),
"lastName" => $this -> getColumnData($member, PARAM_LAST_NAME),
"company" => "iWallet Limited",
"address1" => $member[PARAM_ADDRESS],
"address2" => $member[PARAM_ADDRESS],
"mobile" => $member[PARAM_TEL],
"city" => $member[PARAM_CITY],
"province" => $member[PARAM_STATE],
"zip" => $member[PARAM_ZIP_CODE],
"country" => $member[PARAM_COUNTRY],
"email" => $member[PARAM_MAIL],
"address1" => $this -> getColumnData($member, PARAM_ADDRESS),
"address2" => $this -> getColumnData($member, PARAM_ADDRESS),
"mobile" => $this -> getColumnData($member, PARAM_TEL),
"city" => $this -> getColumnData($member, PARAM_CITY),
"province" => $this -> getColumnData($member, PARAM_STATE),
"zip" => $this -> getColumnData($member, PARAM_ZIP_CODE),
"country" => $this -> getColumnData($member, PARAM_COUNTRY),
"email" => $this -> getColumnData($member, PARAM_MAIL),
"itemName" => "Credit Card Deposit Transaction",
"depositAmount" => $this -> amount,
"currency" => $this -> currency,
......@@ -2870,7 +2881,7 @@ class DepositModelClass extends ModelClassEx {
$logFile = SITE_ROOT."api/Logs/APN/Log_D".date("Y-m-d").".log";
$resultObject = json_decode($result);
$resultObject -> userAccount = $member[PARAM_USER_ACCOUNT];
$resultObject -> userAccount = $this -> getColumnData($member, PARAM_USER_ACCOUNT);
$resultObject -> depositAmount = "{$this -> currency} {$this -> amount}";
$msgtime = date("Y-m-d H:i:s");
......@@ -4048,7 +4059,7 @@ class DepositModelClass extends ModelClassEx {
/// HELP2PAY
public function GetRedirectURLHelp2Pay() {
$language = $this -> getLangage();
$redirectURL = "https://secure.". SITE_DOMAIN . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . "deposit?type=h2p_status";
$redirectURL = SITE_PROTOCOL."://". SITE_DOMAIN_FULL . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . "deposit?type=h2p_status";
//echo this-> $redirectURL;
// $redirectURL = "http://localhost/en/deposit?type=h2p_status";
echo $redirectURL;
......@@ -4056,13 +4067,13 @@ class DepositModelClass extends ModelClassEx {
public function GetSendInformationH2P($Type) {
if($Type == "Merchant") {
echo $this-> customer_merchant;
echo $this -> h2pMerchantID;
} else if($Type == "Currency") {
echo $this-> customer_currency;
echo $this-> currency;
} else if($Type == "Customer") {
echo $this-> customer_name;
echo $this-> userAccount;
} else if($Type == "Reference") {
echo $this-> customer_ref;
echo $this-> referenceNo;
} else if($Type == "Key") {
echo $this-> customer_key;
} else if($Type == "Amount") {
......@@ -4072,19 +4083,20 @@ class DepositModelClass extends ModelClassEx {
} else if($Type == "DateTime") {
echo $this-> customer_date;
} else if($Type == "BackURI") {
echo $this-> customer_backuri;
echo $this-> h2pCallbackURL;
} else if($Type == "language") {
echo $this-> customer_language;
} else if($Type == "bank") {
echo $this-> customer_bank;
echo $this-> bank;
} else if($Type == "ClientIP") {
echo $this-> customer_ip_address;
echo $this-> ipAddress;
} else if($Type == "CustomerData") {
echo $this-> customer_data;
} else if($Type == "H2PURL") {
echo $this-> h2p_url;
echo $this -> h2pTransferUrl;
}
}
public function displayLocalBankListPerCurrency() {
$currency = $this -> currency;
$selected = NO_STRING;
......@@ -4194,7 +4206,6 @@ class DepositModelClass extends ModelClassEx {
, $this -> getLangage());
}
private function sendZanetapaySuccessMail(){
$params = '';
// 変数宣言部
......
......@@ -67,7 +67,6 @@ class WithdrawModelClass extends ModelClassEx {
// チェック
$this -> validate();
} catch (Exception $e) {
throw $e;
}
......@@ -2141,7 +2140,6 @@ class WithdrawModelClass extends ModelClassEx {
}
public function getOutStatus()
{
$account = $this->getUserData(PARAM_USER_ACCOUNT);
$rs = $this -> getAccountCommon($account);
$row = $this -> getRowData($rs);
......@@ -2711,9 +2709,9 @@ class WithdrawModelClass extends ModelClassEx {
'toBankAccountName' => $this -> accountName,
'toBankAccountNumber' => $this -> accountNumber,
);
$raw = NO_STRING;
//generate key
$key = $help2PayAPI -> generateKey($data);
$key = $help2PayAPI -> generateKey($data, $raw);
//save key to db
$param = array();
......@@ -2722,7 +2720,7 @@ class WithdrawModelClass extends ModelClassEx {
$param[] = $language;
$param[] = $this -> receiptBankName;
$this->accessModify('UPDATE_WITHDRAW_H2P_KEY', $param);
$this -> accessModify('UPDATE_WITHDRAW_H2P_KEY', $param);
//send request
$requestData = $help2PayAPI -> generateRequestData($data, $key); //generate request data
......@@ -2731,7 +2729,6 @@ class WithdrawModelClass extends ModelClassEx {
//check if create request is successful
if($res != NULL) {
$xml = new SimpleXMLElement($res);
$statusCode = $xml->statusCode;
$message = $xml->message;
......@@ -2742,8 +2739,11 @@ class WithdrawModelClass extends ModelClassEx {
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);
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){
......@@ -2751,8 +2751,15 @@ class WithdrawModelClass extends ModelClassEx {
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);
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{
......@@ -2761,7 +2768,10 @@ class WithdrawModelClass extends ModelClassEx {
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');
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;
......@@ -2772,5 +2782,4 @@ class WithdrawModelClass extends ModelClassEx {
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
<?php
include '../../system/lib/config.php';
class H2PPayoutTesting extends System{
/**
*
* @var string
*/
private $returnURI = NO_STRING;
/**
*
* @var string
*/
private $amount = NO_COUNT;
/**
*
* @var string
*/
private $transactionNum = NO_STRING; // auto-generated
/**
*
* @var string
*/
private $currencyCode = NO_STRING;
/**
*
* @var string
*/
private $fromCurrencyCode = NO_STRING;
/**
*
* @var string
*/
private $memberCode = NO_STRING;
/**
*
* @var string
*/
private $bankCode = NO_STRING;
/**
*
* @var string
*/
private $bankAccountName = NO_STRING;
/**
*
* @var string
*/
private $countryCode = NO_STRING;
/**
*
* @var string
*/
private $bankAccountNum = NO_STRING;
/**
*
* @var string
*/
private $merchantCode = NO_STRING;
/**
*
* @var string
*/
private $payoutURL = NO_STRING;
/**
*
* @var string
*/
private $ipAddress = NO_STRING;
/**
*
* @var string
*/
private $securityCode = NO_STRING;
public function __construct(){
parent::__construct();
$this -> setParameter();
$this -> validation();
}
private function setParameter(){
date_default_timezone_set('Asia/Manila');
$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 -> payoutURL = str_replace("{merchantcode}", $this -> merchantCode, $h2pSettings -> payout_url);
$this -> ipAddress = $h2pSettings -> ip_address;
$this -> securityCode = $h2pSettings -> security_code;
}
$this -> returnURI = $this -> getDataPost("returnURI");
if($this -> returnURI == NO_STRING)
$this -> returnURI = SITE_PROTOCOL."://".SITE_DOMAIN_FULL."/api/H2PWithdrawalWebhook.php";
$this -> amount = $this -> getDataPost("amount");
$this -> currencyCode = $this -> getDataPost("currency");
$this -> fromCurrencyCode = $this -> getDataPost("fromCurrency");
$this -> memberCode = $this -> getDataPost("memberCode");
$this -> countryCode = $this -> getDataPost("countryCode");
$this -> bankCode = $this -> getDataPost("bankCode");
$this -> bankAccountName = $this -> getDataPost("bankAccountName");
$this -> bankAccountNum = $this -> getDataPost("bankAccountNum");
}
private function validation(){
$validationRemarks = [];
$memberAccount = $this -> getRowData($this -> getAccountCommon($this -> memberCode));
if(!$this -> getColumnData($memberAccount, COLUMN_TEST_ACCOUNT_FLG)){
$validationRemarks[] = json_encode([
"code" => "01",
"message" => "Member Code ({$this -> memberCode}) is not under tester category."
]);
}
$fullName = "{$this -> getColumnData($memberAccount, COLUMN_FIRST_NAME)} {$this -> getColumnData($memberAccount, COLUMN_LAST_NAME)}";
if(strcmp($this -> bankAccountName, $fullName) !== 0){
$validationRemarks[] = json_encode([
"code" => "02",
"message" => "Member Name ({$this -> bankAccountName}) is not correct."
]);
}
if($this -> isLoopData($validationRemarks))
die(print_r($validationRemarks, true));
$this -> transactionNum = $this -> getTransactionNumberCommon(VAR_TRANSACTION_WITHDRAW);
}
/**
*
* @var array
*/
private $data = [];
/**
*
* @var string
*/
private $rawKey = NO_STRING;
private function buildData(){
$dateTime = date("Y-m-d H:i:s");
$this -> data = [
"ClientIP" => $this -> ipAddress,
"ReturnURI" => $this -> returnURI,
"MerchantCode" => $this -> merchantCode,
"TransactionID" => $this -> transactionNum,
"CurrencyCode" => $this -> currencyCode,
"MemberCode" => $this -> memberCode,
"Amount" => sprintf("%.2f", $this -> amount),
"TransactionDateTime" => date("Y-m-d h:i:sA", strtotime($dateTime)),
"BankCode" => $this -> bankCode,
"toBankAccountName" => $this -> bankAccountName,
"toBankAccountNumber" => $this -> bankAccountNum
];
// key generation
$this ->rawKey = $this -> getColumnData($this -> data, "MerchantCode")
.$this -> getColumnData($this -> data, "TransactionID")
.$this -> getColumnData($this -> data, "MemberCode")
.$this -> getColumnData($this -> data, "Amount")
.$this -> getColumnData($this -> data, "CurrencyCode")
.date("YmdHis", strtotime($dateTime))
.$this -> getColumnData($this -> data, "toBankAccountNumber")
.$this -> securityCode;
$transactionKey = md5($this -> rawKey);
$this -> data["Key"] = $transactionKey;
$exchange = $this->getExchangeCommon($this -> amount
, $this -> currencyCode
, $this -> fromCurrencyCode
, false
, true
, NO_STRING
, $this -> memberCode);
$this -> setRateEx($this -> getColumnData($exchange, PARAM_RATE));
$this -> setFeeEx(round($exchange[PARAM_AMOUNT] * 0.02, VAL_INT_2));
}
private function storeToTemporaryTable(){
$rtn = [];
$rtn[] = $this -> memberCode; // account number(1)
$rtn[] = $this -> currencyCode; // currency(2)
$rtn[] = $this -> currencyToInt($this -> amount, $this -> currencyCode); // Amount of money(3)
$rtn[] = $this -> currencyCode; // currency(4)
$rtn[] = $this -> bankAccountName; // Account holder(5)
$rtn[] = $this -> countryCode; // Recipient country(6)
$rtn[] = NO_STRING; // Recipient address 1(7)
$rtn[] = NO_STRING; // Recipient address 1(8)
$rtn[] = 'Local Bank Transfer (Southeast Asia)'; // Recipient message(9)
$rtn[] = 'Local Bank Transfer (Southeast Asia)'; // Receiving bank name(10)
$rtn[] = NO_STRING; // Receiving bank branch name(11)
$rtn[] = NO_STRING; // Receiving bank SWIFT(12)
$rtn[] = $this -> countryCode; // Receiving bank country(13)
$rtn[] = NO_STRING; // Receiving bank address 1(14)
$rtn[] = NO_STRING; // Receiving bank address 2(15)
$rtn[] = $this -> memberCode; // Receiving bank account number(16)
$rtn[] = NO_COUNT; // Relay bank flag(17)
$rtn[] = NO_STRING; // Relay bank name(18)
$rtn[] = NO_STRING; // Relay bank SWIFT(19)
$rtn[] = NO_STRING; // Relay bank country(20)
$rtn[] = NO_STRING; // Relay bank address 1(21)
$rtn[] = NO_STRING; // Relay bank address 2(22)
$rtn[] = NO_STRING; // Relay bank message(23)
$rtn[] = NO_STRING; // phone number(24)
$rtn[] = $this -> currencyCode; // Debit account currency(25)
$rtn[] = $this -> currencyToInt($this -> amount, $this -> currencyCode); // Withdrawal account amount(26)
$rtn[] = $this -> getRateEx(); // rate(27)
$rtn[] = $this -> currencyToInt($this -> getFeeEx(), $this -> currencyCode); // Fee(28)
$rtn[] = $this -> transactionNum; // Transaction Number(29)
$rtn[] = NO_STRING; // Receiving bank branch code(30)
$rtn[] = VAL_STR_H2P_METHOD; // withdraw solution (31)
$this->accessModify('INSERT_WITHDRAW_H2P_TEMP', $rtn, false);
}
private function processPayout(){
$param = array();
$param[] = $this -> transactionNum;
$param[] = $this -> getColumnData($this -> data, "Key");
$param[] = "en";
$param[] = $this -> bankCode;
$this -> accessModify('UPDATE_WITHDRAW_H2P_KEY', $param, false);
$handle = curl_init();
curl_setopt_array($handle, [
CURLOPT_URL => $this -> payoutURL,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "utf8",
CURLOPT_POSTFIELDS => http_build_query($this -> data),
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Content-type: application/x-www-form-urlencoded"
]
]);
$output = curl_exec($handle);
if($err = curl_error($handle))
$output = $err;
curl_close($handle);
return $output;
}
public function listen(){
$this -> buildData();
echo "Payout URL: {$this -> payoutURL}\n";
echo "Raw Key: {$this -> rawKey}\n";
echo "Request Data: ".print_r($this -> data, true);
$this -> storeToTemporaryTable();
$xmlResult = new SimpleXMLElement($this -> processPayout());
if($xmlResult){
switch($xmlResult -> statusCode){
case "000":
echo "\nSuccessful\n";
echo "Result: {$xmlResult -> message}";
break;
default:
echo "Result: {$xmlResult -> message}";
break;
}
}
}
}
$payoutTest = new H2PPayoutTesting();
$payoutTest -> listen();
<?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