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

Help2Pay Migration [Initial Commit]

parent dbe1382b
...@@ -78,23 +78,19 @@ class APNWebHook extends System{ ...@@ -78,23 +78,19 @@ class APNWebHook extends System{
private function creditTransaction($tempDepositData){ private function creditTransaction($tempDepositData){
$comment = "[APN Reference No.]\\n{$tempDepositData["invoice_num"]}"; $comment = "[APN Reference No.]\\n{$tempDepositData["invoice_num"]}";
foreach($tempDepositData as &$data){
$data = "('){$data}(')";
}
$method = VAL_STR_CCDEPOSIT_METHOD; $method = VAL_STR_CCDEPOSIT_METHOD;
$this -> accessModify("INSERT_CC_DEPOSIT_TRANSACTION", [ $this -> accessModify("INSERT_WB_DEPOSIT_TRANSACTION", [
$tempDepositData[COLUMN_TRANSACTION_NUMBER], $tempDepositData[COLUMN_TRANSACTION_NUMBER],
$tempDepositData[COLUMN_USER_ACCOUNT], $tempDepositData[COLUMN_USER_ACCOUNT],
$tempDepositData[COLUMN_AMOUNT], $tempDepositData[COLUMN_AMOUNT],
$tempDepositData[COLUMN_CURRENCY], $tempDepositData[COLUMN_CURRENCY],
"('){$method}(')", $method,
"(')Credit Card Deposit(')", "Credit Card Deposit",
$tempDepositData[COLUMN_DEPOSIT_DATE], $tempDepositData[COLUMN_DEPOSIT_DATE],
$tempDepositData[COLUMN_FEE], $tempDepositData[COLUMN_FEE],
"('){$comment}(')", $comment,
$tempDepositData[COLUMN_CREATE_TIME], $tempDepositData[COLUMN_CREATE_TIME],
NO_COUNT, NO_COUNT,
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 <?php
include_once $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'config.php'; include_once $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'config.php';
class help2PayAPI { class help2PayAPI extends System {
private $callback_url = H2P_CALLBACKURL; private $callback_url = H2P_CALLBACKURL;
private $ip = SYSTEM_IP;
private $merchant_code = H2P_MERCHANT_CODE; private $payoutUrl = NO_STRING;
private $security_code = H2P_SECURITY_CODE; 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 * @function_name: generateRequestData
* "@description : generates the request data * "@description : generates the request data
...@@ -30,7 +52,6 @@ class help2PayAPI { ...@@ -30,7 +52,6 @@ class help2PayAPI {
'toBankAccountNumber' => $data['toBankAccountNumber'], 'toBankAccountNumber' => $data['toBankAccountNumber'],
); );
return $requestData; return $requestData;
} }
...@@ -41,19 +62,28 @@ class help2PayAPI { ...@@ -41,19 +62,28 @@ class help2PayAPI {
* @return : key string * @return : key string
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
public function generateKey($data){ public function generateKey($data, &$rawKeyForm){
$strKey=NO_STRING; $strKey = NO_STRING;
$transaction_id = $data['TransactionID']; $transaction_id = $data['TransactionID'];
$member_code = $data['MemberCode']; $member_code = $data['MemberCode'];
$amount = $data['Amount']; $amount = $data['Amount'];
$currency = $data['CurrencyCode']; $currency = $data['CurrencyCode'];
$transaction_date_time = $data['TransactionDateTime']; $transaction_date_time = $data['TransactionDateTime'];
$bank_account_number = $data['toBankAccountNumber']; $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
$key = md5($strKey); .$member_code
.$amount
.$currency
.$transaction_date_time
.$bank_account_number
.$this -> security_code;
$rawKeyForm = $strKey;
$key = md5($strKey);
return $key; return $key;
} }
...@@ -64,13 +94,22 @@ class help2PayAPI { ...@@ -64,13 +94,22 @@ class help2PayAPI {
* @return : array response data ; bool - false (if creation is successful, returns response data else returns false) * @return : array response data ; bool - false (if creation is successful, returns response data else returns false)
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
public function submitPayoutRequest($data){ public function submitPayoutRequest($data){
//set curl parameters //set curl parameters
$ch = curl_init('https://app.racethewind.net/merchantpayout/M0103'); //请求的URL地址 $ch = curl_init($this -> payoutUrl); //请求的URL地址
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt_array($ch, [
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 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); $responseData = curl_exec($ch);
//check if curl failed //check if curl failed
...@@ -78,35 +117,11 @@ class help2PayAPI { ...@@ -78,35 +117,11 @@ class help2PayAPI {
return false; return false;
} }
curl_close($ch); curl_close($ch);
//$responseData = json_decode($responseData,true);
if(count($responseData) > 0) { if(count($responseData) > 0) {
return $responseData; return $responseData;
} else { } else {
return false; 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,96 +6,97 @@ include_once('template/base_head.php'); ...@@ -6,96 +6,97 @@ include_once('template/base_head.php');
<!-- サイドバー --> <!-- サイドバー -->
<aside id="colLeft"> <aside id="colLeft">
<h1><a href="/en/menu"><img src="../img/logo.png" alt="<?php echo SITE_NAME; ?>"></a></h1> <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> </aside>
<!-- /サイドバー --> <!-- /サイドバー -->
<!-- メインカラム --> <!-- メインカラム -->
<div id="colMain"> <div id="colMain">
<div class="mainIn"> <div class="mainIn">
<?php include_once('template/base_nav.php'); ?> <?php include_once('template/base_nav.php'); ?>
<article> <article>
<div class="article-heading"> <div class="article-heading">
<h2><?php echo $page_title; ?></h2> <h2><?php echo $page_title; ?></h2>
</div> </div>
<div class="mb10 pleft40"><?php echo $this -> echoMessage(); ?></div> <div class="mb10 pleft40"><?php echo $this -> echoMessage(); ?></div>
<p class="pleft40 mb20 respM"> <p class="pleft40 mb20 respM">
Please accomplish the necessary information and check the note below before making any transactions. Please accomplish the necessary information and check the note below before making any transactions.
</p> </p>
<form id="acForm" action="" method="post" class="form1"> <form id="acForm" action="" method="post" class="form1">
<div class="pleft40"> <div class="pleft40">
<table class="table col bdr default odd fontM summaryT"> <table class="table col bdr default odd fontM summaryT">
<tr> <tr>
<th width="30%">Country</th> <th width="30%">Country</th>
<td ><div id="country" name="country" class="country"><?php echo $this -> echoCountryNameH2P(); ?></div></td> <td>
</tr> <div id="country" class="country">
<tr><th>Currency</th> <?php echo $this -> echoCountryNameH2P(); ?>
<td><?php $this -> dispH2PCurrency(); ?></td> </div>
</tr> </td>
<tr> </tr>
<th>Deposit Amount</th> <tr><th>Currency</th>
<td id="amount_td1"> <td><?php $this -> dispH2PCurrency(); ?></td>
<ul class="ui-choose" id="uc_01"> </tr>
<?php $this -> dispH2PAmount();?> <tr>
</ul> <th>Deposit Amount</th>
<div id="damount" class="hidediv"> <td id="amount_td1">
<div class="con" > <ul class="ui-choose" id="uc_01">
<input type="text" value="" placeholder="" id="depositmoney" name="depositmoney" onblur="setAmount();"> <?php $this -> dispH2PAmount();?>
</div><div class="tips"><div class="Validform_checktip"></div></div> </ul>
</div> <div id="damount" class="hidediv">
<div class="con" >
<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>Please select a bank</option>
<?php $this -> displayLocalBankListPerCurrency(); ?>
</select>
</td>
</tr>
</table>
<br>
<strong class="redtext">Note:</strong>
<ol class="ol_list pl20">
<li><p>This option is only available to all individual members with bank account in Vietnam, Thailand, Malaysia and Indonesia.</p></li>
<li><p>The supported currencies for this method are VND, THB, MYR and IDR.</p></li>
<li><p>Below is the deposit limitation per currency:<br>
<strong>VND:</strong> <br>
Standard Account Members: VND 300,000.00 - VND 100,000,000.00 per transaction. <br>
Executive Account Members: VND 300,000.00 - VND 290,000,000.00 per transaction. <br>
<strong>THB:</strong> <br>
Standard Account Members: THB 500.00 - THB 300,000.00 per transaction. <br>
Executive Account Members: THB 500.00 - THB 480,000.00 per transaction. <br>
<strong>MYR:</strong> <br>
Standard Account Members: MYR 50.00 - MYR 30,000.00 per transaction. <br>
Executive Account Members: MYR 50.00 - MYR 48,000.00 per transaction. <br>
<strong>IDR:</strong><br>
Standard Account Members: IDR 200,000.00 - IDR 100,000,000.00 per transaction. <br>
Executive Account Members: IDR 200,000.00 - IDR 190,000,000.00 per transaction. <br></p>
</li>
<li><p>A transaction fee, 2.80% of the deposit amount will be charged to the member.</p></li>
<li><p>The amount you deposited will be instantly credited to your iWallet account. The beneficiary currency will be based on the country of registration.</p></li>
<li><p>You can only deposit funds to your own iWallet account.</p></li>
<li><p>If you have not received the funds within 24 hours, please contact us.</p></li>
</ol>
</div>
</td> <p class="calign nextwbtn" style="margin-top: 40px;"><input type="button" class="btn bg-grad px180" id="btnH2PSend" value="Next"></p>
</tr>
<tr> <input type="hidden" value="" name="amount" id="amount">
<th>Remitting Bank</th> <input type="hidden" value="<?php echo $this -> getExecutiveStatus(); ?>" name="is_executive" id="is_executive">
<td> <input type="hidden" value="<?php echo TYPE_H2P_CONFIRM ?>" name="method">
<select name="bank" id="bank_name"> <input type="hidden" value="" id="type" name="type">
<option disabled="" selected="">Please select a bank</option>
<?php $this -> displayLocalBankListPerCurrency(); ?>
</select>
</td>
</tr>
</table>
<br>
<strong class="redtext">Note:</strong>
<ol class="ol_list pl20">
<li><p>This option is only available to all individual members with bank account in Vietnam, Thailand, Malaysia and Indonesia.</p></li>
<li><p>The supported currencies for this method are VND, THB, MYR and IDR.</p></li>
<li><p>Below is the deposit limitation per currency:<br>
<strong>VND:</strong> <br>
Standard Account Members: VND 300,000.00 - VND 100,000,000.00 per transaction. <br>
Executive Account Members: VND 300,000.00 - VND 290,000,000.00 per transaction. <br>
<strong>THB:</strong> <br>
Standard Account Members: THB 500.00 - THB 300,000.00 per transaction. <br>
Executive Account Members: THB 500.00 - THB 480,000.00 per transaction. <br>
<strong>MYR:</strong> <br>
Standard Account Members: MYR 50.00 - MYR 30,000.00 per transaction. <br>
Executive Account Members: MYR 50.00 - MYR 48,000.00 per transaction. <br>
<strong>IDR:</strong><br>
Standard Account Members: IDR 200,000.00 - IDR 100,000,000.00 per transaction. <br>
Executive Account Members: IDR 200,000.00 - IDR 190,000,000.00 per transaction. <br></p>
</li>
<li><p>A transaction fee, 2.80% of the deposit amount will be charged to the member.</p></li>
<li><p>The amount you deposited will be instantly credited to your iWallet account. The beneficiary currency will be based on the country of registration.</p></li>
<li><p>You can only deposit funds to your own iWallet account.</p></li>
<li><p>If you have not received the funds within 24 hours, please contact us.</p></li>
</ol>
</div>
<p class="calign nextwbtn" style="margin-top: 40px;"><input type="button" class="btn bg-grad px180" id="btnH2PSend" value="Next"></p>
<input type="hidden" value="" name="amount" id="amount">
<input type="hidden" value="<?php echo $this -> getExecutiveStatus(); ?>" name="is_executive" id="is_executive">
<input type="hidden" value="<?php echo TYPE_H2P_CONFIRM ?>" name="method">
<input type="hidden" value="" id="type" name="type">
</form> </form>
</article> </article>
</div> </div>
</div> </div>
<!-- /メインカラム --> <!-- /メインカラム -->
</div> </div>
<?php include_once('template/base_foot.php'); ?> <?php include_once('template/base_foot.php'); ?>
</div> </div>
<script src="../js/ui-choose-bind.js"></script> <script src="../js/ui-choose-bind.js"></script>
<script src="../js/deposit.js" type="text/javascript"></script> <script src="../js/deposit.js" type="text/javascript"></script>
......
...@@ -18,8 +18,17 @@ class DepositModelClass extends ModelClassEx { ...@@ -18,8 +18,17 @@ class DepositModelClass extends ModelClassEx {
private $file = null; //uploaded image private $file = null; //uploaded image
// 別の入金Solutionの変数 // 別の入金Solutionの変数
private $validCalculation; // CCD private $validCalculation = NO_STRING; // CCD
private $token; // 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モデルクラスコンストラクタ * @function_name: コントロールパネルシステムindexモデルクラスコンストラクタ
...@@ -251,6 +260,7 @@ class DepositModelClass extends ModelClassEx { ...@@ -251,6 +260,7 @@ class DepositModelClass extends ModelClassEx {
* @return : TRUE:成功、FALSE:失敗 * @return : TRUE:成功、FALSE:失敗
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
public function validate() { public function validate() {
session_regenerate_id();
// 変数宣言部 // 変数宣言部
$rtn = true; $rtn = true;
$fee = NO_COUNT; $fee = NO_COUNT;
...@@ -2179,7 +2189,7 @@ class DepositModelClass extends ModelClassEx { ...@@ -2179,7 +2189,7 @@ class DepositModelClass extends ModelClassEx {
$rtn = false; $rtn = false;
} }
if($rtn==false){ if(!$rtn){
$this -> setType(TYPE_H2P_INPUT); $this -> setType(TYPE_H2P_INPUT);
return; return;
} }
...@@ -2336,7 +2346,7 @@ class DepositModelClass extends ModelClassEx { ...@@ -2336,7 +2346,7 @@ class DepositModelClass extends ModelClassEx {
// Check if executive // Check if executive
$this -> isExecutive = $this -> checkUnlimitedStatus($this -> getUserData(PARAM_USER_ACCOUNT)); $this -> isExecutive = $this -> checkUnlimitedStatus($this -> getUserData(PARAM_USER_ACCOUNT));
// GET AMOUNT // GET AMOUNT
$this -> amount = str_replace(",","",$this -> getDataPost('amount')); $this -> amount = str_replace(",", NO_STRING, $this -> getDataPost('amount'));
if(!$this -> checkNull($this -> amount)){ if(!$this -> checkNull($this -> amount)){
$this -> popUpSessionMessage(ERROR, 'E_VALIDATE_HELP2PAY_DEVELOPER_TOOLS', array()); $this -> popUpSessionMessage(ERROR, 'E_VALIDATE_HELP2PAY_DEVELOPER_TOOLS', array());
$this -> setType(''); $this -> setType('');
...@@ -2349,18 +2359,21 @@ class DepositModelClass extends ModelClassEx { ...@@ -2349,18 +2359,21 @@ class DepositModelClass extends ModelClassEx {
return; return;
} }
// Get CustomerID Needed by the gateway // 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 // GET Bank
$this -> bank = $this -> getDataPost('bank'); $this -> bank = $this -> getDataPost('bank');
// GET Currency // GET Currency
$this -> fee = $this -> intToCurrency(round(bcmul($this -> amount, VAL_STR_H2P_FEE, 4)),PERCENT); $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');
$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){
$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) || isset($this -> country)){
// GET CURRENCY PER COUNTRY // GET CURRENCY PER COUNTRY
if($country == "Indonesia"){ if($country == "Indonesia"){
$this -> currency = "IDR"; $this -> currency = "IDR";
...@@ -2371,19 +2384,6 @@ class DepositModelClass extends ModelClassEx { ...@@ -2371,19 +2384,6 @@ class DepositModelClass extends ModelClassEx {
} else if($country == "Malaysia"){ } else if($country == "Malaysia"){
$this -> currency = "MYR"; $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 // CHECK IF AMOUNT IS CHANGE ON DEVELOPER TOOL
...@@ -2451,67 +2451,66 @@ class DepositModelClass extends ModelClassEx { ...@@ -2451,67 +2451,66 @@ class DepositModelClass extends ModelClassEx {
$this -> popUpSessionMessage(ERROR, 'E_REQUIRED_HELP2PAY_NOTAGGREE_OTHER', array()); $this -> popUpSessionMessage(ERROR, 'E_REQUIRED_HELP2PAY_NOTAGGREE_OTHER', array());
$this -> setType(TYPE_H2P_CONFIRM); $this -> setType(TYPE_H2P_CONFIRM);
} else { } 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 // Need to remove the comma in the amount
$this-> Formatamount = str_replace(",","",$this -> formatCurrency(($this -> amount + $this -> fee), $this -> currency)); $this -> formattedAmount = str_replace(
$this-> h2p_url = HELP2PAY_URL; ",",
NO_STRING,
$this -> formatCurrency(($this -> amount + $this -> fee), $this -> currency));
// GET IP ADDRESS // GET IP ADDRESS
if(! empty($_SERVER['REMOTE_ADDR']) ) { $this -> ipAddress = $this -> getColumnData($_SERVER, "HTTP_X_FORWARDED_FOR");
$this -> customer_ip_address = $_SERVER["REMOTE_ADDR"];
} if($this -> getColumnData($_SERVER, "REMOTE_ADDR") != NO_STRING)
else { $this -> ipAddress = $this -> getColumnData($_SERVER, "REMOTE_ADDR");
$this -> customer_ip_address = empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? '' : $_SERVER['HTTP_X_FORWARDED_FOR'];
}
// Get Customer ReferenceID // Get Customer ReferenceID
$this -> customer_ref = $this -> getTransactionNumberCommon(VAR_TRANSACTION_DEPOSIT); $this -> referenceNo = $this -> getTransactionNumberCommon(VAR_TRANSACTION_DEPOSIT);
// Get Amount // Get Amount
//$this -> customer_amount = sprintf('%0.2f',$this -> getDataPost('amount'),2); $this -> customer_amount = "{$this -> formattedAmount}.00";
$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;
// Get Customer Note // Get Customer Note
$this -> customer_note = "Note"; $this -> customer_note = "Note";
// Get Customer Bank
$this -> customer_bank = $this -> bank;
// Get Customer language // Get Customer language
$this -> customer_language = "en-us"; $this -> customer_language = "en-us";
// Get Back URI // Get Back URI
$language = $this -> getLangage(); $language = $this -> getLangage();
$this -> customer_backuri = HELP2PAY_CALLBACKURL."?lang=".$language; $this -> h2pCallbackURL = HELP2PAY_CALLBACKURL."?lang=".$language;
//$this -> customer_backuri = "http://requestbin.fullcontact.com/1fnoref1";
//SAVE TO DATABASE //SAVE TO DATABASE
$transactionNumber = $this -> customer_ref; $transactionNumber = $this -> referenceNo;
$HELP2PAY['Model'] = array();
$HELP2PAY['Model']['transaction_number'] = $this -> customer_ref; $this -> accessModify("INSERT_DEPOSIT_H2P_TEMP", [
$HELP2PAY['Model']['user_account'] = $this -> getUserData(PARAM_USER_ACCOUNT); $this -> referenceNo,
$HELP2PAY['Model']['amount'] = $this -> amount; $this -> getUserData(PARAM_USER_ACCOUNT),
$HELP2PAY['Model']['adjusted_amount'] = $this -> Formatamount; $this -> amount,
$HELP2PAY['Model']['currency'] = $this -> customer_currency; $this -> formattedAmount,
$HELP2PAY['Model']['method'] = 'Help2Pay'; $this -> currency,
$HELP2PAY['Model']['deposit_date'] = date("Y-m-d H:i:s"); VAL_STR_H2P_METHOD,
$HELP2PAY['Model']['deposit_bank'] = $this -> getDataPost('bank'); date("Y-m-d H:i:s"),
$HELP2PAY['Model']['fee'] = str_replace(",","",$this -> formatCurrency($this -> fee, $this -> currency)); $this -> getDataPost('bank'),
$HELP2PAY['Model']['message'] = "Local Bank Transfer (Southeast Asia)"; str_replace(",", NO_STRING, $this -> formatCurrency($this -> fee, $this -> currency)),
$HELP2PAY['Model']['comment'] = "via Front Page"; "Local Bank Transfer (Southeast Asia)",
$HELP2PAY['Model']['create_time'] = date("Y-m-d H:i:s"); "via Front Page",
$HELP2PAY['Model']['process_user'] = '9999'; date("Y-m-d H:i:s"),
$HELP2PAY['Model']['type'] = '0'; '9999',
$HELP2PAY['Model']['err_flg'] = '0'; NO_COUNT,
$HELP2PAY['Model']['status'] = '0'; NO_COUNT,
NO_COUNT
$sql = "insert into t_deposit_help2pay_temporary "; ]);
//进deposit表的sql方法
$strsql = $sqlObject->Insertsql($HELP2PAY['Model']);
$sql .= $strsql;
$sqlObject->query($sql);
// Need to set up the time as it error on third party // Need to set up the time as it error on third party
date_default_timezone_set('Asia/Manila'); date_default_timezone_set('Asia/Manila');
...@@ -2522,23 +2521,29 @@ class DepositModelClass extends ModelClassEx { ...@@ -2522,23 +2521,29 @@ class DepositModelClass extends ModelClassEx {
$customer_minutes = date('i:s A'); $customer_minutes = date('i:s A');
$this -> customer_date = $customer_year." ".$customer_Hour.":".$customer_minutes; $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 //SAVE LOGS
$apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api'; $apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api';
$requestUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P'.DIRECTORY_SEPARATOR.'deposit_request'; $requestUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P'.DIRECTORY_SEPARATOR.'deposit_request';
//check if directory exists if not, create directory //check if directory exists if not, create directory
if(!file_exists($requestUrl)) { if(!file_exists($requestUrl)) {
mkdir($requestUrl, 0777, true); mkdir($requestUrl, 0777, true);
} }
//log the transaction details //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); chmod($requestUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
// Get KEY // Get KEY
$customer_dateconverted = date('YmdHis'); $customer_data = $this -> h2pMerchantID
$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; .$this -> referenceNo
.$this -> userAccount
.$this -> customer_amount
.$this -> currency
.date('YmdHis')
.$this -> h2pSecurityCode
.$this -> ipAddress;
$this -> customer_key = md5($customer_data); $this -> customer_key = md5($customer_data);
$this -> customer_data = $customer_data; $this -> customer_data = $customer_data;
...@@ -2546,70 +2551,80 @@ class DepositModelClass extends ModelClassEx { ...@@ -2546,70 +2551,80 @@ class DepositModelClass extends ModelClassEx {
} else if($this -> getType() == TYPE_H2P_STATUS) { } else if($this -> getType() == TYPE_H2P_STATUS) {
unset($_SESSION['H2PCurrency']); unset($_SESSION['H2PCurrency']);
if($this -> getDataPost("Status") == null) { if($this -> getDataPost("Status") == NO_STRING) {
$this -> setType(''); $this -> setType('');
return; return;
} }
$this -> status = $this -> getDataPost("Status"); $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"); $this -> transationNumber = $this -> getDataPost("Reference");
//// GET data from temporary
$sqlstr = 'select * from t_deposit_help2pay_temporary where transaction_number = "'.$this -> transationNumber.'"'; switch($this -> status){
$result = $sqlObject -> query($sqlstr); case "000":
$row = $sqlObject -> fetch_assoc($result); case "006":{
if($this -> status == "000" || $this -> status == "006") { $tempRow = $this -> accessSelect("SELECT_DEPOSIT_H2P_TEMP", [$this -> getDataPost("Reference")]);
//// SAVE TO DATABASE
if(count($row) > 0){ if($this -> isLoopData($tempRow)){
$sqlstr2 = 'select * from t_deposit where transaction_number = "'.$this -> transationNumber.'"'; $tempRow = $this -> getRowData($tempRow);
$result2 = $sqlObject -> query($sqlstr2);
$row2 = $sqlObject -> fetch_assoc($result2); $processedTransaction = $this -> accessSelect("SELECT_DEPOSIT_BY_TRANSACTION_NUMBER", [$this -> getDataPost("Reference")]);
if($row2 == NULL){
$HELP2PAY['Model'] = array(); if(!$this -> isLoopData($processedTransaction)){
$HELP2PAY['Model']['transaction_number'] = $row['transaction_number']; $comment = "Bank:".$this -> getColumnData($tempRow, 'deposit_bank')
$HELP2PAY['Model']['user_account'] = $row['user_account']; .",Merchant:{$this -> getDataPost('Merchant')}"
$HELP2PAY['Model']['amount'] = $row['amount']; .",Status:{$this -> getDataPost('Status')}"
$HELP2PAY['Model']['currency'] = $row['currency']; .",Currency:{$this -> getDataPost('Currency')}"
$HELP2PAY['Model']['method'] = $row['method']; .",Amount:{$this -> getDataPost('Amount')}"
$HELP2PAY['Model']['isSendMail'] = '0'; .",Datetime:{$this -> getDataPost('Datetime')}"
$HELP2PAY['Model']['deposit_date'] = $row['deposit_date']; .",Customer:{$this -> getDataPost('Customer')}"
$HELP2PAY['Model']['deposit_bank'] = "Local Bank Transfer(Southeast Asia)"; .",Language:{$this -> getDataPost('Language')}"
$HELP2PAY['Model']['fee'] = "0"; .",Reference:{$this -> getDataPost('Reference')}"
$HELP2PAY['Model']['message'] = $row['message']; .",ID:{$this -> getDataPost('ID')}"
$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'); .",Key:{$this -> getDataPost('Key')}"
$HELP2PAY['Model']['create_time'] = $row['create_time']; .",Note:{$this -> getDataPost('Note')}";
$HELP2PAY['Model']['process_user'] = '9999';
$HELP2PAY['Model']['old_filename'] = ""; $toInsert = [
$HELP2PAY['Model']['new_filename'] = ""; $this -> getColumnData($tempRow, COLUMN_TRANSACTION_NUMBER),
$HELP2PAY['Model']['type'] = '0'; $this -> getColumnData($tempRow, COLUMN_USER_ACCOUNT),
$HELP2PAY['Model']['err_flg'] = '0'; $this -> getColumnData($tempRow, COLUMN_AMOUNT),
$HELP2PAY['Model']['msecond'] = "0"; $this -> getColumnData($tempRow, COLUMN_CURRENCY),
$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 -> getColumnData($tempRow, COLUMN_METHOD),
$sql = "insert into t_deposit"; "Local Bank Transfer(Southeast Asia)",
//进deposit表的sql方法 $this -> getColumnData($tempRow, COLUMN_DEPOSIT_DATE),
$strsql = $sqlObject->Insertsql($HELP2PAY['Model']); $this -> getColumnData($tempRow, COLUMN_FEE),
$sql .= $strsql; $comment,
$sqlObject->query($sql); $this -> getColumnData($tempRow, COLUMN_CREATE_TIME),
} NO_COUNT,
// Send Mail NO_COUNT,
$this -> setDeposit($this -> getRowData($this -> accessSelect('SELECT_DEPOSIT_BY_TRANSACTION_NUMBER', array($this -> transationNumber)))); "Local Bank Transfer(Southeast Asia)"
$this -> fee = $this -> intToCurrency(round(bcmul($row['amount'], VAL_STR_H2P_FEE, 4)),PERCENT); ];
// $this -> sendHelp2PaySuccessMail();
// $this -> accessModifyCommon('UPDATE_DEPOSIT_ISSENDMAIL',array($this -> transationNumber)); $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($row['amount'], VAL_STR_H2P_FEE, 4)),PERCENT); $this -> setDeposit($this -> getRowData($processedTransaction));
$this -> createTime = $row['create_time'];
$this -> amount = $row['amount']; $this -> fee = $this -> intToCurrency(
$this -> currency = $row['currency']; round(bcmul($this -> getColumnData($tempRow, COLUMN_AMOUNT),
$this -> transationNumber = $row['transaction_number']; VAL_STR_H2P_FEE, VAL_INT_4)), PERCENT);
} else if($this -> status == "009") { $this -> createTime = $this -> getColumnData($tempRow, COLUMN_CREATE_TIME);
$this -> setType(TYPE_H2P_PENDING); $this -> amount = $this -> getColumnData($tempRow, COLUMN_AMOUNT);
} else { $this -> currency = $this -> getColumnData($tempRow, COLUMN_CURRENCY);
$this -> sendHelp2PayFailMail(); $this -> transationNumber = $this -> getColumnData($tempRow, COLUMN_TRANSACTION_NUMBER);
$this -> setType(TYPE_H2P_FAIL);
$this -> sendHelp2PaySuccessMail();
}
break;
}
case "009":
$this -> setType(TYPE_H2P_PENDING);
break;
default:
$this -> sendHelp2PayFailMail();
$this -> setType(TYPE_H2P_FAIL);
break;
} }
}else if($this -> getType() == TYPE_CPS_INPUT }else if($this -> getType() == TYPE_CPS_INPUT
|| $this -> getType() == TYPE_CPS_CONFIRM || $this -> getType() == TYPE_CPS_CONFIRM
|| $this -> getType() == TYPE_CPS_COMPLETE || $this -> getType() == TYPE_CPS_COMPLETE
...@@ -2640,7 +2655,6 @@ class DepositModelClass extends ModelClassEx { ...@@ -2640,7 +2655,6 @@ class DepositModelClass extends ModelClassEx {
return; return;
} }
} }
} }
if($this -> getType() == TYPE_CPS_BACK){ if($this -> getType() == TYPE_CPS_BACK){
...@@ -2648,7 +2662,6 @@ class DepositModelClass extends ModelClassEx { ...@@ -2648,7 +2662,6 @@ class DepositModelClass extends ModelClassEx {
return; return;
} }
if($this -> getType() == TYPE_CPS_CONFIRM){ if($this -> getType() == TYPE_CPS_CONFIRM){
// Validate amount if its a number // Validate amount if its a number
if (!is_numeric($this -> amount)) { if (!is_numeric($this -> amount)) {
...@@ -2686,10 +2699,8 @@ class DepositModelClass extends ModelClassEx { ...@@ -2686,10 +2699,8 @@ class DepositModelClass extends ModelClassEx {
$_SESSION['CPS']['amount'] = $this -> amount; $_SESSION['CPS']['amount'] = $this -> amount;
$_SESSION['CPS']['fee'] = $this -> fee; $_SESSION['CPS']['fee'] = $this -> fee;
$_SESSION['CPS']['Actual'] = $totalDepositAmount; $_SESSION['CPS']['Actual'] = $totalDepositAmount;
} }
//if type is send //if type is send
if($this -> getType() == TYPE_CPS_SEND) { if($this -> getType() == TYPE_CPS_SEND) {
$apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api'; $apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api';
...@@ -2847,17 +2858,17 @@ class DepositModelClass extends ModelClassEx { ...@@ -2847,17 +2858,17 @@ class DepositModelClass extends ModelClassEx {
$member = $this -> getRowData($this -> getAccountCommon($this -> getUserData(PARAM_USER_ACCOUNT)), 0); $member = $this -> getRowData($this -> getAccountCommon($this -> getUserData(PARAM_USER_ACCOUNT)), 0);
$snaps -> setDepositDetails([ $snaps -> setDepositDetails([
"firstName" => $member[PARAM_FIRST_NAME], "firstName" => $this -> getColumnData($member, PARAM_FIRST_NAME),
"lastName" => $member[PARAM_LAST_NAME], "lastName" => $this -> getColumnData($member, PARAM_LAST_NAME),
"company" => "iWallet Limited", "company" => "iWallet Limited",
"address1" => $member[PARAM_ADDRESS], "address1" => $this -> getColumnData($member, PARAM_ADDRESS),
"address2" => $member[PARAM_ADDRESS], "address2" => $this -> getColumnData($member, PARAM_ADDRESS),
"mobile" => $member[PARAM_TEL], "mobile" => $this -> getColumnData($member, PARAM_TEL),
"city" => $member[PARAM_CITY], "city" => $this -> getColumnData($member, PARAM_CITY),
"province" => $member[PARAM_STATE], "province" => $this -> getColumnData($member, PARAM_STATE),
"zip" => $member[PARAM_ZIP_CODE], "zip" => $this -> getColumnData($member, PARAM_ZIP_CODE),
"country" => $member[PARAM_COUNTRY], "country" => $this -> getColumnData($member, PARAM_COUNTRY),
"email" => $member[PARAM_MAIL], "email" => $this -> getColumnData($member, PARAM_MAIL),
"itemName" => "Credit Card Deposit Transaction", "itemName" => "Credit Card Deposit Transaction",
"depositAmount" => $this -> amount, "depositAmount" => $this -> amount,
"currency" => $this -> currency, "currency" => $this -> currency,
...@@ -2870,7 +2881,7 @@ class DepositModelClass extends ModelClassEx { ...@@ -2870,7 +2881,7 @@ class DepositModelClass extends ModelClassEx {
$logFile = SITE_ROOT."api/Logs/APN/Log_D".date("Y-m-d").".log"; $logFile = SITE_ROOT."api/Logs/APN/Log_D".date("Y-m-d").".log";
$resultObject = json_decode($result); $resultObject = json_decode($result);
$resultObject -> userAccount = $member[PARAM_USER_ACCOUNT]; $resultObject -> userAccount = $this -> getColumnData($member, PARAM_USER_ACCOUNT);
$resultObject -> depositAmount = "{$this -> currency} {$this -> amount}"; $resultObject -> depositAmount = "{$this -> currency} {$this -> amount}";
$msgtime = date("Y-m-d H:i:s"); $msgtime = date("Y-m-d H:i:s");
...@@ -4045,46 +4056,47 @@ class DepositModelClass extends ModelClassEx { ...@@ -4045,46 +4056,47 @@ class DepositModelClass extends ModelClassEx {
} }
} }
/// HELP2PAY /// HELP2PAY
public function GetRedirectURLHelp2Pay() { public function GetRedirectURLHelp2Pay() {
$language = $this -> getLangage(); $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; //echo this-> $redirectURL;
// $redirectURL = "http://localhost/en/deposit?type=h2p_status"; // $redirectURL = "http://localhost/en/deposit?type=h2p_status";
echo $redirectURL; echo $redirectURL;
} }
public function GetSendInformationH2P($Type) { public function GetSendInformationH2P($Type) {
if($Type == "Merchant") { if($Type == "Merchant") {
echo $this-> customer_merchant; echo $this -> h2pMerchantID;
} else if($Type == "Currency") { } else if($Type == "Currency") {
echo $this-> customer_currency; echo $this-> currency;
} else if($Type == "Customer") { } else if($Type == "Customer") {
echo $this-> customer_name; echo $this-> userAccount;
} else if($Type == "Reference") { } else if($Type == "Reference") {
echo $this-> customer_ref; echo $this-> referenceNo;
} else if($Type == "Key") { } else if($Type == "Key") {
echo $this-> customer_key; echo $this-> customer_key;
} else if($Type == "Amount") { } else if($Type == "Amount") {
echo $this-> customer_amount; echo $this-> customer_amount;
} else if($Type == "Note") { } else if($Type == "Note") {
echo $this-> customer_note; echo $this-> customer_note;
} else if($Type == "DateTime") { } else if($Type == "DateTime") {
echo $this-> customer_date; echo $this-> customer_date;
} else if($Type == "BackURI") { } else if($Type == "BackURI") {
echo $this-> customer_backuri; echo $this-> h2pCallbackURL;
} else if($Type == "language") { } else if($Type == "language") {
echo $this-> customer_language; echo $this-> customer_language;
} else if($Type == "bank") { } else if($Type == "bank") {
echo $this-> customer_bank; echo $this-> bank;
} else if($Type == "ClientIP") { } else if($Type == "ClientIP") {
echo $this-> customer_ip_address; echo $this-> ipAddress;
} else if($Type == "CustomerData") { } else if($Type == "CustomerData") {
echo $this-> customer_data; echo $this-> customer_data;
} else if($Type == "H2PURL") { } else if($Type == "H2PURL") {
echo $this-> h2p_url; echo $this -> h2pTransferUrl;
} }
} }
public function displayLocalBankListPerCurrency() { public function displayLocalBankListPerCurrency() {
$currency = $this -> currency; $currency = $this -> currency;
$selected = NO_STRING; $selected = NO_STRING;
...@@ -4143,57 +4155,56 @@ class DepositModelClass extends ModelClassEx { ...@@ -4143,57 +4155,56 @@ class DepositModelClass extends ModelClassEx {
return 0; return 0;
} }
private function getSendHelp2PaySuccessData() { private function getSendHelp2PaySuccessData() {
// 変数宣言部 // 変数宣言部
$rtn = array(); $rtn = array();
$account = $this -> getColumnData($this -> deposit, COLUMN_USER_ACCOUNT); $account = $this -> getColumnData($this -> deposit, COLUMN_USER_ACCOUNT);
// パラメータの設定 // パラメータの設定
$rtn[] = $account; // 口座番号(1) $rtn[] = $account; // 口座番号(1)
$rtn[] = $this -> getNameCommon($account); // 氏名(2) $rtn[] = $this -> getNameCommon($account); // 氏名(2)
$rtn[] = $this -> transationNumber; // 取引番号(3) $rtn[] = $this -> transationNumber; // 取引番号(3)
$rtn[] = $this -> createTime; // 取引時刻(4) $rtn[] = $this -> createTime; // 取引時刻(4)
$rtn[] = $this -> currency; // 決済通貨(5) $rtn[] = $this -> currency; // 決済通貨(5)
$rtn[] = $this -> getAmountString($this -> amount, $this -> currency); // 決済金額(6) $rtn[] = $this -> getAmountString($this -> amount, $this -> currency); // 決済金額(6)
$rtn[] = $this -> currency; // 反映通貨(7) $rtn[] = $this -> currency; // 反映通貨(7)
$rtn[] = $this -> getAmountString(($this -> amount + $this -> fee), $this -> currency); // 反映金額(8) $rtn[] = $this -> getAmountString(($this -> amount + $this -> fee), $this -> currency); // 反映金額(8)
$rtn[] = $this -> CallUserData(PARAM_COUNTRY); $rtn[] = $this -> CallUserData(PARAM_COUNTRY);
return $rtn; return $rtn;
} }
private function sendHelp2PaySuccessMail(){
$params = '';
// 変数宣言部
$params = $this -> getSendHelp2PaySuccessData();
// メールを送信(ユーザ)
$this -> sendMailByTmp('help2pay_deposit_info.xml'
, $params
, $this -> getEMailCommon($this -> getColumnData($params, NO_COUNT))
, VAR_CS_MAIL_ADDRESS
, $this -> getLangage());
}
private function getSendHelp2PayFailData() {
// 変数宣言部
$rtn = array();
$rtn[] = $this -> getUserData(PARAM_USER_ACCOUNT); // 口座番号
$rtn[] = $this -> getNameCommon($this -> getUserData(PARAM_USER_ACCOUNT)); // 氏名
return $rtn;
}
private function sendHelp2PayFailMail(){
$params = '';
// 変数宣言部
$params = $this -> getSendHelp2PayFailData();
// メールを送信(ユーザ)
$this -> sendMailByTmp('help2pay_deposit_info_fail.xml'
, $params
, $this -> getEMailCommon($this -> getColumnData($params, NO_COUNT))
, VAR_CS_MAIL_ADDRESS
, $this -> getLangage());
}
private function sendHelp2PaySuccessMail(){
$params = '';
// 変数宣言部
$params = $this -> getSendHelp2PaySuccessData();
// メールを送信(ユーザ)
$this -> sendMailByTmp('help2pay_deposit_info.xml'
, $params
, $this -> getEMailCommon($this -> getColumnData($params, NO_COUNT))
, VAR_CS_MAIL_ADDRESS
, $this -> getLangage());
}
private function getSendHelp2PayFailData() {
// 変数宣言部
$rtn = array();
$rtn[] = $this -> getUserData(PARAM_USER_ACCOUNT); // 口座番号
$rtn[] = $this -> getNameCommon($this -> getUserData(PARAM_USER_ACCOUNT)); // 氏名
return $rtn;
}
private function sendHelp2PayFailMail(){
$params = '';
// 変数宣言部
$params = $this -> getSendHelp2PayFailData();
// メールを送信(ユーザ)
$this -> sendMailByTmp('help2pay_deposit_info_fail.xml'
, $params
, $this -> getEMailCommon($this -> getColumnData($params, NO_COUNT))
, VAR_CS_MAIL_ADDRESS
, $this -> getLangage());
}
private function sendZanetapaySuccessMail(){ private function sendZanetapaySuccessMail(){
$params = ''; $params = '';
......
...@@ -67,7 +67,6 @@ class WithdrawModelClass extends ModelClassEx { ...@@ -67,7 +67,6 @@ class WithdrawModelClass extends ModelClassEx {
// チェック // チェック
$this -> validate(); $this -> validate();
} catch (Exception $e) { } catch (Exception $e) {
throw $e; throw $e;
} }
...@@ -2141,26 +2140,25 @@ class WithdrawModelClass extends ModelClassEx { ...@@ -2141,26 +2140,25 @@ class WithdrawModelClass extends ModelClassEx {
} }
public function getOutStatus() public function getOutStatus()
{ {
$account = $this->getUserData(PARAM_USER_ACCOUNT); $account = $this->getUserData(PARAM_USER_ACCOUNT);
$rs = $this -> getAccountCommon($account); $rs = $this -> getAccountCommon($account);
$row = $this -> getRowData($rs); $row = $this -> getRowData($rs);
$accountType = $this -> getColumnData($row, COLUMN_ACCOUNT_TYPE); $accountType = $this -> getColumnData($row, COLUMN_ACCOUNT_TYPE);
$rtn = array(); $rtn = array();
$array_list_IBT = array( $array_list_IBT = array(
'81691034',//Restine '81691034',//Restine
'42156169'// New iWallet 会計用 Corporate '42156169'// New iWallet 会計用 Corporate
); );
if(in_array($this->getUserData(PARAM_USER_ACCOUNT), $array_list_IBT)){ if(in_array($this->getUserData(PARAM_USER_ACCOUNT), $array_list_IBT)){
$method = getOutMoney(); $method = getOutMoney();
} else { } else {
$method = getOouMoney(); $method = getOouMoney();
} }
$lang = $this -> getLangage(); $lang = $this -> getLangage();
foreach ($method as $key => $value) { 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)); $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 { ...@@ -2686,91 +2684,102 @@ class WithdrawModelClass extends ModelClassEx {
public function sendH2PRequest(){ public function sendH2PRequest(){
$language = $this -> getLangage(); $language = $this -> getLangage();
//prep log path //prep log path
$apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api'; $apiPath = dirname(SYSTEM_PATH).DIRECTORY_SEPARATOR.'api';
$errorUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P_Withdrawal'.DIRECTORY_SEPARATOR.'sending_request'.DIRECTORY_SEPARATOR.'error'; $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'; $requestUrl = $apiPath.DIRECTORY_SEPARATOR.'Logs'.DIRECTORY_SEPARATOR.'H2P_Withdrawal'.DIRECTORY_SEPARATOR.'sending_request'.DIRECTORY_SEPARATOR.'request';
//require api file //require api file
include $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'api'.DIRECTORY_SEPARATOR.'help2PayAPI.php'; include $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR.'api'.DIRECTORY_SEPARATOR.'help2PayAPI.php';
//instantiate api class //instantiate api class
$help2PayAPI = new help2PayAPI(); $help2PayAPI = new help2PayAPI();
//start request //start request
$data = array( $data = array(
'TransactionID' => $this -> transactionId, 'TransactionID' => $this -> transactionId,
'CurrencyCode' => $this -> currency, 'CurrencyCode' => $this -> currency,
'MemberCode' => $this -> getUserData(PARAM_USER_ACCOUNT), 'MemberCode' => $this -> getUserData(PARAM_USER_ACCOUNT),
'Amount' => number_format((float)$this -> amount, 2, '.', ''), 'Amount' => number_format((float)$this -> amount, 2, '.', ''),
'TransactionDateTime' => date('YmdHis'), 'TransactionDateTime' => date('YmdHis'),
'TransactionDateTime2' => date('Y-m-d h:i:sA'), 'TransactionDateTime2' => date('Y-m-d h:i:sA'),
'BankCode' => $this -> receiptBankName, 'BankCode' => $this -> receiptBankName,
'toBankAccountName' => $this -> accountName, 'toBankAccountName' => $this -> accountName,
'toBankAccountNumber' => $this -> accountNumber, 'toBankAccountNumber' => $this -> accountNumber,
); );
$raw = NO_STRING;
//generate key //generate key
$key = $help2PayAPI -> generateKey($data); $key = $help2PayAPI -> generateKey($data, $raw);
//save key to db //save key to db
$param = array(); $param = array();
$param[] = $this -> transactionId; $param[] = $this -> transactionId;
$param[] = $key; $param[] = $key;
$param[] = $language; $param[] = $language;
$param[] = $this -> receiptBankName; $param[] = $this -> receiptBankName;
$this->accessModify('UPDATE_WITHDRAW_H2P_KEY', $param); $this -> accessModify('UPDATE_WITHDRAW_H2P_KEY', $param);
//send request //send request
$requestData = $help2PayAPI -> generateRequestData($data, $key); //generate request data $requestData = $help2PayAPI -> generateRequestData($data, $key); //generate request data
$requestDataLog = implode(" ", $requestData); //generate request data log $requestDataLog = implode(" ", $requestData); //generate request data log
$res = $help2PayAPI -> submitPayoutRequest($requestData); //create channel $res = $help2PayAPI -> submitPayoutRequest($requestData); //create channel
//check if create request is successful //check if create request is successful
if($res != NULL) { if($res != NULL) {
$xml = new SimpleXMLElement($res);
$xml = new SimpleXMLElement($res); $statusCode = $xml->statusCode;
$statusCode = $xml->statusCode; $message = $xml->message;
$message = $xml->message; $date = date('Y-m-d H:i:s'); //created date
$date = date('Y-m-d H:i:s'); //created date
if($statusCode == 000) {
if($statusCode == 000) { if(!file_exists($requestUrl)) {
if(!file_exists($requestUrl)) { mkdir($requestUrl, 0777, true);
mkdir($requestUrl, 0777, true); }
}
error_log("[{$date}]\r\nREQUEST:\r\n\r\n{$requestDataLog}\r\n\r\n\r\n\r\n",
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'); VAL_INT_3,
chmod($requestUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511); $requestUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
return true; chmod($requestUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log', 511);
}elseif($statusCode == 001){
if(!file_exists($errorUrl)) { return true;
mkdir($errorUrl, 0777, 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);
error_log("\n\n".print_r($requestData, true)."\n\n".print_r($res, true)."\n\n{$raw}\n\n{$key}",
return false; VAL_INT_3,
}else{ $errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
//logerror of invalid statuscode
if(!file_exists($errorUrl)) { error_log("[{$date}]\r\nERROR:{$this -> transactionId}\r\n\r\nMessage:\r\n{$message}\r\n\r\n\r\n\r\n",
mkdir($errorUrl, 0777, true); VAL_INT_3,
} $errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log');
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);
chmod($errorUrl.DIRECTORY_SEPARATOR.'Log_'.date("Y-m-d").'.log',511);
return false;
return false; }else{
} //logerror of invalid statuscode
} else { //create request failed if(!file_exists($errorUrl)) {
$this -> popUpSessionMessage(ERROR, 'E_ERROR_H2P_API_NULL', array()); mkdir($errorUrl, 0777, true);
$this -> setType(TYPE_WITHDRAW_H2P_INPUT); }
return;
} 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'); ...@@ -371,10 +371,19 @@ define('TYPE_H2P_STATUS', 'h2p_status');
define('TYPE_H2P_FAIL', 'h2p_fail'); define('TYPE_H2P_FAIL', 'h2p_fail');
define('TYPE_H2P_PENDING', 'h2p_pending'); define('TYPE_H2P_PENDING', 'h2p_pending');
define('TYPE_H2P_NOTICE_KYC', 'h2p_notice_kyc'); define('TYPE_H2P_NOTICE_KYC', 'h2p_notice_kyc');
define('HELP2PAY_URL','https://api.racethewind.net/MerchantTransfer'); define('HELP2PAY_CALLBACKURL', SITE_PROTOCOL.'://'.SITE_DOMAIN_FULL.'/api/H2PDepositWebhook.php');
define('HELP2PAY_CUSTOMERMERCHANT','M0103');
define('HELP2PAY_SECURITYCODE','FJCfJRGRZDXSX7j'); //Help2Pay withdrawal type constants start
define('HELP2PAY_CALLBACKURL', 'https://secure.'.SITE_DOMAIN.'/api/help2pay_webhook.php'); 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 //admin user
define('TYPE_ADMIN_USER_SEARCH_ALL', 'admin_user_search_all'); define('TYPE_ADMIN_USER_SEARCH_ALL', 'admin_user_search_all');
...@@ -395,21 +404,6 @@ define('TYPE_EXPORT_ADMIN_FAIL_LIST', 'export_admin_fail_list'); ...@@ -395,21 +404,6 @@ define('TYPE_EXPORT_ADMIN_FAIL_LIST', 'export_admin_fail_list');
define('VAL_STR_BIT_FEE_VAL','3.50'); 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 //NEW SD API
define('SD_MERCHANT_CODE', 'M1000100'); define('SD_MERCHANT_CODE', 'M1000100');
define('SD_PUBLIC_KEY', '-----BEGIN PUBLIC KEY----- define('SD_PUBLIC_KEY', '-----BEGIN PUBLIC KEY-----
......
...@@ -11721,7 +11721,7 @@ WHERE ...@@ -11721,7 +11721,7 @@ WHERE
) )
</INSERT_TEMP_CCDEPOSIT> </INSERT_TEMP_CCDEPOSIT>
<INSERT_CC_DEPOSIT_TRANSACTION> <INSERT_WB_DEPOSIT_TRANSACTION>
INSERT into t_deposit ( INSERT into t_deposit (
transaction_number, transaction_number,
user_account, user_account,
...@@ -11737,21 +11737,21 @@ WHERE ...@@ -11737,21 +11737,21 @@ WHERE
err_flg, err_flg,
message message
) values ( ) values (
__ELEMENT01__, '__ELEMENT01__',
__ELEMENT02__, '__ELEMENT02__',
__ELEMENT03__, '__ELEMENT03__',
__ELEMENT04__, '__ELEMENT04__',
__ELEMENT05__, '__ELEMENT05__',
__ELEMENT06__, '__ELEMENT06__',
__ELEMENT07__, '__ELEMENT07__',
__ELEMENT08__, '__ELEMENT08__',
__ELEMENT09__, '__ELEMENT09__',
__ELEMENT10__, '__ELEMENT10__',
__ELEMENT11__, '__ELEMENT11__',
__ELEMENT12__, '__ELEMENT12__',
__ELEMENT13__ '__ELEMENT13__'
) )
</INSERT_CC_DEPOSIT_TRANSACTION> </INSERT_WB_DEPOSIT_TRANSACTION>
<UPDATE_TEMP_CCDEPOSIT> <UPDATE_TEMP_CCDEPOSIT>
UPDATE t_deposit_credit_card_temporary UPDATE t_deposit_credit_card_temporary
...@@ -13433,6 +13433,56 @@ WHERE ...@@ -13433,6 +13433,56 @@ WHERE
transaction_time transaction_time
</LIST_USER_TRANSACTION_FOR_SUSPENSION_CHECKING> </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_WITHDRAW_H2P_TEMP>
SELECT 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