-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathExternalConfiguration.php
90 lines (82 loc) · 3.92 KB
/
ExternalConfiguration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/*
* Purpose : passing Authentication config object to the configuration
*/
namespace CyberSource;
require_once __DIR__. DIRECTORY_SEPARATOR .'../vendor/autoload.php';
class ExternalConfiguration
{
//initialize variable on constructor
function __construct()
{
$this->authType = "http_signature";//http_signature/jwt
$this->enableLog = true;
$this->logSize = "1048576";
$this->logFile = "Log";
$this->logFilename = "Cybs.log";
$this->merchantID = "testrest";
$this->apiKeyID = "08c94330-f618-42a3-b09d-e1e43be5efda";
$this->secretKey = "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE=";
$this->keyAlias = "testrest";
$this->keyPass = "testrest";
$this->keyFilename = "testrest";
$this->keyDirectory = "Resources/";
$this->runEnv = "cyberSource.environment.SANDBOX";
$this->merchantConfigObject();
}
//creating merchant config object
function merchantConfigObject()
{
$config = new \CyberSource\Authentication\Core\MerchantConfiguration();
if(is_bool($this->enableLog))
$confiData = $config->setDebug($this->enableLog);
$confiData = $config->setLogSize(trim($this->logSize));
$confiData = $config->setDebugFile(trim(__DIR__. DIRECTORY_SEPARATOR."../".$this->logFile));
$confiData = $config->setLogFileName(trim($this->logFilename));
$confiData = $config->setauthenticationType(strtoupper(trim($this->authType)));
$confiData = $config->setMerchantID(trim($this->merchantID));
$confiData = $config->setApiKeyID($this->apiKeyID);
$confiData = $config->setSecretKey($this->secretKey);
$confiData = $config->setKeyFileName(trim($this->keyFilename));
$confiData = $config->setKeyAlias($this->keyAlias);
$confiData = $config->setKeyPassword($this->keyPass);
$confiData = $config->setKeysDirectory(__DIR__. DIRECTORY_SEPARATOR."../".$this->keyDirectory);
$confiData = $config->setRunEnvironment($this->runEnv);
$config->validateMerchantData($confiData);
return $config;
}
function ConnectionHost()
{
$merchantConfig = $this->merchantConfigObject();
$config = new Configuration();
$config = $config->setHost($merchantConfig->getHost());
$config = $config->setDebug($merchantConfig->getDebug());
$config = $config->setDebugFile($merchantConfig->getDebugFile().DIRECTORY_SEPARATOR.$merchantConfig->getLogFileName());
return $config;
}
function FutureDate($format){
if($format){
$rdate = date("Y-m-d",strtotime("+7 days"));
$retDate = date($format,strtotime($rdate));
}
else{
$retDate = date("Y-m",strtotime("+7 days"));
}
echo $retDate;
return $retDate;
}
function CallTestLogging($testId, $apiName, $assertMessage, $inputMessage){
$runtime = date('d-m-Y H:i:s');
$file = fopen("./SamplesQA/CSV_Files/TestReport/TestResults.csv", "a+");
fputcsv($file, array($testId, $apiName, $assertMessage, $inputMessage, $runtime));
fclose($file);
}
function downloadReport($downloadData, $fileName){
$filePathName = __DIR__. DIRECTORY_SEPARATOR .$fileName;
$file = fopen($filePathName, "w");
fwrite($file, $downloadData);
fclose($file);
return __DIR__.'\\'.$fileName;
}
}
?>