-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathConfig.php
More file actions
175 lines (143 loc) · 3.7 KB
/
Config.php
File metadata and controls
175 lines (143 loc) · 3.7 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
namespace PayTech;
use PayTech\Enums\Currency;
use PayTech\Enums\Environment;
use PayTech\Utils\Check;
use PayTech\Exceptions\CurrencyException;
/**
*
* @author PapiHack
* @since 07/2020
*
*/
abstract class Config extends PayTech
{
const ROOT_URL_BASE = "https://paytech.sn";
const PAYMENT_REQUEST_PATH = '/api/payment/request-payment';
const PAYMENT_REDIRECT_PATH = '/payment/checkout/';
const MOBILE_CANCEL_URL = "https://paytech.sn/mobile/cancel";
const MOBILE_SUCCESS_URL = "https://paytech.sn/mobile/success";
private static $apiKey;
private static $apiSecret;
private static $currency = Currency::XOF;
private static $liveMode = true;
private static $testMode = false;
private static $isMobile = false;
private static $ipnUrl;
private static $successUrl;
private static $cancelUrl;
private static $env = Environment::PROD;
public static function getApiKey()
{
return self::$apiKey;
}
public static function getApiSecret()
{
return self::$apiSecret;
}
public static function getCurrency()
{
return strtolower(self::$currency);
}
public static function getLiveMode()
{
return self::$liveMode;
}
public static function getTestMode()
{
return self::$testMode;
}
public static function getIsMobile()
{
return self::$isMobile;
}
public static function getIpnUrl()
{
return self::$ipnUrl;
}
public static function getSuccessUrl()
{
return self::$successUrl;
}
public static function getCancelUrl()
{
return self::$cancelUrl;
}
public static function getEnv()
{
return strtolower(self::$env);
}
public static function setApiKey($apiKey)
{
self::$apiKey = $apiKey;
}
public static function setApiSecret($apiSecret)
{
self::$apiSecret = $apiSecret;
}
public static function setCurrency($currency)
{
if (Check::isCurrencyAllowed($currency))
{
self::$currency = $currency;
}
else
{
throw new CurrencyException("That Currency is not allowed for the moment... Sorry :(", -99);
}
}
// @codeCoverageIgnoreStart
private static function setLiveMode($liveMode)
{
self::$liveMode = $liveMode;
self::$testMode = !$liveMode;
}
// @codeCoverageIgnoreEnd
private static function setTestMode($testMode)
{
self::$testMode = $testMode;
self::$liveMode = !$testMode;
}
public static function setIsMobile($isMobile)
{
self::$isMobile = $isMobile;
}
public static function setIpnUrl($ipnUrl)
{
self::$ipnUrl = $ipnUrl;
}
public static function setSuccessUrl($successUrl)
{
self::$successUrl = $successUrl;
}
public static function setCancelUrl($cancelUrl)
{
self::$cancelUrl = $cancelUrl;
}
public static function setEnv($env)
{
if (Check::isEnvAllowed($env))
{
self::$env = strtolower($env);
self::setApproriateLiveAndTestMode();
}
else
{
throw new \Exception('The '. $env. ' is not allowed. Please chose between test or prod !');
}
}
// @codeCoverageIgnoreStart
private static function setApproriateLiveAndTestMode()
{
switch (self::getEnv())
{
case 'test':
self::setTestMode(true);
break;
case 'prod':
self::setLiveMode(true);
break;
}
}
// @codeCoverageIgnoreEnd
}