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

Dynamic Payment API Error Code Formatting

parent 91db4f60
......@@ -164,41 +164,41 @@ class Settle extends System {
$this -> logDetails(print_r($accessArray, true));
if(strcasecmp($this -> requestType, "POST") !== 0){
$this -> invalid[] = "Invalid Request Type [{$this -> requestType}]";
$this -> invalid["DERR1"] = "Invalid Request Type [{$this -> requestType}]";
}
if($this -> contentType != "application/json"){
$this -> invalid[] = "Invalid Content Type [{$this -> contentType}]";
$this -> invalid["DERR2"] = "Invalid Content Type [{$this -> contentType}]";
}
if($this -> checkJSONString($this -> payload)){
if($this -> currency != NO_STRING){
if(!$this -> checkCurrency(strtoupper($this -> currency)))
$this -> invalid[] = "Invalid Currency [{$this -> currency}]";
$this -> invalid["DERR3"] = "Invalid Currency [{$this -> currency}]";
}else
$this -> invalid[] = "Currency is required";
$this -> invalid["DERR4"] = "Currency is required";
if($this -> amount != NO_STRING){
if($this -> amount == NO_COUNT){
$this -> invalid[] = "Amount cannot be 0";
$this -> invalid["DERR5"] = "Amount cannot be 0";
}
if(!$this -> checkStringNumber($this -> amount)){
$this -> invalid[] = "Invalid Inputted Amount.";
$this -> invalid["DERR6"] = "Invalid Inputted Amount.";
}
}else
$this -> invalid[] = "Amount is required";
$this -> invalid["DERR7"] = "Amount is required";
if($this -> language != NO_STRING){
$languages = ["en", "ja", "tc", "sc", "id"];
$this -> language = strtolower($this -> language);
if(!in_array($this -> language, $languages)){
$this -> invalid[] = "The Settlement Feature is not available to the language you've specified. [{$this -> language}]";
$this -> invalid["DERR8"] = "The Settlement Feature is not available to the language you've specified. [{$this -> language}]";
}
}else
$this -> invalid[] = "Language is required";
$this -> invalid["DERR9"] = "Language is required";
if($this -> pnum != NO_STRING){
$apiSignature = $this -> getRowData($this -> getAPISignatureCommon($this -> pnum));
......@@ -210,7 +210,7 @@ class Settle extends System {
$this -> pnum,
$this -> signature,
$userAccount)){
$this -> invalid[] = "Invalid Settlement Signature";
$this -> invalid["DERR10"] = "Invalid Settlement Signature";
}
$wlistSettings = $this -> getColumnData($apiSignature, COLUMN_WHITELIST_SETTING);
......@@ -222,25 +222,34 @@ class Settle extends System {
$ipAddresses = explode(",", $this -> getColumnData($apiSignature, "ip_address"));
if(!in_array($this -> ipAddress, $ipAddresses))
$this -> invalid[] = "Invalid IP Address [{$this -> ipAddress}]";
$this -> invalid["DERR11"] = "Invalid IP Address [{$this -> ipAddress}]";
}
if(!$this -> getColumnData($wlistSettings, "allow_curl_in_payment")){
$this -> invalid[] = "Authentication Denied for this Program Code.";
$this -> invalid["DERR12"] = "Authentication Denied for this Program Code.";
}
}
}else
$this -> invalid[] = "Invalid Program Code";
$this -> invalid["DERR13"] = "Invalid Program Code";
}else
$this -> invalid[] = "Program Code is required";
$this -> invalid["DERR14"] = "Program Code is required";
}else
$this -> invalid[] = "Invalid Payload Format";
$this -> invalid["DERR15"] = "Invalid Payload Format";
if($this -> isLoopData($this -> invalid)){
$this -> logDetails("Settlement Request Denied: ".print_r($this -> invalid, true));
header("HTTP/1.1 401 Unauthenticated");
die(print_r($this -> invalid, true));
$errorTraces = [];
foreach($this -> invalid as $errcode => $description){
$errorTraces[] = [
"errcode" => $errcode,
"description" => $description
];
}
die(json_encode($errorTraces));
}
}
......
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