@@ -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; |
@@ -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>'; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | /** |
| 83 | 83 | * Outputs the endpoint URL and request JSON in a human readable format |
| 84 | 84 | * |
| 85 | - * @return array list of event types |
|
| 85 | + * @return AuthnetWebhooksResponse list of event types |
|
| 86 | 86 | */ |
| 87 | 87 | public function getEventTypes() |
| 88 | 88 | {
|
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @throws \JohnConde\Authnet\AuthnetInvalidParameterException |
| 103 | 103 | * |
| 104 | - * @return array list of event types |
|
| 104 | + * @return AuthnetWebhooksResponse list of event types |
|
| 105 | 105 | */ |
| 106 | 106 | public function createWebhooks(Array $webhooks, $webhookUrl, $status = 'active') |
| 107 | 107 | {
|
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | /** |
| 136 | 136 | * List all of your webhooks |
| 137 | 137 | * |
| 138 | - * @return array list of event types |
|
| 138 | + * @return AuthnetWebhooksResponse list of event types |
|
| 139 | 139 | */ |
| 140 | 140 | public function getWebhooks() |
| 141 | 141 | {
|
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @param string $webhookId Webhook ID to be retrieved |
| 152 | 152 | * |
| 153 | - * @return array list of event types |
|
| 153 | + * @return AuthnetWebhooksResponse list of event types |
|
| 154 | 154 | */ |
| 155 | 155 | public function getWebhook($webhookId) |
| 156 | 156 | {
|
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * |
| 171 | 171 | * @throws \JohnConde\Authnet\AuthnetInvalidParameterException |
| 172 | 172 | * |
| 173 | - * @return array list of event types |
|
| 173 | + * @return AuthnetWebhooksResponse list of event types |
|
| 174 | 174 | */ |
| 175 | 175 | public function updateWebhook($webhookId, $webhookUrl, Array $eventTypes, $status = 'active') |
| 176 | 176 | {
|
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * @param integer $limit Default: 1000 |
| 207 | 207 | * @param integer $offset Default: 0 |
| 208 | 208 | * |
| 209 | - * @return array list of event types |
|
| 209 | + * @return AuthnetWebhooksResponse list of event types |
|
| 210 | 210 | */ |
| 211 | 211 | public function getNotificationHistory($limit = 1000, $offset = 0) |
| 212 | 212 | {
|
@@ -250,6 +250,7 @@ discard block |
||
| 250 | 250 | * @throws \JohnConde\Authnet\AuthnetCurlException |
| 251 | 251 | * |
| 252 | 252 | * @codeCoverageIgnore |
| 253 | + * @return string |
|
| 253 | 254 | */ |
| 254 | 255 | private function get($url) {
|
| 255 | 256 | $this->processor->get($url); |
@@ -265,6 +266,7 @@ discard block |
||
| 265 | 266 | * @throws \JohnConde\Authnet\AuthnetCurlException |
| 266 | 267 | * |
| 267 | 268 | * @codeCoverageIgnore |
| 269 | + * @return string |
|
| 268 | 270 | */ |
| 269 | 271 | private function post($url, $request) {
|
| 270 | 272 | $this->processor->post($url, $request); |
@@ -280,6 +282,7 @@ discard block |
||
| 280 | 282 | * @throws \JohnConde\Authnet\AuthnetCurlException |
| 281 | 283 | * |
| 282 | 284 | * @codeCoverageIgnore |
| 285 | + * @return string |
|
| 283 | 286 | */ |
| 284 | 287 | private function put($url, $request) {
|
| 285 | 288 | $this->processor->put($url, $request, true); |
@@ -303,7 +306,7 @@ discard block |
||
| 303 | 306 | /** |
| 304 | 307 | * Sets the handler to be used to handle our API call. Mainly used for unit testing as Curl is used by default. |
| 305 | 308 | * |
| 306 | - * @param object $processor |
|
| 309 | + * @param \Curl\Curl $processor |
|
| 307 | 310 | */ |
| 308 | 311 | public function setProcessHandler($processor) |
| 309 | 312 | {
|