@@ -32,7 +32,7 @@ |
||
| 32 | 32 | } |
| 33 | 33 | $cn = strtolower($class); |
| 34 | 34 | if (isset($classes[$cn])) {
|
| 35 | - require(__DIR__ . $classes[$cn]); |
|
| 35 | + require(__DIR__.$classes[$cn]); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | ); |
@@ -224,10 +224,10 @@ |
||
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | - * Gets the transaction response from Authorize.Net in JSON format for logging purposes |
|
| 228 | - * |
|
| 229 | - * @return string transaction response from Authorize.Net in JSON format |
|
| 230 | - */ |
|
| 227 | + * Gets the transaction response from Authorize.Net in JSON format for logging purposes |
|
| 228 | + * |
|
| 229 | + * @return string transaction response from Authorize.Net in JSON format |
|
| 230 | + */ |
|
| 231 | 231 | public function getRawResponse() |
| 232 | 232 | { |
| 233 | 233 | return $this->responseJson; |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | public function __toString() |
| 131 | 131 | { |
| 132 | 132 | $output = ''; |
| 133 | - $output .= '<table summary="Authorize.Net Response" id="authnet-response">' . "\n"; |
|
| 134 | - $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Response JSON</b></th>' . "\n" . '</tr>' . "\n"; |
|
| 135 | - $output .= '<tr><td colspan="2"><pre>' . "\n"; |
|
| 136 | - $output .= $this->responseJson . "\n"; |
|
| 137 | - $output .= '</pre></td></tr>' . "\n"; |
|
| 133 | + $output .= '<table summary="Authorize.Net Response" id="authnet-response">'."\n"; |
|
| 134 | + $output .= '<tr>'."\n\t\t".'<th colspan="2"><b>Response JSON</b></th>'."\n".'</tr>'."\n"; |
|
| 135 | + $output .= '<tr><td colspan="2"><pre>'."\n"; |
|
| 136 | + $output .= $this->responseJson."\n"; |
|
| 137 | + $output .= '</pre></td></tr>'."\n"; |
|
| 138 | 138 | $output .= '</table>'; |
| 139 | 139 | |
| 140 | 140 | return $output; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function isApproved() |
| 180 | 180 | { |
| 181 | - return $this->isSuccessful() && $this->checkTransactionStatus(self::STATUS_APPROVED) ; |
|
| 181 | + return $this->isSuccessful() && $this->checkTransactionStatus(self::STATUS_APPROVED); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | */ |
| 189 | 189 | public function isDeclined() |
| 190 | 190 | { |
| 191 | - return $this->isSuccessful() && $this->checkTransactionStatus(self::STATUS_DECLINED) ; |
|
| 191 | + return $this->isSuccessful() && $this->checkTransactionStatus(self::STATUS_DECLINED); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
@@ -201,8 +201,7 @@ |
||
| 201 | 201 | { |
| 202 | 202 | if ($this->transactionInfo instanceof TransactionResponse) { |
| 203 | 203 | $match = (int) $this->transactionInfo->getTransactionResponseField('ResponseCode') === (int) $status; |
| 204 | - } |
|
| 205 | - else { |
|
| 204 | + } else { |
|
| 206 | 205 | $match = (int) $this->transactionResponse->responseCode === $status; |
| 207 | 206 | } |
| 208 | 207 | return $match; |
@@ -101,8 +101,7 @@ |
||
| 101 | 101 | $value = null; |
| 102 | 102 | if (is_int($field)) {
|
| 103 | 103 | $value = (isset($this->responseArray[$field])) ? $this->responseArray[$field] : $value; |
| 104 | - } |
|
| 105 | - else {
|
|
| 104 | + } else {
|
|
| 106 | 105 | if ($key = array_search($field, $this->fieldMap)) {
|
| 107 | 106 | $value = $this->responseArray[$key]; |
| 108 | 107 | } |
@@ -82,7 +82,7 @@ |
||
| 82 | 82 | $this->sequence, |
| 83 | 83 | $this->timestamp, |
| 84 | 84 | $amount |
| 85 | - ), $this->transactionKey); |
|
| 85 | + ), $this->transactionKey); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -60,11 +60,11 @@ |
||
| 60 | 60 | public function __toString() |
| 61 | 61 | { |
| 62 | 62 | $output = ''; |
| 63 | - $output .= '<table summary="Authorize.Net Webhooks Response" id="authnet-response">' . "\n"; |
|
| 64 | - $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Response JSON</b></th>' . "\n" . '</tr>' . "\n"; |
|
| 65 | - $output .= '<tr><td colspan="2"><pre>' . "\n"; |
|
| 66 | - $output .= $this->responseJson . "\n"; |
|
| 67 | - $output .= '</pre></td></tr>' . "\n"; |
|
| 63 | + $output .= '<table summary="Authorize.Net Webhooks Response" id="authnet-response">'."\n"; |
|
| 64 | + $output .= '<tr>'."\n\t\t".'<th colspan="2"><b>Response JSON</b></th>'."\n".'</tr>'."\n"; |
|
| 65 | + $output .= '<tr><td colspan="2"><pre>'."\n"; |
|
| 66 | + $output .= $this->responseJson."\n"; |
|
| 67 | + $output .= '</pre></td></tr>'."\n"; |
|
| 68 | 68 | $output .= '</table>'; |
| 69 | 69 | |
| 70 | 70 | return $output; |
@@ -104,8 +104,7 @@ |
||
| 104 | 104 | foreach ($this->response->eventTypes as $event) { |
| 105 | 105 | $events[] = $event; |
| 106 | 106 | } |
| 107 | - } |
|
| 108 | - else { |
|
| 107 | + } else { |
|
| 109 | 108 | foreach ($this->response as $event) { |
| 110 | 109 | $events[] = $event->name; |
| 111 | 110 | } |
@@ -83,14 +83,11 @@ discard block |
||
| 83 | 83 | {
|
| 84 | 84 | if ($server === static::USE_PRODUCTION_SERVER) {
|
| 85 | 85 | $url = 'https://api.authorize.net/xml/v1/request.api'; |
| 86 | - } |
|
| 87 | - else if ($server === static::USE_DEVELOPMENT_SERVER) {
|
|
| 86 | + } else if ($server === static::USE_DEVELOPMENT_SERVER) {
|
|
| 88 | 87 | $url = 'https://apitest.authorize.net/xml/v1/request.api'; |
| 89 | - } |
|
| 90 | - else if ($server === static::USE_AKAMAI_SERVER) {
|
|
| 88 | + } else if ($server === static::USE_AKAMAI_SERVER) {
|
|
| 91 | 89 | $url = 'https://api2.authorize.net/xml/v1/request.api'; |
| 92 | - } |
|
| 93 | - else {
|
|
| 90 | + } else {
|
|
| 94 | 91 | throw new AuthnetInvalidServerException('You did not provide a valid server.');
|
| 95 | 92 | } |
| 96 | 93 | return $url; |
@@ -129,11 +126,9 @@ discard block |
||
| 129 | 126 | {
|
| 130 | 127 | if ($server === static::USE_PRODUCTION_SERVER) {
|
| 131 | 128 | $url = 'https://secure2.authorize.net/gateway/transact.dll'; |
| 132 | - } |
|
| 133 | - else if ($server === static::USE_DEVELOPMENT_SERVER) {
|
|
| 129 | + } else if ($server === static::USE_DEVELOPMENT_SERVER) {
|
|
| 134 | 130 | $url = 'https://test.authorize.net/gateway/transact.dll'; |
| 135 | - } |
|
| 136 | - else {
|
|
| 131 | + } else {
|
|
| 137 | 132 | throw new AuthnetInvalidServerException('You did not provide a valid server.');
|
| 138 | 133 | } |
| 139 | 134 | return $url; |
@@ -184,11 +179,9 @@ discard block |
||
| 184 | 179 | {
|
| 185 | 180 | if ($server === static::USE_PRODUCTION_SERVER) {
|
| 186 | 181 | $url = 'https://api.authorize.net/rest/v1/'; |
| 187 | - } |
|
| 188 | - else if ($server === static::USE_DEVELOPMENT_SERVER) {
|
|
| 182 | + } else if ($server === static::USE_DEVELOPMENT_SERVER) {
|
|
| 189 | 183 | $url = 'https://apitest.authorize.net/rest/v1/'; |
| 190 | - } |
|
| 191 | - else {
|
|
| 184 | + } else {
|
|
| 192 | 185 | throw new AuthnetInvalidServerException('You did not provide a valid server.');
|
| 193 | 186 | } |
| 194 | 187 | return $url; |
@@ -105,16 +105,16 @@ discard block |
||
| 105 | 105 | public function __toString() |
| 106 | 106 | {
|
| 107 | 107 | $output = ''; |
| 108 | - $output .= '<table summary="Authorize.Net Request" id="authnet-request">' . "\n"; |
|
| 109 | - $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Class Parameters</b></th>' . "\n" . '</tr>' . "\n"; |
|
| 110 | - $output .= '<tr>' . "\n\t\t" . '<td><b>API Login ID</b></td><td>' . $this->login . '</td>' . "\n" . '</tr>' . "\n"; |
|
| 111 | - $output .= '<tr>' . "\n\t\t" . '<td><b>Transaction Key</b></td><td>' . $this->transactionKey . '</td>' . "\n" . '</tr>' . "\n"; |
|
| 112 | - $output .= '<tr>' . "\n\t\t" . '<td><b>Authnet Server URL</b></td><td>' . $this->url . '</td>' . "\n" . '</tr>' . "\n"; |
|
| 113 | - $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Request JSON</b></th>' . "\n" . '</tr>' . "\n"; |
|
| 108 | + $output .= '<table summary="Authorize.Net Request" id="authnet-request">'."\n"; |
|
| 109 | + $output .= '<tr>'."\n\t\t".'<th colspan="2"><b>Class Parameters</b></th>'."\n".'</tr>'."\n"; |
|
| 110 | + $output .= '<tr>'."\n\t\t".'<td><b>API Login ID</b></td><td>'.$this->login.'</td>'."\n".'</tr>'."\n"; |
|
| 111 | + $output .= '<tr>'."\n\t\t".'<td><b>Transaction Key</b></td><td>'.$this->transactionKey.'</td>'."\n".'</tr>'."\n"; |
|
| 112 | + $output .= '<tr>'."\n\t\t".'<td><b>Authnet Server URL</b></td><td>'.$this->url.'</td>'."\n".'</tr>'."\n"; |
|
| 113 | + $output .= '<tr>'."\n\t\t".'<th colspan="2"><b>Request JSON</b></th>'."\n".'</tr>'."\n"; |
|
| 114 | 114 | if (!empty($this->requestJson)) {
|
| 115 | - $output .= '<tr><td colspan="2"><pre>' . "\n"; |
|
| 116 | - $output .= $this->requestJson . "\n"; |
|
| 117 | - $output .= '</pre></td></tr>' . "\n"; |
|
| 115 | + $output .= '<tr><td colspan="2"><pre>'."\n"; |
|
| 116 | + $output .= $this->requestJson."\n"; |
|
| 117 | + $output .= '</pre></td></tr>'."\n"; |
|
| 118 | 118 | } |
| 119 | 119 | $output .= '</table>'; |
| 120 | 120 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public function __set($name, $value) |
| 132 | 132 | {
|
| 133 | - throw new AuthnetCannotSetParamsException('You cannot set parameters directly in ' . __CLASS__ . '.');
|
|
| 133 | + throw new AuthnetCannotSetParamsException('You cannot set parameters directly in '.__CLASS__.'.');
|
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | {
|
| 172 | 172 | $this->processor->post($this->url, $this->requestJson); |
| 173 | 173 | |
| 174 | - if(!$this->processor->error) {
|
|
| 174 | + if (!$this->processor->error) {
|
|
| 175 | 175 | return $this->processor->response; |
| 176 | 176 | } |
| 177 | 177 | $error_message = null; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $error_message = $this->processor->error_message; |
| 181 | 181 | $error_code = $this->processor->error_code; |
| 182 | 182 | } |
| 183 | - throw new AuthnetCurlException('Connection error: ' . $error_message . ' (' . $error_code . ')');
|
|
| 183 | + throw new AuthnetCurlException('Connection error: '.$error_message.' ('.$error_code.')');
|
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -69,15 +69,15 @@ |
||
| 69 | 69 | public function __toString() |
| 70 | 70 | { |
| 71 | 71 | $output = ''; |
| 72 | - $output .= '<table summary="Authorize.Net Webhook" id="authnet-webhook">' . "\n"; |
|
| 73 | - $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Response HTTP Headers</b></th>' . "\n" . '</tr>' . "\n"; |
|
| 74 | - $output .= '<tr><td colspan="2"><pre>' . "\n"; |
|
| 75 | - $output .= var_export($this->headers) . "\n"; |
|
| 76 | - $output .= '</pre></td></tr>' . "\n"; |
|
| 77 | - $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Response JSON</b></th>' . "\n" . '</tr>' . "\n"; |
|
| 78 | - $output .= '<tr><td colspan="2"><pre>' . "\n"; |
|
| 79 | - $output .= $this->webhookJson . "\n"; |
|
| 80 | - $output .= '</pre></td></tr>' . "\n"; |
|
| 72 | + $output .= '<table summary="Authorize.Net Webhook" id="authnet-webhook">'."\n"; |
|
| 73 | + $output .= '<tr>'."\n\t\t".'<th colspan="2"><b>Response HTTP Headers</b></th>'."\n".'</tr>'."\n"; |
|
| 74 | + $output .= '<tr><td colspan="2"><pre>'."\n"; |
|
| 75 | + $output .= var_export($this->headers)."\n"; |
|
| 76 | + $output .= '</pre></td></tr>'."\n"; |
|
| 77 | + $output .= '<tr>'."\n\t\t".'<th colspan="2"><b>Response JSON</b></th>'."\n".'</tr>'."\n"; |
|
| 78 | + $output .= '<tr><td colspan="2"><pre>'."\n"; |
|
| 79 | + $output .= $this->webhookJson."\n"; |
|
| 80 | + $output .= '</pre></td></tr>'."\n"; |
|
| 81 | 81 | $output .= '</table>'; |
| 82 | 82 | |
| 83 | 83 | return $output; |
@@ -132,8 +132,7 @@ |
||
| 132 | 132 | $headers = []; |
| 133 | 133 | if (function_exists('apache_request_headers')) { |
| 134 | 134 | $headers = apache_request_headers(); |
| 135 | - } |
|
| 136 | - else { |
|
| 135 | + } else { |
|
| 137 | 136 | foreach ($_SERVER as $name => $value) { |
| 138 | 137 | if (substr($name, 0, 5) == 'HTTP_') { |
| 139 | 138 | $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; |
@@ -62,17 +62,17 @@ discard block |
||
| 62 | 62 | public function __toString() |
| 63 | 63 | {
|
| 64 | 64 | $output = ''; |
| 65 | - $output .= '<table summary="Authorize.Net Request" id="authnet-request">' . "\n"; |
|
| 66 | - $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Class Parameters</b></th>' . "\n" . '</tr>' . "\n"; |
|
| 67 | - $output .= '<tr>' . "\n\t\t" . '<td><b>Authnet Server URL</b></td><td>' . $this->url . '</td>' . "\n" . '</tr>' . "\n"; |
|
| 68 | - $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Request JSON</b></th>' . "\n" . '</tr>' . "\n"; |
|
| 65 | + $output .= '<table summary="Authorize.Net Request" id="authnet-request">'."\n"; |
|
| 66 | + $output .= '<tr>'."\n\t\t".'<th colspan="2"><b>Class Parameters</b></th>'."\n".'</tr>'."\n"; |
|
| 67 | + $output .= '<tr>'."\n\t\t".'<td><b>Authnet Server URL</b></td><td>'.$this->url.'</td>'."\n".'</tr>'."\n"; |
|
| 68 | + $output .= '<tr>'."\n\t\t".'<th colspan="2"><b>Request JSON</b></th>'."\n".'</tr>'."\n"; |
|
| 69 | 69 | if (!empty($this->requestJson)) {
|
| 70 | - $output .= '<tr><td colspan="2"><pre>' . "\n"; |
|
| 71 | - $output .= $this->requestJson . "\n"; |
|
| 72 | - $output .= '</pre></td></tr>' . "\n"; |
|
| 70 | + $output .= '<tr><td colspan="2"><pre>'."\n"; |
|
| 71 | + $output .= $this->requestJson."\n"; |
|
| 72 | + $output .= '</pre></td></tr>'."\n"; |
|
| 73 | 73 | } |
| 74 | 74 | else {
|
| 75 | - $output .= '<tr><td colspan="2" style="text-align: center;"><pre>N/A</pre></td></tr>' . "\n"; |
|
| 75 | + $output .= '<tr><td colspan="2" style="text-align: center;"><pre>N/A</pre></td></tr>'."\n"; |
|
| 76 | 76 | } |
| 77 | 77 | $output .= '</table>'; |
| 78 | 78 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | private function handleResponse() |
| 228 | 228 | {
|
| 229 | - if(!$this->processor->error) {
|
|
| 229 | + if (!$this->processor->error) {
|
|
| 230 | 230 | return $this->processor->response; |
| 231 | 231 | } |
| 232 | 232 | $error_message = null; |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $error_message = sprintf('(%u) %s: %s', $response->status, $response->reason, $response->message);
|
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | - throw new AuthnetCurlException('Connection error: ' . $error_message . ' (' . $error_code . ')');
|
|
| 242 | + throw new AuthnetCurlException('Connection error: '.$error_message.' ('.$error_code.')');
|
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -70,8 +70,7 @@ |
||
| 70 | 70 | $output .= '<tr><td colspan="2"><pre>' . "\n"; |
| 71 | 71 | $output .= $this->requestJson . "\n"; |
| 72 | 72 | $output .= '</pre></td></tr>' . "\n"; |
| 73 | - } |
|
| 74 | - else {
|
|
| 73 | + } else {
|
|
| 75 | 74 | $output .= '<tr><td colspan="2" style="text-align: center;"><pre>N/A</pre></td></tr>' . "\n"; |
| 76 | 75 | } |
| 77 | 76 | $output .= '</table>'; |