@@ -166,6 +166,7 @@ discard block |
||
| 166 | 166 | * Tells the handler to make the API call to Authorize.Net |
| 167 | 167 | * |
| 168 | 168 | * @throws \JohnConde\Authnet\AuthnetInvalidJsonException |
| 169 | + * @return string |
|
| 169 | 170 | */ |
| 170 | 171 | private function process() |
| 171 | 172 | {
|
@@ -175,7 +176,7 @@ discard block |
||
| 175 | 176 | /** |
| 176 | 177 | * Sets the handler to be used to handle our API call |
| 177 | 178 | * |
| 178 | - * @param object $processor |
|
| 179 | + * @param CurlWrapper $processor |
|
| 179 | 180 | */ |
| 180 | 181 | public function setProcessHandler($processor) |
| 181 | 182 | {
|
@@ -90,21 +90,21 @@ discard block |
||
| 90 | 90 | * @param string $transactionKey Authorize.Net API Transaction Key |
| 91 | 91 | * @param string $api_url URL endpoint for processing a transaction |
| 92 | 92 | */ |
| 93 | - public function __construct($login, $transactionKey, $api_url) |
|
| 94 | - {
|
|
| 95 | - $this->login = $login; |
|
| 93 | + public function __construct($login, $transactionKey, $api_url) |
|
| 94 | + {
|
|
| 95 | + $this->login = $login; |
|
| 96 | 96 | $this->transactionKey = $transactionKey; |
| 97 | 97 | $this->url = $api_url; |
| 98 | - } |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Outputs the account credentials, endpoint URL, and request JSON in a human readable format |
| 102 | 102 | * |
| 103 | 103 | * @return string HTML table containing debugging information |
| 104 | 104 | */ |
| 105 | - public function __toString() |
|
| 106 | - {
|
|
| 107 | - $output = ''; |
|
| 105 | + public function __toString() |
|
| 106 | + {
|
|
| 107 | + $output = ''; |
|
| 108 | 108 | $output .= '<table summary="Authorize.Net Request" id="authnet-request">' . "\n"; |
| 109 | 109 | $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Class Parameters</b></th>' . "\n" . '</tr>' . "\n"; |
| 110 | 110 | $output .= '<tr>' . "\n\t\t" . '<td><b>API Login ID</b></td><td>' . $this->login . '</td>' . "\n" . '</tr>' . "\n"; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $output .= '</table>'; |
| 120 | 120 | |
| 121 | 121 | return $output; |
| 122 | - } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * The __set() method should never be used as all values to ba made in the APi call must be passed as an array |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | * @throws \JohnConde\Authnet\AuthnetCannotSetParamsException |
| 130 | 130 | */ |
| 131 | 131 | public function __set($name, $value) |
| 132 | - {
|
|
| 132 | + {
|
|
| 133 | 133 | throw new AuthnetCannotSetParamsException('You cannot set parameters directly in ' . __CLASS__ . '.');
|
| 134 | - } |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * Magic method that dynamically creates our API call based on the name of the method in the client code and |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @returns null |
| 143 | 143 | */ |
| 144 | 144 | public function __call($api_call, Array $args) |
| 145 | - {
|
|
| 145 | + {
|
|
| 146 | 146 | $authentication = array( |
| 147 | 147 | 'merchantAuthentication' => array( |
| 148 | 148 | 'name' => $this->login, |
@@ -158,9 +158,9 @@ discard block |
||
| 158 | 158 | ); |
| 159 | 159 | $this->requestJson = json_encode($parameters); |
| 160 | 160 | |
| 161 | - $response = $this->process(); |
|
| 161 | + $response = $this->process(); |
|
| 162 | 162 | return new AuthnetJsonResponse($response); |
| 163 | - } |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | 166 | * Tells the handler to make the API call to Authorize.Net |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function __construct($login, $transactionKey, $api_url) |
| 94 | 94 | {
|
| 95 | - $this->login = $login; |
|
| 95 | + $this->login = $login; |
|
| 96 | 96 | $this->transactionKey = $transactionKey; |
| 97 | 97 | $this->url = $api_url; |
| 98 | 98 | } |
@@ -104,17 +104,17 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function __toString() |
| 106 | 106 | {
|
| 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"; |
|
| 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"; |
|
| 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 | /** |
@@ -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 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | public function process($url, $json) |
| 39 | 39 | {
|
| 40 | 40 | $response = $this->makeRequest($url, $json); |
| 41 | - if($response !== false) {
|
|
| 41 | + if ($response !== false) {
|
|
| 42 | 42 | return $response; |
| 43 | 43 | } |
| 44 | 44 | $error = null; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $error = curl_error($this->ch); |
| 48 | 48 | $errno = curl_errno($this->ch); |
| 49 | 49 | } |
| 50 | - throw new AuthnetCurlException('Connection error: ' . $error . ' (' . $errno . ')');
|
|
| 50 | + throw new AuthnetCurlException('Connection error: '.$error.' ('.$errno.')');
|
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -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 | /** |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | /** |
| 28 | 28 | * @const Indicates use of Authorize.Net's production server |
| 29 | 29 | */ |
| 30 | - const USE_PRODUCTION_SERVER = 0; |
|
| 30 | + const USE_PRODUCTION_SERVER = 0; |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * @const Indicates use of the development server |
@@ -75,14 +75,11 @@ discard block |
||
| 75 | 75 | {
|
| 76 | 76 | if ($server === static::USE_PRODUCTION_SERVER) {
|
| 77 | 77 | $url = 'https://api.authorize.net/xml/v1/request.api'; |
| 78 | - } |
|
| 79 | - else if ($server === static::USE_DEVELOPMENT_SERVER) {
|
|
| 78 | + } else if ($server === static::USE_DEVELOPMENT_SERVER) {
|
|
| 80 | 79 | $url = 'https://apitest.authorize.net/xml/v1/request.api'; |
| 81 | - } |
|
| 82 | - else if ($server === static::USE_AKAMAI_SERVER) {
|
|
| 80 | + } else if ($server === static::USE_AKAMAI_SERVER) {
|
|
| 83 | 81 | $url = 'https://api2.authorize.net/xml/v1/request.api'; |
| 84 | - } |
|
| 85 | - else {
|
|
| 82 | + } else {
|
|
| 86 | 83 | throw new AuthnetInvalidServerException('You did not provide a valid server.');
|
| 87 | 84 | } |
| 88 | 85 | return $url; |
@@ -121,11 +118,9 @@ discard block |
||
| 121 | 118 | {
|
| 122 | 119 | if ($server === static::USE_PRODUCTION_SERVER) {
|
| 123 | 120 | $url = 'https://secure2.authorize.net/gateway/transact.dll'; |
| 124 | - } |
|
| 125 | - else if ($server === static::USE_DEVELOPMENT_SERVER) {
|
|
| 121 | + } else if ($server === static::USE_DEVELOPMENT_SERVER) {
|
|
| 126 | 122 | $url = 'https://test.authorize.net/gateway/transact.dll'; |
| 127 | - } |
|
| 128 | - else {
|
|
| 123 | + } else {
|
|
| 129 | 124 | throw new AuthnetInvalidServerException('You did not provide a valid server.');
|
| 130 | 125 | } |
| 131 | 126 | return $url; |