@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | public static function init() |
47 | 47 | { |
48 | - require_once "loader" . DIRECTORY_SEPARATOR . "PagSeguroAutoLoader.class.php"; |
|
48 | + require_once "loader".DIRECTORY_SEPARATOR."PagSeguroAutoLoader.class.php"; |
|
49 | 49 | self::verifyDependencies(); |
50 | 50 | if (self::$library == null) { |
51 | 51 | self::$library = new PagSeguroLibrary(); |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | |
61 | 61 | try { |
62 | 62 | |
63 | - if (!function_exists('curl_init')) { |
|
63 | + if ( ! function_exists('curl_init')) { |
|
64 | 64 | $dependencies = false; |
65 | 65 | throw new Exception('PagSeguroLibrary: cURL library is required.'); |
66 | 66 | } |
67 | 67 | |
68 | - if (!class_exists('DOMDocument')) { |
|
68 | + if ( ! class_exists('DOMDocument')) { |
|
69 | 69 | $dependencies = false; |
70 | 70 | throw new Exception('PagSeguroLibrary: DOM XML extension is required.'); |
71 | 71 | } |
@@ -24,99 +24,99 @@ |
||
24 | 24 | class PagSeguroLibrary |
25 | 25 | { |
26 | 26 | |
27 | - const VERSION = "2.5.0"; |
|
28 | - public static $resources; |
|
29 | - public static $config; |
|
30 | - public static $log; |
|
31 | - private static $path; |
|
32 | - private static $library; |
|
33 | - private static $module_version; |
|
34 | - private static $cms_version; |
|
35 | - private static $php_version; |
|
36 | - |
|
37 | - private function __construct() |
|
38 | - { |
|
39 | - self::$path = (dirname(__FILE__)); |
|
40 | - PagSeguroAutoloader::init(); |
|
41 | - self::$resources = PagSeguroResources::init(); |
|
42 | - self::$config = PagSeguroConfig::init(); |
|
43 | - self::$log = LogPagSeguro::init(); |
|
44 | - } |
|
45 | - |
|
46 | - public static function init() |
|
47 | - { |
|
48 | - require_once "loader" . DIRECTORY_SEPARATOR . "PagSeguroAutoLoader.class.php"; |
|
49 | - self::verifyDependencies(); |
|
50 | - if (self::$library == null) { |
|
51 | - self::$library = new PagSeguroLibrary(); |
|
52 | - } |
|
53 | - return self::$library; |
|
54 | - } |
|
55 | - |
|
56 | - private static function verifyDependencies() |
|
57 | - { |
|
58 | - |
|
59 | - $dependencies = true; |
|
60 | - |
|
61 | - try { |
|
62 | - |
|
63 | - if (!function_exists('curl_init')) { |
|
64 | - $dependencies = false; |
|
65 | - throw new Exception('PagSeguroLibrary: cURL library is required.'); |
|
66 | - } |
|
67 | - |
|
68 | - if (!class_exists('DOMDocument')) { |
|
69 | - $dependencies = false; |
|
70 | - throw new Exception('PagSeguroLibrary: DOM XML extension is required.'); |
|
71 | - } |
|
72 | - |
|
73 | - } catch (Exception $e) { |
|
74 | - return $dependencies; |
|
75 | - } |
|
76 | - |
|
77 | - return $dependencies; |
|
78 | - |
|
79 | - } |
|
80 | - |
|
81 | - final public static function getVersion() |
|
82 | - { |
|
83 | - return self::VERSION; |
|
84 | - } |
|
85 | - |
|
86 | - final public static function getPath() |
|
87 | - { |
|
88 | - return self::$path; |
|
89 | - } |
|
90 | - |
|
91 | - final public static function getModuleVersion() |
|
92 | - { |
|
93 | - return self::$module_version; |
|
94 | - } |
|
95 | - |
|
96 | - final public static function setModuleVersion($version) |
|
97 | - { |
|
98 | - self::$module_version = $version; |
|
99 | - } |
|
100 | - |
|
101 | - final public static function getPHPVersion() |
|
102 | - { |
|
103 | - return self::$php_version = phpversion(); |
|
104 | - } |
|
105 | - |
|
106 | - final public static function setPHPVersion($version) |
|
107 | - { |
|
108 | - self::$php_version = $version; |
|
109 | - } |
|
110 | - |
|
111 | - final public static function getCMSVersion() |
|
112 | - { |
|
113 | - return self::$cms_version; |
|
114 | - } |
|
115 | - |
|
116 | - final public static function setCMSVersion($version) |
|
117 | - { |
|
118 | - self::$cms_version = $version; |
|
119 | - } |
|
27 | + const VERSION = "2.5.0"; |
|
28 | + public static $resources; |
|
29 | + public static $config; |
|
30 | + public static $log; |
|
31 | + private static $path; |
|
32 | + private static $library; |
|
33 | + private static $module_version; |
|
34 | + private static $cms_version; |
|
35 | + private static $php_version; |
|
36 | + |
|
37 | + private function __construct() |
|
38 | + { |
|
39 | + self::$path = (dirname(__FILE__)); |
|
40 | + PagSeguroAutoloader::init(); |
|
41 | + self::$resources = PagSeguroResources::init(); |
|
42 | + self::$config = PagSeguroConfig::init(); |
|
43 | + self::$log = LogPagSeguro::init(); |
|
44 | + } |
|
45 | + |
|
46 | + public static function init() |
|
47 | + { |
|
48 | + require_once "loader" . DIRECTORY_SEPARATOR . "PagSeguroAutoLoader.class.php"; |
|
49 | + self::verifyDependencies(); |
|
50 | + if (self::$library == null) { |
|
51 | + self::$library = new PagSeguroLibrary(); |
|
52 | + } |
|
53 | + return self::$library; |
|
54 | + } |
|
55 | + |
|
56 | + private static function verifyDependencies() |
|
57 | + { |
|
58 | + |
|
59 | + $dependencies = true; |
|
60 | + |
|
61 | + try { |
|
62 | + |
|
63 | + if (!function_exists('curl_init')) { |
|
64 | + $dependencies = false; |
|
65 | + throw new Exception('PagSeguroLibrary: cURL library is required.'); |
|
66 | + } |
|
67 | + |
|
68 | + if (!class_exists('DOMDocument')) { |
|
69 | + $dependencies = false; |
|
70 | + throw new Exception('PagSeguroLibrary: DOM XML extension is required.'); |
|
71 | + } |
|
72 | + |
|
73 | + } catch (Exception $e) { |
|
74 | + return $dependencies; |
|
75 | + } |
|
76 | + |
|
77 | + return $dependencies; |
|
78 | + |
|
79 | + } |
|
80 | + |
|
81 | + final public static function getVersion() |
|
82 | + { |
|
83 | + return self::VERSION; |
|
84 | + } |
|
85 | + |
|
86 | + final public static function getPath() |
|
87 | + { |
|
88 | + return self::$path; |
|
89 | + } |
|
90 | + |
|
91 | + final public static function getModuleVersion() |
|
92 | + { |
|
93 | + return self::$module_version; |
|
94 | + } |
|
95 | + |
|
96 | + final public static function setModuleVersion($version) |
|
97 | + { |
|
98 | + self::$module_version = $version; |
|
99 | + } |
|
100 | + |
|
101 | + final public static function getPHPVersion() |
|
102 | + { |
|
103 | + return self::$php_version = phpversion(); |
|
104 | + } |
|
105 | + |
|
106 | + final public static function setPHPVersion($version) |
|
107 | + { |
|
108 | + self::$php_version = $version; |
|
109 | + } |
|
110 | + |
|
111 | + final public static function getCMSVersion() |
|
112 | + { |
|
113 | + return self::$cms_version; |
|
114 | + } |
|
115 | + |
|
116 | + final public static function setCMSVersion($version) |
|
117 | + { |
|
118 | + self::$cms_version = $version; |
|
119 | + } |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | PagSeguroLibrary::init(); |
@@ -29,189 +29,189 @@ |
||
29 | 29 | class PagSeguroConfig |
30 | 30 | { |
31 | 31 | |
32 | - private static $config; |
|
33 | - private static $data; |
|
34 | - |
|
35 | - const VARNAME = 'PagSeguroConfig'; |
|
36 | - |
|
37 | - private function __construct() |
|
38 | - { |
|
39 | - define('ALLOW_PAGSEGURO_CONFIG', true); |
|
40 | - |
|
41 | - require_once PagSeguroLibrary::getPath() . |
|
42 | - DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "PagSeguroConfig.php"; |
|
43 | - $varName = self::VARNAME; |
|
44 | - |
|
45 | - if (isset($$varName)) { |
|
46 | - self::$data = $$varName; |
|
47 | - unset($$varName); |
|
48 | - } else { |
|
49 | - throw new Exception("Config is undefined."); |
|
50 | - } |
|
51 | - } |
|
52 | - |
|
53 | - public static function init() |
|
54 | - { |
|
55 | - if (self::$config == null) { |
|
56 | - self::$config = new PagSeguroConfig(); |
|
57 | - } |
|
58 | - |
|
59 | - return self::$config; |
|
60 | - } |
|
61 | - |
|
62 | - public static function getData($key1, $key2 = null) |
|
63 | - { |
|
64 | - if ($key2 != null) { |
|
65 | - if (isset(self::$data[$key1][$key2])) { |
|
66 | - return self::$data[$key1][$key2]; |
|
67 | - } else { |
|
68 | - throw new Exception("Config keys {$key1}, {$key2} not found."); |
|
69 | - } |
|
70 | - } else { |
|
71 | - if (isset(self::$data[$key1])) { |
|
72 | - return self::$data[$key1]; |
|
73 | - } else { |
|
74 | - throw new Exception("Config key {$key1} not found."); |
|
75 | - } |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - public static function setData($key1, $key2, $value) |
|
80 | - { |
|
81 | - if (isset(self::$data[$key1][$key2])) { |
|
82 | - self::$data[$key1][$key2] = $value; |
|
83 | - } else { |
|
84 | - throw new Exception("Config keys {$key1}, {$key2} not found."); |
|
85 | - } |
|
86 | - } |
|
87 | - |
|
88 | - public static function setEnvironment($value) |
|
89 | - { |
|
90 | - self::$data['environment'] = $value; |
|
91 | - } |
|
92 | - |
|
93 | - public static function getApplicationCredentials() |
|
94 | - { |
|
95 | - if (isset(self::$data['credentials']) && |
|
96 | - isset(self::$data['credentials']['appId'][self::$data['environment']]) && |
|
97 | - isset(self::$data['credentials']['appKey'][self::$data['environment']]) |
|
98 | - ) { |
|
32 | + private static $config; |
|
33 | + private static $data; |
|
34 | + |
|
35 | + const VARNAME = 'PagSeguroConfig'; |
|
36 | + |
|
37 | + private function __construct() |
|
38 | + { |
|
39 | + define('ALLOW_PAGSEGURO_CONFIG', true); |
|
40 | + |
|
41 | + require_once PagSeguroLibrary::getPath() . |
|
42 | + DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "PagSeguroConfig.php"; |
|
43 | + $varName = self::VARNAME; |
|
44 | + |
|
45 | + if (isset($$varName)) { |
|
46 | + self::$data = $$varName; |
|
47 | + unset($$varName); |
|
48 | + } else { |
|
49 | + throw new Exception("Config is undefined."); |
|
50 | + } |
|
51 | + } |
|
52 | + |
|
53 | + public static function init() |
|
54 | + { |
|
55 | + if (self::$config == null) { |
|
56 | + self::$config = new PagSeguroConfig(); |
|
57 | + } |
|
58 | + |
|
59 | + return self::$config; |
|
60 | + } |
|
61 | + |
|
62 | + public static function getData($key1, $key2 = null) |
|
63 | + { |
|
64 | + if ($key2 != null) { |
|
65 | + if (isset(self::$data[$key1][$key2])) { |
|
66 | + return self::$data[$key1][$key2]; |
|
67 | + } else { |
|
68 | + throw new Exception("Config keys {$key1}, {$key2} not found."); |
|
69 | + } |
|
70 | + } else { |
|
71 | + if (isset(self::$data[$key1])) { |
|
72 | + return self::$data[$key1]; |
|
73 | + } else { |
|
74 | + throw new Exception("Config key {$key1} not found."); |
|
75 | + } |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + public static function setData($key1, $key2, $value) |
|
80 | + { |
|
81 | + if (isset(self::$data[$key1][$key2])) { |
|
82 | + self::$data[$key1][$key2] = $value; |
|
83 | + } else { |
|
84 | + throw new Exception("Config keys {$key1}, {$key2} not found."); |
|
85 | + } |
|
86 | + } |
|
87 | + |
|
88 | + public static function setEnvironment($value) |
|
89 | + { |
|
90 | + self::$data['environment'] = $value; |
|
91 | + } |
|
92 | + |
|
93 | + public static function getApplicationCredentials() |
|
94 | + { |
|
95 | + if (isset(self::$data['credentials']) && |
|
96 | + isset(self::$data['credentials']['appId'][self::$data['environment']]) && |
|
97 | + isset(self::$data['credentials']['appKey'][self::$data['environment']]) |
|
98 | + ) { |
|
99 | 99 | |
100 | - return new PagSeguroApplicationCredentials( |
|
101 | - self::$data['credentials']['appId'][self::$data['environment']], |
|
102 | - self::$data['credentials']['appKey'][self::$data['environment']] |
|
103 | - ); |
|
104 | - } else { |
|
105 | - throw new Exception("Applications credentials not set."); |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - public static function getAccountCredentials() |
|
110 | - { |
|
111 | - if (isset(self::$data['credentials']) && |
|
112 | - isset(self::$data['credentials']['email']) && |
|
113 | - isset(self::$data['credentials']['token'][self::$data['environment']]) |
|
114 | - ) { |
|
100 | + return new PagSeguroApplicationCredentials( |
|
101 | + self::$data['credentials']['appId'][self::$data['environment']], |
|
102 | + self::$data['credentials']['appKey'][self::$data['environment']] |
|
103 | + ); |
|
104 | + } else { |
|
105 | + throw new Exception("Applications credentials not set."); |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + public static function getAccountCredentials() |
|
110 | + { |
|
111 | + if (isset(self::$data['credentials']) && |
|
112 | + isset(self::$data['credentials']['email']) && |
|
113 | + isset(self::$data['credentials']['token'][self::$data['environment']]) |
|
114 | + ) { |
|
115 | 115 | |
116 | - return new PagSeguroAccountCredentials( |
|
117 | - self::$data['credentials']['email'], |
|
118 | - self::$data['credentials']['token'][self::$data['environment']] |
|
119 | - ); |
|
120 | - } else { |
|
121 | - throw new Exception("Credentials not set."); |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - public static function getPaymentRedirectUrl() |
|
126 | - { |
|
127 | - return PagSeguroResources::getPaymentUrl(self::$data['environment']); |
|
128 | - } |
|
129 | - |
|
130 | - public static function getStaticUrl() |
|
131 | - { |
|
132 | - return PagSeguroResources::getStaticUrl(self::$data['environment']); |
|
133 | - } |
|
134 | - |
|
135 | - public static function getEnvironment() |
|
136 | - { |
|
137 | - if (isset(self::$data['environment'])) { |
|
138 | - return self::$data['environment']; |
|
139 | - } else { |
|
140 | - throw new Exception("Environment not set."); |
|
141 | - } |
|
142 | - } |
|
143 | - |
|
144 | - public static function getApplicationCharset() |
|
145 | - { |
|
146 | - if (isset(self::$data['application']) && isset(self::$data['application']['charset'])) { |
|
147 | - return self::$data['application']['charset']; |
|
148 | - } else { |
|
149 | - throw new Exception("Application charset not set."); |
|
150 | - } |
|
151 | - } |
|
152 | - |
|
153 | - public static function setApplicationCharset($charset) |
|
154 | - { |
|
155 | - self::setData('application', 'charset', $charset); |
|
156 | - } |
|
157 | - |
|
158 | - public static function logIsActive() |
|
159 | - { |
|
160 | - if (isset(self::$data['log']) && isset(self::$data['log']['active'])) { |
|
161 | - return (bool) self::$data['log']['active']; |
|
162 | - } else { |
|
163 | - throw new Exception("Log activation flag not set."); |
|
164 | - } |
|
165 | - } |
|
166 | - |
|
167 | - public static function activeLog($fileName = null) |
|
168 | - { |
|
169 | - self::setData('log', 'active', true); |
|
170 | - self::setData('log', 'fileLocation', $fileName ? $fileName : ''); |
|
171 | - LogPagSeguro::reLoad(); |
|
172 | - } |
|
173 | - |
|
174 | - public static function getLogFileLocation() |
|
175 | - { |
|
176 | - if (isset(self::$data['log']) && isset(self::$data['log']['fileLocation'])) { |
|
177 | - return self::$data['log']['fileLocation']; |
|
178 | - } else { |
|
179 | - throw new Exception("Log file location not set."); |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - /*** |
|
116 | + return new PagSeguroAccountCredentials( |
|
117 | + self::$data['credentials']['email'], |
|
118 | + self::$data['credentials']['token'][self::$data['environment']] |
|
119 | + ); |
|
120 | + } else { |
|
121 | + throw new Exception("Credentials not set."); |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + public static function getPaymentRedirectUrl() |
|
126 | + { |
|
127 | + return PagSeguroResources::getPaymentUrl(self::$data['environment']); |
|
128 | + } |
|
129 | + |
|
130 | + public static function getStaticUrl() |
|
131 | + { |
|
132 | + return PagSeguroResources::getStaticUrl(self::$data['environment']); |
|
133 | + } |
|
134 | + |
|
135 | + public static function getEnvironment() |
|
136 | + { |
|
137 | + if (isset(self::$data['environment'])) { |
|
138 | + return self::$data['environment']; |
|
139 | + } else { |
|
140 | + throw new Exception("Environment not set."); |
|
141 | + } |
|
142 | + } |
|
143 | + |
|
144 | + public static function getApplicationCharset() |
|
145 | + { |
|
146 | + if (isset(self::$data['application']) && isset(self::$data['application']['charset'])) { |
|
147 | + return self::$data['application']['charset']; |
|
148 | + } else { |
|
149 | + throw new Exception("Application charset not set."); |
|
150 | + } |
|
151 | + } |
|
152 | + |
|
153 | + public static function setApplicationCharset($charset) |
|
154 | + { |
|
155 | + self::setData('application', 'charset', $charset); |
|
156 | + } |
|
157 | + |
|
158 | + public static function logIsActive() |
|
159 | + { |
|
160 | + if (isset(self::$data['log']) && isset(self::$data['log']['active'])) { |
|
161 | + return (bool) self::$data['log']['active']; |
|
162 | + } else { |
|
163 | + throw new Exception("Log activation flag not set."); |
|
164 | + } |
|
165 | + } |
|
166 | + |
|
167 | + public static function activeLog($fileName = null) |
|
168 | + { |
|
169 | + self::setData('log', 'active', true); |
|
170 | + self::setData('log', 'fileLocation', $fileName ? $fileName : ''); |
|
171 | + LogPagSeguro::reLoad(); |
|
172 | + } |
|
173 | + |
|
174 | + public static function getLogFileLocation() |
|
175 | + { |
|
176 | + if (isset(self::$data['log']) && isset(self::$data['log']['fileLocation'])) { |
|
177 | + return self::$data['log']['fileLocation']; |
|
178 | + } else { |
|
179 | + throw new Exception("Log file location not set."); |
|
180 | + } |
|
181 | + } |
|
182 | + |
|
183 | + /*** |
|
184 | 184 | * Validate if the requirements are enable for use correct of the PagSeguro |
185 | 185 | * @return array |
186 | 186 | */ |
187 | - public static function validateRequirements() |
|
188 | - { |
|
187 | + public static function validateRequirements() |
|
188 | + { |
|
189 | 189 | |
190 | - $requirements = array( |
|
191 | - 'version' => '', |
|
192 | - 'spl' => '', |
|
193 | - 'curl' => '', |
|
194 | - 'dom' => '' |
|
195 | - ); |
|
190 | + $requirements = array( |
|
191 | + 'version' => '', |
|
192 | + 'spl' => '', |
|
193 | + 'curl' => '', |
|
194 | + 'dom' => '' |
|
195 | + ); |
|
196 | 196 | |
197 | - $version = str_replace('.', '', phpversion()); |
|
197 | + $version = str_replace('.', '', phpversion()); |
|
198 | 198 | |
199 | - if ($version < 533) { |
|
200 | - $requirements['version'] = 'PagSeguroLibrary: PHP version 5.3.3 or greater is required.'; |
|
201 | - } |
|
199 | + if ($version < 533) { |
|
200 | + $requirements['version'] = 'PagSeguroLibrary: PHP version 5.3.3 or greater is required.'; |
|
201 | + } |
|
202 | 202 | |
203 | - if (!function_exists('spl_autoload_register')) { |
|
204 | - $requirements['spl'] = 'PagSeguroLibrary: Standard PHP Library (SPL) is required.'; |
|
205 | - } |
|
203 | + if (!function_exists('spl_autoload_register')) { |
|
204 | + $requirements['spl'] = 'PagSeguroLibrary: Standard PHP Library (SPL) is required.'; |
|
205 | + } |
|
206 | 206 | |
207 | - if (!function_exists('curl_init')) { |
|
208 | - $requirements['curl'] = 'PagSeguroLibrary: cURL library is required.'; |
|
209 | - } |
|
207 | + if (!function_exists('curl_init')) { |
|
208 | + $requirements['curl'] = 'PagSeguroLibrary: cURL library is required.'; |
|
209 | + } |
|
210 | 210 | |
211 | - if (!class_exists('DOMDocument')) { |
|
212 | - $requirements['dom'] = 'PagSeguroLibrary: DOM XML extension is required.'; |
|
213 | - } |
|
211 | + if (!class_exists('DOMDocument')) { |
|
212 | + $requirements['dom'] = 'PagSeguroLibrary: DOM XML extension is required.'; |
|
213 | + } |
|
214 | 214 | |
215 | - return $requirements; |
|
216 | - } |
|
215 | + return $requirements; |
|
216 | + } |
|
217 | 217 | } |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | { |
39 | 39 | define('ALLOW_PAGSEGURO_CONFIG', true); |
40 | 40 | |
41 | - require_once PagSeguroLibrary::getPath() . |
|
42 | - DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "PagSeguroConfig.php"; |
|
41 | + require_once PagSeguroLibrary::getPath(). |
|
42 | + DIRECTORY_SEPARATOR."config".DIRECTORY_SEPARATOR."PagSeguroConfig.php"; |
|
43 | 43 | $varName = self::VARNAME; |
44 | 44 | |
45 | 45 | if (isset($$varName)) { |
@@ -200,15 +200,15 @@ discard block |
||
200 | 200 | $requirements['version'] = 'PagSeguroLibrary: PHP version 5.3.3 or greater is required.'; |
201 | 201 | } |
202 | 202 | |
203 | - if (!function_exists('spl_autoload_register')) { |
|
203 | + if ( ! function_exists('spl_autoload_register')) { |
|
204 | 204 | $requirements['spl'] = 'PagSeguroLibrary: Standard PHP Library (SPL) is required.'; |
205 | 205 | } |
206 | 206 | |
207 | - if (!function_exists('curl_init')) { |
|
207 | + if ( ! function_exists('curl_init')) { |
|
208 | 208 | $requirements['curl'] = 'PagSeguroLibrary: cURL library is required.'; |
209 | 209 | } |
210 | 210 | |
211 | - if (!class_exists('DOMDocument')) { |
|
211 | + if ( ! class_exists('DOMDocument')) { |
|
212 | 212 | $requirements['dom'] = 'PagSeguroLibrary: DOM XML extension is required.'; |
213 | 213 | } |
214 | 214 |
@@ -28,17 +28,17 @@ discard block |
||
28 | 28 | class PagSeguroAccountCredentials extends PagSeguroCredentials |
29 | 29 | { |
30 | 30 | |
31 | - /*** |
|
31 | + /*** |
|
32 | 32 | * Primary email associated with this account |
33 | 33 | */ |
34 | - private $email; |
|
34 | + private $email; |
|
35 | 35 | |
36 | - /*** |
|
36 | + /*** |
|
37 | 37 | * PagSeguro token |
38 | 38 | */ |
39 | - private $token; |
|
39 | + private $token; |
|
40 | 40 | |
41 | - /*** |
|
41 | + /*** |
|
42 | 42 | * Initializes a new instance of PagSeguroAccountCredentials class |
43 | 43 | * |
44 | 44 | * @throws Exception when credentials aren't provided. |
@@ -46,67 +46,67 @@ discard block |
||
46 | 46 | * @param string $email |
47 | 47 | * @param string $token |
48 | 48 | */ |
49 | - public function __construct($email, $token) |
|
50 | - { |
|
51 | - if ($email !== null && $token !== null) { |
|
52 | - $this->email = $email; |
|
53 | - $this->token = $token; |
|
54 | - } else { |
|
55 | - throw new Exception("Credentials not set."); |
|
56 | - } |
|
57 | - } |
|
49 | + public function __construct($email, $token) |
|
50 | + { |
|
51 | + if ($email !== null && $token !== null) { |
|
52 | + $this->email = $email; |
|
53 | + $this->token = $token; |
|
54 | + } else { |
|
55 | + throw new Exception("Credentials not set."); |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | - /*** |
|
59 | + /*** |
|
60 | 60 | * @return string the e-mail from this account credential object |
61 | 61 | */ |
62 | - public function getEmail() |
|
63 | - { |
|
64 | - return $this->email; |
|
65 | - } |
|
62 | + public function getEmail() |
|
63 | + { |
|
64 | + return $this->email; |
|
65 | + } |
|
66 | 66 | |
67 | - /*** |
|
67 | + /*** |
|
68 | 68 | * Sets the e-mail from this account credential object |
69 | 69 | */ |
70 | - public function setEmail($email) |
|
71 | - { |
|
72 | - $this->email = $email; |
|
73 | - } |
|
70 | + public function setEmail($email) |
|
71 | + { |
|
72 | + $this->email = $email; |
|
73 | + } |
|
74 | 74 | |
75 | - /*** |
|
75 | + /*** |
|
76 | 76 | * @return string the token from this account credential object |
77 | 77 | */ |
78 | - public function getToken() |
|
79 | - { |
|
80 | - return $this->token; |
|
81 | - } |
|
78 | + public function getToken() |
|
79 | + { |
|
80 | + return $this->token; |
|
81 | + } |
|
82 | 82 | |
83 | - /*** |
|
83 | + /*** |
|
84 | 84 | * Sets the token in this account credential object |
85 | 85 | */ |
86 | - public function setToken($token) |
|
87 | - { |
|
88 | - $this->token = $token; |
|
89 | - } |
|
86 | + public function setToken($token) |
|
87 | + { |
|
88 | + $this->token = $token; |
|
89 | + } |
|
90 | 90 | |
91 | - /*** |
|
91 | + /*** |
|
92 | 92 | * @return array a map of name value pairs that compose this set of credentials |
93 | 93 | */ |
94 | - public function getAttributesMap() |
|
95 | - { |
|
96 | - return array( |
|
97 | - 'email' => $this->email, |
|
98 | - 'token' => $this->token |
|
99 | - ); |
|
100 | - } |
|
94 | + public function getAttributesMap() |
|
95 | + { |
|
96 | + return array( |
|
97 | + 'email' => $this->email, |
|
98 | + 'token' => $this->token |
|
99 | + ); |
|
100 | + } |
|
101 | 101 | |
102 | - /*** |
|
102 | + /*** |
|
103 | 103 | * @return string a string that represents the current object |
104 | 104 | */ |
105 | - public function toString() |
|
106 | - { |
|
107 | - $credentials = array(); |
|
108 | - $credentials['E-mail'] = $this->email; |
|
109 | - $credentials['Token'] = $this->token; |
|
110 | - return implode(' - ', $credentials); |
|
111 | - } |
|
105 | + public function toString() |
|
106 | + { |
|
107 | + $credentials = array(); |
|
108 | + $credentials['E-mail'] = $this->email; |
|
109 | + $credentials['Token'] = $this->token; |
|
110 | + return implode(' - ', $credentials); |
|
111 | + } |
|
112 | 112 | } |
@@ -309,7 +309,7 @@ |
||
309 | 309 | foreach ($item as $code) { |
310 | 310 | $accents .= chr($code); |
311 | 311 | } |
312 | - $change[$key] = '/[' . $accents . ']/i'; |
|
312 | + $change[$key] = '/['.$accents.']/i'; |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | $state = preg_replace(array_values($change), array_keys($change), $state); |
@@ -28,301 +28,301 @@ |
||
28 | 28 | class PagSeguroAddress |
29 | 29 | { |
30 | 30 | |
31 | - private $postalCode; |
|
31 | + private $postalCode; |
|
32 | 32 | |
33 | - /*** |
|
33 | + /*** |
|
34 | 34 | * Street name |
35 | 35 | */ |
36 | - private $street; |
|
36 | + private $street; |
|
37 | 37 | |
38 | - /*** |
|
38 | + /*** |
|
39 | 39 | * Number |
40 | 40 | */ |
41 | - private $number; |
|
41 | + private $number; |
|
42 | 42 | |
43 | - /*** |
|
43 | + /*** |
|
44 | 44 | * Apartment, suite number or any other qualifier after the street/number pair. |
45 | 45 | * Example: Apt 274, building A. |
46 | 46 | */ |
47 | - private $complement; |
|
47 | + private $complement; |
|
48 | 48 | |
49 | - /*** |
|
49 | + /*** |
|
50 | 50 | * District, county or neighborhood, if applicable |
51 | 51 | */ |
52 | - private $district; |
|
52 | + private $district; |
|
53 | 53 | |
54 | - /*** |
|
54 | + /*** |
|
55 | 55 | * City |
56 | 56 | */ |
57 | - private $city; |
|
57 | + private $city; |
|
58 | 58 | |
59 | - /*** |
|
59 | + /*** |
|
60 | 60 | * State or province |
61 | 61 | */ |
62 | - private $state; |
|
62 | + private $state; |
|
63 | 63 | |
64 | - /*** |
|
64 | + /*** |
|
65 | 65 | * Country |
66 | 66 | */ |
67 | - private $country; |
|
67 | + private $country; |
|
68 | 68 | |
69 | - /*** |
|
69 | + /*** |
|
70 | 70 | * acronyms and states brazilian |
71 | 71 | * @var type |
72 | 72 | */ |
73 | - private static $acronyms = array('acre' => 'AC', |
|
74 | - 'alagoas' => 'AL', |
|
75 | - 'amapa' => 'AP', |
|
76 | - 'amazonas' => 'AM', |
|
77 | - 'bahia' => 'BA', |
|
78 | - 'ceara' => 'CE', |
|
79 | - 'espiritosanto' => 'ES', |
|
80 | - 'goias' => 'GO', |
|
81 | - 'maranhao' => 'MA', |
|
82 | - 'matogrosso' => 'MT', |
|
83 | - 'matogrossodosul' => 'MS', |
|
84 | - 'matogrossosul' => 'MS', |
|
85 | - 'minasgerais' => 'MG', |
|
86 | - 'para' => 'PA', |
|
87 | - 'paraiba' => 'PB', |
|
88 | - 'parana' => 'PR', |
|
89 | - 'pernambuco' => 'PE', |
|
90 | - 'piaui' => 'PI', |
|
91 | - 'riodejaneiro' => 'RJ', |
|
92 | - 'riojaneiro' => 'RJ', |
|
93 | - 'riograndedonorte' => 'RN', |
|
94 | - 'riograndenorte' => 'RN', |
|
95 | - 'riograndedosul' => 'RS', |
|
96 | - 'riograndesul' => 'RS', |
|
97 | - 'rondonia' => 'RO', |
|
98 | - 'roraima' => 'RR', |
|
99 | - 'santacatarina' => 'SC', |
|
100 | - 'saopaulo' => 'SP', |
|
101 | - 'sergipe' => 'SE', |
|
102 | - 'tocantins' => 'TO', |
|
103 | - 'distritofederal' => 'DF'); |
|
104 | - |
|
105 | - /*** |
|
73 | + private static $acronyms = array('acre' => 'AC', |
|
74 | + 'alagoas' => 'AL', |
|
75 | + 'amapa' => 'AP', |
|
76 | + 'amazonas' => 'AM', |
|
77 | + 'bahia' => 'BA', |
|
78 | + 'ceara' => 'CE', |
|
79 | + 'espiritosanto' => 'ES', |
|
80 | + 'goias' => 'GO', |
|
81 | + 'maranhao' => 'MA', |
|
82 | + 'matogrosso' => 'MT', |
|
83 | + 'matogrossodosul' => 'MS', |
|
84 | + 'matogrossosul' => 'MS', |
|
85 | + 'minasgerais' => 'MG', |
|
86 | + 'para' => 'PA', |
|
87 | + 'paraiba' => 'PB', |
|
88 | + 'parana' => 'PR', |
|
89 | + 'pernambuco' => 'PE', |
|
90 | + 'piaui' => 'PI', |
|
91 | + 'riodejaneiro' => 'RJ', |
|
92 | + 'riojaneiro' => 'RJ', |
|
93 | + 'riograndedonorte' => 'RN', |
|
94 | + 'riograndenorte' => 'RN', |
|
95 | + 'riograndedosul' => 'RS', |
|
96 | + 'riograndesul' => 'RS', |
|
97 | + 'rondonia' => 'RO', |
|
98 | + 'roraima' => 'RR', |
|
99 | + 'santacatarina' => 'SC', |
|
100 | + 'saopaulo' => 'SP', |
|
101 | + 'sergipe' => 'SE', |
|
102 | + 'tocantins' => 'TO', |
|
103 | + 'distritofederal' => 'DF'); |
|
104 | + |
|
105 | + /*** |
|
106 | 106 | * Initializes a new instance of the Address class |
107 | 107 | * @param array $data |
108 | 108 | */ |
109 | - public function __construct(array $data = null) |
|
110 | - { |
|
111 | - if (isset($data['postalCode'])) { |
|
112 | - $this->postalCode = $data['postalCode']; |
|
113 | - } |
|
114 | - if (isset($data['street'])) { |
|
115 | - $this->street = $data['street']; |
|
116 | - } |
|
117 | - if (isset($data['number'])) { |
|
118 | - $this->number = $data['number']; |
|
119 | - } |
|
120 | - if (isset($data['complement'])) { |
|
121 | - $this->complement = $data['complement']; |
|
122 | - } |
|
123 | - if (isset($data['district'])) { |
|
124 | - $this->district = $data['district']; |
|
125 | - } |
|
126 | - if (isset($data['city'])) { |
|
127 | - $this->city = $data['city']; |
|
128 | - } |
|
129 | - if (isset($data['state'])) { |
|
130 | - $this->state = $data['state']; |
|
131 | - } |
|
132 | - if (isset($data['country'])) { |
|
133 | - $this->country = $data['country']; |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - /*** |
|
109 | + public function __construct(array $data = null) |
|
110 | + { |
|
111 | + if (isset($data['postalCode'])) { |
|
112 | + $this->postalCode = $data['postalCode']; |
|
113 | + } |
|
114 | + if (isset($data['street'])) { |
|
115 | + $this->street = $data['street']; |
|
116 | + } |
|
117 | + if (isset($data['number'])) { |
|
118 | + $this->number = $data['number']; |
|
119 | + } |
|
120 | + if (isset($data['complement'])) { |
|
121 | + $this->complement = $data['complement']; |
|
122 | + } |
|
123 | + if (isset($data['district'])) { |
|
124 | + $this->district = $data['district']; |
|
125 | + } |
|
126 | + if (isset($data['city'])) { |
|
127 | + $this->city = $data['city']; |
|
128 | + } |
|
129 | + if (isset($data['state'])) { |
|
130 | + $this->state = $data['state']; |
|
131 | + } |
|
132 | + if (isset($data['country'])) { |
|
133 | + $this->country = $data['country']; |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + /*** |
|
138 | 138 | * @return string the street |
139 | 139 | */ |
140 | - public function getStreet() |
|
141 | - { |
|
142 | - return $this->street; |
|
143 | - } |
|
140 | + public function getStreet() |
|
141 | + { |
|
142 | + return $this->street; |
|
143 | + } |
|
144 | 144 | |
145 | - /*** |
|
145 | + /*** |
|
146 | 146 | * @return string the number |
147 | 147 | */ |
148 | - public function getNumber() |
|
149 | - { |
|
150 | - return $this->number; |
|
151 | - } |
|
148 | + public function getNumber() |
|
149 | + { |
|
150 | + return $this->number; |
|
151 | + } |
|
152 | 152 | |
153 | - /*** |
|
153 | + /*** |
|
154 | 154 | * @return string the complement |
155 | 155 | */ |
156 | - public function getComplement() |
|
157 | - { |
|
158 | - return $this->complement; |
|
159 | - } |
|
156 | + public function getComplement() |
|
157 | + { |
|
158 | + return $this->complement; |
|
159 | + } |
|
160 | 160 | |
161 | - /*** |
|
161 | + /*** |
|
162 | 162 | * @return string the distrcit |
163 | 163 | */ |
164 | - public function getDistrict() |
|
165 | - { |
|
166 | - return $this->district; |
|
167 | - } |
|
164 | + public function getDistrict() |
|
165 | + { |
|
166 | + return $this->district; |
|
167 | + } |
|
168 | 168 | |
169 | - /*** |
|
169 | + /*** |
|
170 | 170 | * @return string the city |
171 | 171 | */ |
172 | - public function getCity() |
|
173 | - { |
|
174 | - return $this->city; |
|
175 | - } |
|
172 | + public function getCity() |
|
173 | + { |
|
174 | + return $this->city; |
|
175 | + } |
|
176 | 176 | |
177 | - /*** |
|
177 | + /*** |
|
178 | 178 | * @return string the state |
179 | 179 | */ |
180 | - public function getState() |
|
181 | - { |
|
182 | - return $this->state; |
|
183 | - } |
|
180 | + public function getState() |
|
181 | + { |
|
182 | + return $this->state; |
|
183 | + } |
|
184 | 184 | |
185 | - /*** |
|
185 | + /*** |
|
186 | 186 | * @return string the postal code |
187 | 187 | */ |
188 | - public function getPostalCode() |
|
189 | - { |
|
190 | - return $this->postalCode; |
|
191 | - } |
|
188 | + public function getPostalCode() |
|
189 | + { |
|
190 | + return $this->postalCode; |
|
191 | + } |
|
192 | 192 | |
193 | - /*** |
|
193 | + /*** |
|
194 | 194 | * @return string the country |
195 | 195 | */ |
196 | - public function getCountry() |
|
197 | - { |
|
198 | - return $this->country; |
|
199 | - } |
|
196 | + public function getCountry() |
|
197 | + { |
|
198 | + return $this->country; |
|
199 | + } |
|
200 | 200 | |
201 | - /*** |
|
201 | + /*** |
|
202 | 202 | * Sets the country |
203 | 203 | * @param String $country |
204 | 204 | */ |
205 | - public function setCountry($country) |
|
206 | - { |
|
207 | - $this->country = $country; |
|
208 | - } |
|
205 | + public function setCountry($country) |
|
206 | + { |
|
207 | + $this->country = $country; |
|
208 | + } |
|
209 | 209 | |
210 | - /*** |
|
210 | + /*** |
|
211 | 211 | * Sets the street |
212 | 212 | * @param String $street |
213 | 213 | */ |
214 | - public function setStreet($street) |
|
215 | - { |
|
216 | - $this->street = $street; |
|
217 | - } |
|
214 | + public function setStreet($street) |
|
215 | + { |
|
216 | + $this->street = $street; |
|
217 | + } |
|
218 | 218 | |
219 | - /*** |
|
219 | + /*** |
|
220 | 220 | * sets the numbetr |
221 | 221 | * @param String $number |
222 | 222 | */ |
223 | - public function setNumber($number) |
|
224 | - { |
|
225 | - $this->number = $number; |
|
226 | - } |
|
223 | + public function setNumber($number) |
|
224 | + { |
|
225 | + $this->number = $number; |
|
226 | + } |
|
227 | 227 | |
228 | - /*** |
|
228 | + /*** |
|
229 | 229 | * Sets the complement |
230 | 230 | * @param String $complement |
231 | 231 | */ |
232 | - public function setComplement($complement) |
|
233 | - { |
|
234 | - $this->complement = $complement; |
|
235 | - } |
|
232 | + public function setComplement($complement) |
|
233 | + { |
|
234 | + $this->complement = $complement; |
|
235 | + } |
|
236 | 236 | |
237 | - /*** |
|
237 | + /*** |
|
238 | 238 | * sets the district |
239 | 239 | * @param String $district |
240 | 240 | */ |
241 | - public function setDistrict($district) |
|
242 | - { |
|
243 | - $this->district = $district; |
|
244 | - } |
|
241 | + public function setDistrict($district) |
|
242 | + { |
|
243 | + $this->district = $district; |
|
244 | + } |
|
245 | 245 | |
246 | - /*** |
|
246 | + /*** |
|
247 | 247 | * Sets the city |
248 | 248 | * @param String $city |
249 | 249 | */ |
250 | - public function setCity($city) |
|
251 | - { |
|
252 | - $this->city = $city; |
|
253 | - } |
|
250 | + public function setCity($city) |
|
251 | + { |
|
252 | + $this->city = $city; |
|
253 | + } |
|
254 | 254 | |
255 | - /*** |
|
255 | + /*** |
|
256 | 256 | * Sets the state |
257 | 257 | * @param String $state |
258 | 258 | */ |
259 | - public function setState($state) |
|
260 | - { |
|
261 | - $this->state = $this->treatState($state); |
|
262 | - } |
|
259 | + public function setState($state) |
|
260 | + { |
|
261 | + $this->state = $this->treatState($state); |
|
262 | + } |
|
263 | 263 | |
264 | - /*** |
|
264 | + /*** |
|
265 | 265 | * Sets the postal code |
266 | 266 | * @param String $postalCode |
267 | 267 | */ |
268 | - public function setPostalCode($postalCode) |
|
269 | - { |
|
270 | - $this->postalCode = $postalCode; |
|
271 | - } |
|
268 | + public function setPostalCode($postalCode) |
|
269 | + { |
|
270 | + $this->postalCode = $postalCode; |
|
271 | + } |
|
272 | 272 | |
273 | - /*** |
|
273 | + /*** |
|
274 | 274 | * Handle the state to pass in format expected in PagSeguro |
275 | 275 | * @param type $defaultState |
276 | 276 | * @return string |
277 | 277 | */ |
278 | - private function treatState($defaultState) |
|
279 | - { |
|
280 | - |
|
281 | - if (strlen($defaultState) == 2) { |
|
282 | - foreach (self::$acronyms as $key => $val) { |
|
283 | - if ($val == strtoupper($defaultState)) { |
|
284 | - return strtoupper($defaultState); |
|
285 | - } |
|
286 | - } |
|
287 | - return ''; |
|
288 | - } |
|
289 | - |
|
290 | - $state = utf8_decode($defaultState); |
|
291 | - $state = strtolower($state); |
|
292 | - |
|
293 | - // Code ASCII of the vowel |
|
294 | - $ascii['a'] = range(224, 230); |
|
295 | - $ascii['e'] = range(232, 235); |
|
296 | - $ascii['i'] = range(236, 239); |
|
297 | - $ascii['o'] = array_merge(range(242, 246), array(240, 248)); |
|
298 | - $ascii['u'] = range(249, 252); |
|
299 | - |
|
300 | - // Code ASCII of the others character |
|
301 | - $ascii['b'] = array(223); |
|
302 | - $ascii['c'] = array(231); |
|
303 | - $ascii['d'] = array(208); |
|
304 | - $ascii['n'] = array(241); |
|
305 | - $ascii['y'] = array(253, 255); |
|
306 | - |
|
307 | - foreach ($ascii as $key => $item) { |
|
308 | - $accents = ''; |
|
309 | - foreach ($item as $code) { |
|
310 | - $accents .= chr($code); |
|
311 | - } |
|
312 | - $change[$key] = '/[' . $accents . ']/i'; |
|
313 | - } |
|
314 | - |
|
315 | - $state = preg_replace(array_values($change), array_keys($change), $state); |
|
316 | - |
|
317 | - $state = preg_replace("/\s/", "", $state); |
|
318 | - |
|
319 | - foreach (self::$acronyms as $key => $val) { |
|
320 | - if ($key == $state) { |
|
321 | - $acronym = $val; |
|
322 | - return $acronym; |
|
323 | - } |
|
324 | - } |
|
325 | - |
|
326 | - return ''; |
|
327 | - } |
|
278 | + private function treatState($defaultState) |
|
279 | + { |
|
280 | + |
|
281 | + if (strlen($defaultState) == 2) { |
|
282 | + foreach (self::$acronyms as $key => $val) { |
|
283 | + if ($val == strtoupper($defaultState)) { |
|
284 | + return strtoupper($defaultState); |
|
285 | + } |
|
286 | + } |
|
287 | + return ''; |
|
288 | + } |
|
289 | + |
|
290 | + $state = utf8_decode($defaultState); |
|
291 | + $state = strtolower($state); |
|
292 | + |
|
293 | + // Code ASCII of the vowel |
|
294 | + $ascii['a'] = range(224, 230); |
|
295 | + $ascii['e'] = range(232, 235); |
|
296 | + $ascii['i'] = range(236, 239); |
|
297 | + $ascii['o'] = array_merge(range(242, 246), array(240, 248)); |
|
298 | + $ascii['u'] = range(249, 252); |
|
299 | + |
|
300 | + // Code ASCII of the others character |
|
301 | + $ascii['b'] = array(223); |
|
302 | + $ascii['c'] = array(231); |
|
303 | + $ascii['d'] = array(208); |
|
304 | + $ascii['n'] = array(241); |
|
305 | + $ascii['y'] = array(253, 255); |
|
306 | + |
|
307 | + foreach ($ascii as $key => $item) { |
|
308 | + $accents = ''; |
|
309 | + foreach ($item as $code) { |
|
310 | + $accents .= chr($code); |
|
311 | + } |
|
312 | + $change[$key] = '/[' . $accents . ']/i'; |
|
313 | + } |
|
314 | + |
|
315 | + $state = preg_replace(array_values($change), array_keys($change), $state); |
|
316 | + |
|
317 | + $state = preg_replace("/\s/", "", $state); |
|
318 | + |
|
319 | + foreach (self::$acronyms as $key => $val) { |
|
320 | + if ($key == $state) { |
|
321 | + $acronym = $val; |
|
322 | + return $acronym; |
|
323 | + } |
|
324 | + } |
|
325 | + |
|
326 | + return ''; |
|
327 | + } |
|
328 | 328 | } |
@@ -57,11 +57,11 @@ |
||
57 | 57 | if ($appId !== null && $appKey !== null) { |
58 | 58 | $this->appId = $appId; |
59 | 59 | $this->appKey = $appKey; |
60 | - } else { |
|
60 | + } else { |
|
61 | 61 | throw new Exception("Authorization credentials not set."); |
62 | 62 | } |
63 | 63 | |
64 | - if ($authorizationCode !== null ) { |
|
64 | + if ($authorizationCode !== null) { |
|
65 | 65 | $this->authorizationCode = $authorizationCode; |
66 | 66 | } |
67 | 67 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | if ($appId !== null && $appKey !== null) { |
58 | 58 | $this->appId = $appId; |
59 | 59 | $this->appKey = $appKey; |
60 | - } else { |
|
60 | + } else { |
|
61 | 61 | throw new Exception("Authorization credentials not set."); |
62 | 62 | } |
63 | 63 |
@@ -28,22 +28,22 @@ discard block |
||
28 | 28 | class PagSeguroApplicationCredentials extends PagSeguroCredentials |
29 | 29 | { |
30 | 30 | |
31 | - /*** |
|
31 | + /*** |
|
32 | 32 | * PagSeguro App ID |
33 | 33 | */ |
34 | - private $appId; |
|
34 | + private $appId; |
|
35 | 35 | |
36 | - /*** |
|
36 | + /*** |
|
37 | 37 | * Specifies the corresponding appKey to PagSeguro application that is performing the request. |
38 | 38 | */ |
39 | - private $appKey; |
|
39 | + private $appKey; |
|
40 | 40 | |
41 | - /*** |
|
41 | + /*** |
|
42 | 42 | * Specifies the corresponding authorization Code to PagSeguro application that is performing the request. |
43 | 43 | */ |
44 | - private $authorizationCode; |
|
44 | + private $authorizationCode; |
|
45 | 45 | |
46 | - /*** |
|
46 | + /*** |
|
47 | 47 | * Initializes a new instance of PagSeguroAuthorizationCredentials class |
48 | 48 | * |
49 | 49 | * @throws Exception when credentials aren't provided. |
@@ -52,92 +52,92 @@ discard block |
||
52 | 52 | * @param string $appKey |
53 | 53 | * @param string $authorizationCode |
54 | 54 | */ |
55 | - public function __construct($appId, $appKey, $authorizationCode = null) |
|
56 | - { |
|
57 | - if ($appId !== null && $appKey !== null) { |
|
58 | - $this->appId = $appId; |
|
59 | - $this->appKey = $appKey; |
|
60 | - } else { |
|
61 | - throw new Exception("Authorization credentials not set."); |
|
62 | - } |
|
55 | + public function __construct($appId, $appKey, $authorizationCode = null) |
|
56 | + { |
|
57 | + if ($appId !== null && $appKey !== null) { |
|
58 | + $this->appId = $appId; |
|
59 | + $this->appKey = $appKey; |
|
60 | + } else { |
|
61 | + throw new Exception("Authorization credentials not set."); |
|
62 | + } |
|
63 | 63 | |
64 | - if ($authorizationCode !== null ) { |
|
65 | - $this->authorizationCode = $authorizationCode; |
|
66 | - } |
|
67 | - } |
|
64 | + if ($authorizationCode !== null ) { |
|
65 | + $this->authorizationCode = $authorizationCode; |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | - /*** |
|
69 | + /*** |
|
70 | 70 | * @return string the appID from this authorization credentials |
71 | 71 | */ |
72 | - public function getAppId() |
|
73 | - { |
|
74 | - return $this->appId; |
|
75 | - } |
|
72 | + public function getAppId() |
|
73 | + { |
|
74 | + return $this->appId; |
|
75 | + } |
|
76 | 76 | |
77 | - /*** |
|
77 | + /*** |
|
78 | 78 | * Sets the app ID from this authorization credentials |
79 | 79 | * @param string $appId |
80 | 80 | */ |
81 | - public function setAppId($appId) |
|
82 | - { |
|
83 | - $this->appId = $appId; |
|
84 | - } |
|
81 | + public function setAppId($appId) |
|
82 | + { |
|
83 | + $this->appId = $appId; |
|
84 | + } |
|
85 | 85 | |
86 | - /*** |
|
86 | + /*** |
|
87 | 87 | * @return string the appKey from this authorization credentials |
88 | 88 | */ |
89 | - public function getAppKey() |
|
90 | - { |
|
91 | - return $this->appKey; |
|
92 | - } |
|
89 | + public function getAppKey() |
|
90 | + { |
|
91 | + return $this->appKey; |
|
92 | + } |
|
93 | 93 | |
94 | - /*** |
|
94 | + /*** |
|
95 | 95 | * Sets the app ID from this authorization credentials |
96 | 96 | * @param string $appKey |
97 | 97 | */ |
98 | - public function setAppKey($appKey) |
|
99 | - { |
|
100 | - $this->appKey = $appKey; |
|
101 | - } |
|
98 | + public function setAppKey($appKey) |
|
99 | + { |
|
100 | + $this->appKey = $appKey; |
|
101 | + } |
|
102 | 102 | |
103 | - /*** |
|
103 | + /*** |
|
104 | 104 | * @return string the appKey from this authorization credentials |
105 | 105 | */ |
106 | - public function getAuthorizationCode() |
|
107 | - { |
|
108 | - return $this->authorizationCode; |
|
109 | - } |
|
106 | + public function getAuthorizationCode() |
|
107 | + { |
|
108 | + return $this->authorizationCode; |
|
109 | + } |
|
110 | 110 | |
111 | - /*** |
|
111 | + /*** |
|
112 | 112 | * Sets the app ID from this authorization credentials |
113 | 113 | * @param string $authorizationCode |
114 | 114 | */ |
115 | - public function setAuthorizationCode($authorizationCode) |
|
116 | - { |
|
117 | - $this->authorizationCode = $authorizationCode; |
|
118 | - } |
|
115 | + public function setAuthorizationCode($authorizationCode) |
|
116 | + { |
|
117 | + $this->authorizationCode = $authorizationCode; |
|
118 | + } |
|
119 | 119 | |
120 | - /*** |
|
120 | + /*** |
|
121 | 121 | * @return array a map of name value pairs that compose this set of credentials |
122 | 122 | */ |
123 | - public function getAttributesMap() |
|
124 | - { |
|
125 | - return array( |
|
126 | - 'appId' => $this->appId, |
|
127 | - 'appKey' => $this->appKey, |
|
128 | - 'authorizationCode' => $this->authorizationCode |
|
129 | - ); |
|
130 | - } |
|
123 | + public function getAttributesMap() |
|
124 | + { |
|
125 | + return array( |
|
126 | + 'appId' => $this->appId, |
|
127 | + 'appKey' => $this->appKey, |
|
128 | + 'authorizationCode' => $this->authorizationCode |
|
129 | + ); |
|
130 | + } |
|
131 | 131 | |
132 | - /*** |
|
132 | + /*** |
|
133 | 133 | * @return string a string that represents the current object |
134 | 134 | */ |
135 | - public function toString() |
|
136 | - { |
|
137 | - $credentials = array(); |
|
138 | - $credentials['AppID'] = $this->appId; |
|
139 | - $credentials['AppKey'] = $this->appKey; |
|
140 | - $credentials['AuthorizationCode'] = $this->appKey; |
|
141 | - return implode(' - ', $credentials); |
|
142 | - } |
|
135 | + public function toString() |
|
136 | + { |
|
137 | + $credentials = array(); |
|
138 | + $credentials['AppID'] = $this->appId; |
|
139 | + $credentials['AppKey'] = $this->appKey; |
|
140 | + $credentials['AuthorizationCode'] = $this->appKey; |
|
141 | + return implode(' - ', $credentials); |
|
142 | + } |
|
143 | 143 | } |
@@ -186,6 +186,6 @@ |
||
186 | 186 | $authorization = array(); |
187 | 187 | $authorization['code'] = $this->code; |
188 | 188 | $authorization['reference'] = $this->reference; |
189 | - return "Authorization: " . implode(' - ', $authorization); |
|
189 | + return "Authorization: ".implode(' - ', $authorization); |
|
190 | 190 | } |
191 | 191 | } |
@@ -28,164 +28,164 @@ |
||
28 | 28 | class PagSeguroAuthorization |
29 | 29 | { |
30 | 30 | |
31 | - /*** |
|
31 | + /*** |
|
32 | 32 | * Authorization code |
33 | 33 | */ |
34 | - private $code; |
|
34 | + private $code; |
|
35 | 35 | |
36 | - /*** |
|
36 | + /*** |
|
37 | 37 | * Authorization date |
38 | 38 | */ |
39 | - private $date; |
|
39 | + private $date; |
|
40 | 40 | |
41 | - /*** |
|
41 | + /*** |
|
42 | 42 | * Creation date |
43 | 43 | * Date of authorization creation |
44 | 44 | */ |
45 | - private $creationDate; |
|
45 | + private $creationDate; |
|
46 | 46 | |
47 | 47 | |
48 | - /*** |
|
48 | + /*** |
|
49 | 49 | * Reference code |
50 | 50 | * You can use the reference code to store an identifier so you can |
51 | 51 | * associate the PagSeguro authorization to a authorization in your system. |
52 | 52 | */ |
53 | - private $reference; |
|
53 | + private $reference; |
|
54 | 54 | |
55 | - /*** |
|
55 | + /*** |
|
56 | 56 | * Represents all permissions returned by the authorization |
57 | 57 | * @see PagSeguroAuthorizationPermisssions |
58 | 58 | */ |
59 | - private $permissions; |
|
59 | + private $permissions; |
|
60 | 60 | |
61 | - /*** |
|
61 | + /*** |
|
62 | 62 | * Represents the account |
63 | 63 | * @see PagSeguroAuthorizationAccount |
64 | 64 | */ |
65 | - private $account; |
|
65 | + private $account; |
|
66 | 66 | |
67 | - /*** |
|
67 | + /*** |
|
68 | 68 | * @return string of authorization code. |
69 | 69 | */ |
70 | - public function getCode() |
|
71 | - { |
|
72 | - return $this->code; |
|
73 | - } |
|
70 | + public function getCode() |
|
71 | + { |
|
72 | + return $this->code; |
|
73 | + } |
|
74 | 74 | |
75 | - /*** |
|
75 | + /*** |
|
76 | 76 | * Sets the authorization code |
77 | 77 | * @param string $code |
78 | 78 | */ |
79 | - public function setCode($code) |
|
80 | - { |
|
81 | - if (isset($code)) { |
|
82 | - $this->code = $code; |
|
83 | - } |
|
84 | - } |
|
79 | + public function setCode($code) |
|
80 | + { |
|
81 | + if (isset($code)) { |
|
82 | + $this->code = $code; |
|
83 | + } |
|
84 | + } |
|
85 | 85 | |
86 | - /*** |
|
86 | + /*** |
|
87 | 87 | * @return string of authorization date. |
88 | 88 | */ |
89 | - public function getDate() |
|
90 | - { |
|
91 | - return $this->date; |
|
92 | - } |
|
89 | + public function getDate() |
|
90 | + { |
|
91 | + return $this->date; |
|
92 | + } |
|
93 | 93 | |
94 | - /*** |
|
94 | + /*** |
|
95 | 95 | * Sets the authorization date |
96 | 96 | * @param string $date |
97 | 97 | */ |
98 | - public function setDate($date) |
|
99 | - { |
|
100 | - if (isset($date)) { |
|
101 | - $this->date = $date; |
|
102 | - } |
|
103 | - } |
|
98 | + public function setDate($date) |
|
99 | + { |
|
100 | + if (isset($date)) { |
|
101 | + $this->date = $date; |
|
102 | + } |
|
103 | + } |
|
104 | 104 | |
105 | - /*** |
|
105 | + /*** |
|
106 | 106 | * @return string of authorization creation date. |
107 | 107 | */ |
108 | - public function getCreationDate() |
|
109 | - { |
|
110 | - return $this->creationDate; |
|
111 | - } |
|
108 | + public function getCreationDate() |
|
109 | + { |
|
110 | + return $this->creationDate; |
|
111 | + } |
|
112 | 112 | |
113 | - /*** |
|
113 | + /*** |
|
114 | 114 | * Sets the authorization creation date |
115 | 115 | * @param string $creationDate |
116 | 116 | */ |
117 | - public function setCreationDate($creationDate) |
|
118 | - { |
|
119 | - if (isset($creationDate)) { |
|
120 | - $this->creationDate = $creationDate; |
|
121 | - } |
|
122 | - } |
|
117 | + public function setCreationDate($creationDate) |
|
118 | + { |
|
119 | + if (isset($creationDate)) { |
|
120 | + $this->creationDate = $creationDate; |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | - /*** |
|
124 | + /*** |
|
125 | 125 | * @return string of authorization reference. |
126 | 126 | */ |
127 | - public function getReference() |
|
128 | - { |
|
129 | - return $this->reference; |
|
130 | - } |
|
127 | + public function getReference() |
|
128 | + { |
|
129 | + return $this->reference; |
|
130 | + } |
|
131 | 131 | |
132 | - /*** |
|
132 | + /*** |
|
133 | 133 | * Sets the authorization reference |
134 | 134 | * @param string $reference |
135 | 135 | */ |
136 | - public function setReference($reference) |
|
137 | - { |
|
138 | - if (isset($reference)) { |
|
139 | - $this->reference = $reference; |
|
140 | - } |
|
141 | - } |
|
136 | + public function setReference($reference) |
|
137 | + { |
|
138 | + if (isset($reference)) { |
|
139 | + $this->reference = $reference; |
|
140 | + } |
|
141 | + } |
|
142 | 142 | |
143 | - /*** |
|
143 | + /*** |
|
144 | 144 | * @return string of authorization permissions. |
145 | 145 | */ |
146 | - public function getPermissions() |
|
147 | - { |
|
148 | - return $this->permissions; |
|
149 | - } |
|
146 | + public function getPermissions() |
|
147 | + { |
|
148 | + return $this->permissions; |
|
149 | + } |
|
150 | 150 | |
151 | - /*** |
|
151 | + /*** |
|
152 | 152 | * Sets the authorization permissions |
153 | 153 | * @param string $permissions |
154 | 154 | */ |
155 | - public function setPermissions($permissions) |
|
156 | - { |
|
157 | - if (isset($permissions)) { |
|
158 | - $this->permissions = $permissions; |
|
159 | - } |
|
160 | - } |
|
155 | + public function setPermissions($permissions) |
|
156 | + { |
|
157 | + if (isset($permissions)) { |
|
158 | + $this->permissions = $permissions; |
|
159 | + } |
|
160 | + } |
|
161 | 161 | |
162 | - /*** |
|
162 | + /*** |
|
163 | 163 | * @return string of authorization account. |
164 | 164 | */ |
165 | - public function getAccount() |
|
166 | - { |
|
167 | - return $this->account; |
|
168 | - } |
|
165 | + public function getAccount() |
|
166 | + { |
|
167 | + return $this->account; |
|
168 | + } |
|
169 | 169 | |
170 | - /*** |
|
170 | + /*** |
|
171 | 171 | * Sets the authorization account |
172 | 172 | * @param string $account |
173 | 173 | */ |
174 | - public function setAccount($account) |
|
175 | - { |
|
176 | - if (isset($account)) { |
|
177 | - $this->account = $account; |
|
178 | - } |
|
179 | - } |
|
174 | + public function setAccount($account) |
|
175 | + { |
|
176 | + if (isset($account)) { |
|
177 | + $this->account = $account; |
|
178 | + } |
|
179 | + } |
|
180 | 180 | |
181 | - /*** |
|
181 | + /*** |
|
182 | 182 | * @return String that resents the current object |
183 | 183 | */ |
184 | - public function toString() |
|
185 | - { |
|
186 | - $authorization = array(); |
|
187 | - $authorization['code'] = $this->code; |
|
188 | - $authorization['reference'] = $this->reference; |
|
189 | - return "Authorization: " . implode(' - ', $authorization); |
|
190 | - } |
|
184 | + public function toString() |
|
185 | + { |
|
186 | + $authorization = array(); |
|
187 | + $authorization['code'] = $this->code; |
|
188 | + $authorization['reference'] = $this->reference; |
|
189 | + return "Authorization: " . implode(' - ', $authorization); |
|
190 | + } |
|
191 | 191 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | $request = array(); |
194 | 194 | $request['Reference'] = $this->reference; |
195 | 195 | |
196 | - return "PagSeguroAuthorizationRequest: " . implode(' - ', $request); |
|
196 | + return "PagSeguroAuthorizationRequest: ".implode(' - ', $request); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /*** |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public function verifyURLTest($url) |
205 | 205 | { |
206 | - $address = array('127.0.0.1','::1'); |
|
206 | + $address = array('127.0.0.1', '::1'); |
|
207 | 207 | |
208 | 208 | foreach ($address as $item) { |
209 | 209 | $find = strpos($url, $item); |
@@ -208,10 +208,11 @@ |
||
208 | 208 | foreach ($address as $item) { |
209 | 209 | $find = strpos($url, $item); |
210 | 210 | |
211 | - if ($find) |
|
212 | - return false; |
|
213 | - else |
|
214 | - return $url; |
|
211 | + if ($find) { |
|
212 | + return false; |
|
213 | + } else { |
|
214 | + return $url; |
|
215 | + } |
|
215 | 216 | } |
216 | 217 | } |
217 | 218 | } |
@@ -27,191 +27,191 @@ |
||
27 | 27 | class PagSeguroAuthorizationRequest |
28 | 28 | { |
29 | 29 | |
30 | - /*** |
|
30 | + /*** |
|
31 | 31 | * Reference code |
32 | 32 | * Optional. You can use the reference code to store an identifier so you can |
33 | 33 | * associate the PagSeguro transaction to a transaction in your system. |
34 | 34 | */ |
35 | - private $reference; |
|
35 | + private $reference; |
|
36 | 36 | |
37 | - /*** |
|
37 | + /*** |
|
38 | 38 | * Uri to where the PagSeguro payment page should redirect the user after the payment information is processed. |
39 | 39 | * Typically this is a confirmation page on your web site. |
40 | 40 | * @var String |
41 | 41 | */ |
42 | - private $redirectURL; |
|
42 | + private $redirectURL; |
|
43 | 43 | |
44 | - /*** |
|
44 | + /*** |
|
45 | 45 | * Determines for which url PagSeguro will send the order related notifications codes. |
46 | 46 | * Optional. Any change happens in the transaction status, a new notification request will be send |
47 | 47 | * to this url. You can use that for update the related order. |
48 | 48 | */ |
49 | - private $notificationURL; |
|
49 | + private $notificationURL; |
|
50 | 50 | |
51 | - /*** |
|
51 | + /*** |
|
52 | 52 | * Permission List |
53 | 53 | */ |
54 | - private $permissions; |
|
54 | + private $permissions; |
|
55 | 55 | |
56 | - /*** |
|
56 | + /*** |
|
57 | 57 | * Extra parameters that user can add to a PagSeguro authorization request |
58 | 58 | * |
59 | 59 | * Optional |
60 | 60 | * @var PagSeguroParameter |
61 | 61 | */ |
62 | - private $parameter; |
|
62 | + private $parameter; |
|
63 | 63 | |
64 | - /*** |
|
64 | + /*** |
|
65 | 65 | * Sets reference for PagSeguro authorization requests |
66 | 66 | * @param string $reference |
67 | 67 | */ |
68 | - public function setReference($reference) |
|
69 | - { |
|
70 | - $this->reference = $reference; |
|
71 | - } |
|
72 | - /*** |
|
68 | + public function setReference($reference) |
|
69 | + { |
|
70 | + $this->reference = $reference; |
|
71 | + } |
|
72 | + /*** |
|
73 | 73 | * @return string of $redirectURL |
74 | 74 | */ |
75 | - public function getReference() |
|
76 | - { |
|
77 | - return $this->reference; |
|
78 | - } |
|
75 | + public function getReference() |
|
76 | + { |
|
77 | + return $this->reference; |
|
78 | + } |
|
79 | 79 | |
80 | - /*** |
|
80 | + /*** |
|
81 | 81 | * Sets redirect URL for PagSeguro authorization requests |
82 | 82 | * @param string $redirectURL |
83 | 83 | */ |
84 | - public function setRedirectURL($redirectURL) |
|
85 | - { |
|
86 | - $this->redirectURL = $redirectURL; |
|
87 | - } |
|
88 | - /*** |
|
84 | + public function setRedirectURL($redirectURL) |
|
85 | + { |
|
86 | + $this->redirectURL = $redirectURL; |
|
87 | + } |
|
88 | + /*** |
|
89 | 89 | * @return string of $redirectURL |
90 | 90 | */ |
91 | - public function getRedirectURL() |
|
92 | - { |
|
93 | - return $this->redirectURL; |
|
94 | - } |
|
91 | + public function getRedirectURL() |
|
92 | + { |
|
93 | + return $this->redirectURL; |
|
94 | + } |
|
95 | 95 | |
96 | - /*** |
|
96 | + /*** |
|
97 | 97 | * Sets notificationURL for PagSeguro authorization requests |
98 | 98 | * @param string $notificationURL |
99 | 99 | */ |
100 | - public function setNotificationURL($notificationURL) |
|
101 | - { |
|
102 | - $this->permissions = $notificationURL; |
|
103 | - } |
|
100 | + public function setNotificationURL($notificationURL) |
|
101 | + { |
|
102 | + $this->permissions = $notificationURL; |
|
103 | + } |
|
104 | 104 | |
105 | - /*** |
|
105 | + /*** |
|
106 | 106 | * @return string of notificationURL |
107 | 107 | */ |
108 | - public function getNotificationURL() |
|
109 | - { |
|
110 | - return $this->notificationURL; |
|
111 | - } |
|
108 | + public function getNotificationURL() |
|
109 | + { |
|
110 | + return $this->notificationURL; |
|
111 | + } |
|
112 | 112 | |
113 | - /*** |
|
113 | + /*** |
|
114 | 114 | * @return array of permissions |
115 | 115 | */ |
116 | - public function getPermissions() |
|
117 | - { |
|
118 | - return $this->permissions; |
|
119 | - } |
|
116 | + public function getPermissions() |
|
117 | + { |
|
118 | + return $this->permissions; |
|
119 | + } |
|
120 | 120 | |
121 | - /*** |
|
121 | + /*** |
|
122 | 122 | * Sets permissions for PagSeguro authorization requests |
123 | 123 | * @param array $permissions |
124 | 124 | */ |
125 | - public function setPermissions(array $permissions) |
|
126 | - { |
|
127 | - $this->permissions = new PagSeguroAuthorizationPermissions($permissions); |
|
128 | - } |
|
125 | + public function setPermissions(array $permissions) |
|
126 | + { |
|
127 | + $this->permissions = new PagSeguroAuthorizationPermissions($permissions); |
|
128 | + } |
|
129 | 129 | |
130 | - /*** |
|
130 | + /*** |
|
131 | 131 | * Sets parameter for PagSeguro authorization requests |
132 | 132 | * |
133 | 133 | * @param PagSeguroParameter $parameter |
134 | 134 | */ |
135 | - public function setParameter($parameter) |
|
136 | - { |
|
137 | - $this->parameter = $parameter; |
|
138 | - } |
|
135 | + public function setParameter($parameter) |
|
136 | + { |
|
137 | + $this->parameter = $parameter; |
|
138 | + } |
|
139 | 139 | |
140 | - /*** |
|
140 | + /*** |
|
141 | 141 | * Gets parameter for PagSeguro authorization requests |
142 | 142 | * |
143 | 143 | * @return PagSeguroParameter |
144 | 144 | */ |
145 | - public function getParameter() |
|
146 | - { |
|
147 | - if ($this->parameter == null) { |
|
148 | - $this->parameter = new PagSeguroParameter(); |
|
149 | - } |
|
150 | - return $this->parameter; |
|
151 | - } |
|
145 | + public function getParameter() |
|
146 | + { |
|
147 | + if ($this->parameter == null) { |
|
148 | + $this->parameter = new PagSeguroParameter(); |
|
149 | + } |
|
150 | + return $this->parameter; |
|
151 | + } |
|
152 | 152 | |
153 | - /*** |
|
153 | + /*** |
|
154 | 154 | * add a parameter for PagSeguro authorization request |
155 | 155 | * |
156 | 156 | * @param PagSeguroParameterItem $parameterName key |
157 | 157 | * @param PagSeguroParameterItem $parameterValue value |
158 | 158 | */ |
159 | - public function addParameter($parameterName, $parameterValue) |
|
160 | - { |
|
161 | - $this->getParameter()->addItem(new PagSeguroParameterItem($parameterName, $parameterValue)); |
|
162 | - } |
|
159 | + public function addParameter($parameterName, $parameterValue) |
|
160 | + { |
|
161 | + $this->getParameter()->addItem(new PagSeguroParameterItem($parameterName, $parameterValue)); |
|
162 | + } |
|
163 | 163 | |
164 | - /*** |
|
164 | + /*** |
|
165 | 165 | * add a parameter for PagSeguro authorization request |
166 | 166 | * |
167 | 167 | * @param PagSeguroParameterItem $parameterName key |
168 | 168 | * @param PagSeguroParameterItem $parameterValue value |
169 | 169 | * @param PagSeguroParameterItem $parameterIndex group |
170 | 170 | */ |
171 | - public function addIndexedParameter($parameterName, $parameterValue, $parameterIndex) |
|
172 | - { |
|
173 | - $this->getParameter()->addItem(new PagSeguroParameterItem($parameterName, $parameterValue, $parameterIndex)); |
|
174 | - } |
|
171 | + public function addIndexedParameter($parameterName, $parameterValue, $parameterIndex) |
|
172 | + { |
|
173 | + $this->getParameter()->addItem(new PagSeguroParameterItem($parameterName, $parameterValue, $parameterIndex)); |
|
174 | + } |
|
175 | 175 | |
176 | - /*** |
|
176 | + /*** |
|
177 | 177 | * Calls the PagSeguro web service and register this request for authorization |
178 | 178 | * @param PagSeguroCredentials $credentials |
179 | 179 | * @param bool $onlyAuthorizationCode |
180 | 180 | * @return PagSeguroAuthorizationService Data |
181 | 181 | */ |
182 | - public function register(PagSeguroCredentials $credentials, $onlyAuthorizationCode = false) |
|
183 | - { |
|
184 | - return PagSeguroAuthorizationService::createAuthorizationRequest($credentials, $this, $onlyAuthorizationCode); |
|
185 | - } |
|
182 | + public function register(PagSeguroCredentials $credentials, $onlyAuthorizationCode = false) |
|
183 | + { |
|
184 | + return PagSeguroAuthorizationService::createAuthorizationRequest($credentials, $this, $onlyAuthorizationCode); |
|
185 | + } |
|
186 | 186 | |
187 | - /*** |
|
187 | + /*** |
|
188 | 188 | * @return String a string that represents the current object |
189 | 189 | */ |
190 | - public function toString() |
|
191 | - { |
|
190 | + public function toString() |
|
191 | + { |
|
192 | 192 | |
193 | - $request = array(); |
|
194 | - $request['Reference'] = $this->reference; |
|
193 | + $request = array(); |
|
194 | + $request['Reference'] = $this->reference; |
|
195 | 195 | |
196 | - return "PagSeguroAuthorizationRequest: " . implode(' - ', $request); |
|
197 | - } |
|
196 | + return "PagSeguroAuthorizationRequest: " . implode(' - ', $request); |
|
197 | + } |
|
198 | 198 | |
199 | - /*** |
|
199 | + /*** |
|
200 | 200 | * Verify if the adress of NotificationURL or RedirectURL is for tests and return empty |
201 | 201 | * @param type $url |
202 | 202 | * @return type |
203 | 203 | */ |
204 | - public function verifyURLTest($url) |
|
205 | - { |
|
206 | - $address = array('127.0.0.1','::1'); |
|
204 | + public function verifyURLTest($url) |
|
205 | + { |
|
206 | + $address = array('127.0.0.1','::1'); |
|
207 | 207 | |
208 | - foreach ($address as $item) { |
|
209 | - $find = strpos($url, $item); |
|
208 | + foreach ($address as $item) { |
|
209 | + $find = strpos($url, $item); |
|
210 | 210 | |
211 | - if ($find) |
|
212 | - return false; |
|
213 | - else |
|
214 | - return $url; |
|
215 | - } |
|
216 | - } |
|
211 | + if ($find) |
|
212 | + return false; |
|
213 | + else |
|
214 | + return $url; |
|
215 | + } |
|
216 | + } |
|
217 | 217 | } |
@@ -152,7 +152,7 @@ |
||
152 | 152 | $authorizations['TotalPages'] = $this->totalPages; |
153 | 153 | $authorizations['Transactions in this page'] = $this->resultsInThisPage; |
154 | 154 | |
155 | - return "PagSeguroAuthorizationsSearchResult: " . implode(' - ', $authorizations); |
|
155 | + return "PagSeguroAuthorizationsSearchResult: ".implode(' - ', $authorizations); |
|
156 | 156 | |
157 | 157 | } |
158 | 158 | } |
@@ -27,132 +27,132 @@ |
||
27 | 27 | class PagSeguroAuthorizationSearchResult |
28 | 28 | { |
29 | 29 | |
30 | - /*** |
|
30 | + /*** |
|
31 | 31 | * Date/time when this search was executed |
32 | 32 | */ |
33 | - private $date; |
|
33 | + private $date; |
|
34 | 34 | |
35 | - /*** |
|
35 | + /*** |
|
36 | 36 | * Authorizations in the current page |
37 | 37 | */ |
38 | - private $resultsInThisPage; |
|
38 | + private $resultsInThisPage; |
|
39 | 39 | |
40 | - /*** |
|
40 | + /*** |
|
41 | 41 | * Total number of pages |
42 | 42 | */ |
43 | - private $totalPages; |
|
43 | + private $totalPages; |
|
44 | 44 | |
45 | - /*** |
|
45 | + /*** |
|
46 | 46 | * Current page. |
47 | 47 | */ |
48 | - private $currentPage; |
|
48 | + private $currentPage; |
|
49 | 49 | |
50 | - /*** |
|
50 | + /*** |
|
51 | 51 | * Authorization summaries in this page |
52 | 52 | */ |
53 | - private $authorizations; |
|
53 | + private $authorizations; |
|
54 | 54 | |
55 | - /*** |
|
55 | + /*** |
|
56 | 56 | * @return the current page number |
57 | 57 | */ |
58 | - public function getCurrentPage() |
|
59 | - { |
|
60 | - return $this->currentPage; |
|
61 | - } |
|
58 | + public function getCurrentPage() |
|
59 | + { |
|
60 | + return $this->currentPage; |
|
61 | + } |
|
62 | 62 | |
63 | - /*** |
|
63 | + /*** |
|
64 | 64 | * Sets the current page number |
65 | 65 | * @param integer $currentPage |
66 | 66 | */ |
67 | - public function setCurrentPage($currentPage) |
|
68 | - { |
|
69 | - $this->currentPage = $currentPage; |
|
70 | - } |
|
67 | + public function setCurrentPage($currentPage) |
|
68 | + { |
|
69 | + $this->currentPage = $currentPage; |
|
70 | + } |
|
71 | 71 | |
72 | - /*** |
|
72 | + /*** |
|
73 | 73 | * @return the date/time when this search was executed |
74 | 74 | */ |
75 | - public function getDate() |
|
76 | - { |
|
77 | - return $this->date; |
|
78 | - } |
|
75 | + public function getDate() |
|
76 | + { |
|
77 | + return $this->date; |
|
78 | + } |
|
79 | 79 | |
80 | - /*** |
|
80 | + /*** |
|
81 | 81 | * Set the date/time when this search was executed |
82 | 82 | * @param date |
83 | 83 | */ |
84 | - public function setDate($date) |
|
85 | - { |
|
86 | - $this->date = $date; |
|
87 | - } |
|
84 | + public function setDate($date) |
|
85 | + { |
|
86 | + $this->date = $date; |
|
87 | + } |
|
88 | 88 | |
89 | - /*** |
|
89 | + /*** |
|
90 | 90 | * @return the number of authorizations summaries in the current page |
91 | 91 | */ |
92 | - public function getResultsInThisPage() |
|
93 | - { |
|
94 | - return $this->resultsInThisPage; |
|
95 | - } |
|
92 | + public function getResultsInThisPage() |
|
93 | + { |
|
94 | + return $this->resultsInThisPage; |
|
95 | + } |
|
96 | 96 | |
97 | - /*** |
|
97 | + /*** |
|
98 | 98 | * Sets the number of authorizations summaries in the current page |
99 | 99 | * |
100 | 100 | * @param resultsInThisPage |
101 | 101 | */ |
102 | - public function setResultsInThisPage($resultsInThisPage) |
|
103 | - { |
|
104 | - $this->resultsInThisPage = $resultsInThisPage; |
|
105 | - } |
|
102 | + public function setResultsInThisPage($resultsInThisPage) |
|
103 | + { |
|
104 | + $this->resultsInThisPage = $resultsInThisPage; |
|
105 | + } |
|
106 | 106 | |
107 | - /*** |
|
107 | + /*** |
|
108 | 108 | * @return the total number of pages |
109 | 109 | */ |
110 | - public function getTotalPages() |
|
111 | - { |
|
112 | - return $this->totalPages; |
|
113 | - } |
|
110 | + public function getTotalPages() |
|
111 | + { |
|
112 | + return $this->totalPages; |
|
113 | + } |
|
114 | 114 | |
115 | - /*** |
|
115 | + /*** |
|
116 | 116 | * Sets the total number of pages |
117 | 117 | * |
118 | 118 | * @param totalPages |
119 | 119 | */ |
120 | - public function setTotalPages($totalPages) |
|
121 | - { |
|
122 | - $this->totalPages = $totalPages; |
|
123 | - } |
|
120 | + public function setTotalPages($totalPages) |
|
121 | + { |
|
122 | + $this->totalPages = $totalPages; |
|
123 | + } |
|
124 | 124 | |
125 | - /*** |
|
125 | + /*** |
|
126 | 126 | * @return PagSeguroAuthorizations the authorizations summaries in this page |
127 | 127 | * @see PagSeguroAuthorizations |
128 | 128 | */ |
129 | - public function getAuthorizations() |
|
130 | - { |
|
131 | - return $this->authorizations; |
|
132 | - } |
|
129 | + public function getAuthorizations() |
|
130 | + { |
|
131 | + return $this->authorizations; |
|
132 | + } |
|
133 | 133 | |
134 | - /*** |
|
134 | + /*** |
|
135 | 135 | * Sets the authorizations summaries in this page |
136 | 136 | * @param PagSeguroAuthorization $authorizations |
137 | 137 | */ |
138 | - public function setAuthorizations($authorizations) |
|
139 | - { |
|
140 | - $this->authorizations = $authorizations; |
|
141 | - } |
|
138 | + public function setAuthorizations($authorizations) |
|
139 | + { |
|
140 | + $this->authorizations = $authorizations; |
|
141 | + } |
|
142 | 142 | |
143 | - /*** |
|
143 | + /*** |
|
144 | 144 | * @return String a string that represents the current object |
145 | 145 | */ |
146 | - public function toString() |
|
147 | - { |
|
148 | - $authorizations = array(); |
|
146 | + public function toString() |
|
147 | + { |
|
148 | + $authorizations = array(); |
|
149 | 149 | |
150 | - $authorizations['Date'] = $this->date; |
|
151 | - $authorizations['CurrentPage'] = $this->currentPage; |
|
152 | - $authorizations['TotalPages'] = $this->totalPages; |
|
153 | - $authorizations['Transactions in this page'] = $this->resultsInThisPage; |
|
150 | + $authorizations['Date'] = $this->date; |
|
151 | + $authorizations['CurrentPage'] = $this->currentPage; |
|
152 | + $authorizations['TotalPages'] = $this->totalPages; |
|
153 | + $authorizations['Transactions in this page'] = $this->resultsInThisPage; |
|
154 | 154 | |
155 | - return "PagSeguroAuthorizationsSearchResult: " . implode(' - ', $authorizations); |
|
155 | + return "PagSeguroAuthorizationsSearchResult: " . implode(' - ', $authorizations); |
|
156 | 156 | |
157 | - } |
|
157 | + } |
|
158 | 158 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | */ |
40 | 40 | public function __construct($data = null) |
41 | 41 | { |
42 | - if (isset($data) and is_array($data)){ |
|
42 | + if (isset($data) and is_array($data)) { |
|
43 | 43 | $this->setAddress(new PagSeguroAddress($data)); |
44 | 44 | } elseif ($data instanceof PagSeguroAddress) { |
45 | 45 | $this->setAddress($data); |
@@ -27,41 +27,41 @@ |
||
27 | 27 | class PagSeguroBilling |
28 | 28 | { |
29 | 29 | |
30 | - /*** |
|
30 | + /*** |
|
31 | 31 | * Billing Address |
32 | 32 | * @see PagSeguroAddress |
33 | 33 | */ |
34 | - private $address; |
|
34 | + private $address; |
|
35 | 35 | |
36 | - /*** |
|
36 | + /*** |
|
37 | 37 | * Initializes a new instance of the PagSeguroBilling class |
38 | 38 | * @param $data |
39 | 39 | */ |
40 | - public function __construct($data = null) |
|
41 | - { |
|
42 | - if (isset($data) and is_array($data)){ |
|
43 | - $this->setAddress(new PagSeguroAddress($data)); |
|
44 | - } elseif ($data instanceof PagSeguroAddress) { |
|
45 | - $this->setAddress($data); |
|
46 | - } |
|
47 | - } |
|
40 | + public function __construct($data = null) |
|
41 | + { |
|
42 | + if (isset($data) and is_array($data)){ |
|
43 | + $this->setAddress(new PagSeguroAddress($data)); |
|
44 | + } elseif ($data instanceof PagSeguroAddress) { |
|
45 | + $this->setAddress($data); |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | - /*** |
|
49 | + /*** |
|
50 | 50 | * Sets the billing address |
51 | 51 | * @see PagSeguroAddress |
52 | 52 | * @param PagSeguroAddress $address |
53 | 53 | */ |
54 | - public function setAddress(PagSeguroAddress $address) |
|
55 | - { |
|
56 | - $this->address = $address; |
|
57 | - } |
|
54 | + public function setAddress(PagSeguroAddress $address) |
|
55 | + { |
|
56 | + $this->address = $address; |
|
57 | + } |
|
58 | 58 | |
59 | - /*** |
|
59 | + /*** |
|
60 | 60 | * @return PagSeguroAddress the billing address |
61 | 61 | * @see PagSeguroAddress |
62 | 62 | */ |
63 | - public function getAddress() |
|
64 | - { |
|
65 | - return $this->address; |
|
66 | - } |
|
63 | + public function getAddress() |
|
64 | + { |
|
65 | + return $this->address; |
|
66 | + } |
|
67 | 67 | } |
68 | 68 | \ No newline at end of file |