@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param string $merchant_id Merchant ID. |
| 69 | 69 | * @param string $merchant_key Merchant key. |
| 70 | 70 | */ |
| 71 | - public function __construct( $merchant_id, $merchant_key ) { |
|
| 71 | + public function __construct($merchant_id, $merchant_key) { |
|
| 72 | 72 | $this->merchant_id = $merchant_id; |
| 73 | 73 | $this->merchant_key = $merchant_key; |
| 74 | 74 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * |
| 88 | 88 | * @param boolean $test_mode True if test mode, false otherwise. |
| 89 | 89 | */ |
| 90 | - public function set_test_mode( $test_mode ) { |
|
| 90 | + public function set_test_mode($test_mode) { |
|
| 91 | 91 | $this->test_mode = $test_mode; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @param array $parameters Parameters. |
| 99 | 99 | * @return string|WP_Error |
| 100 | 100 | */ |
| 101 | - private function send_request( $method, array $parameters = array() ) { |
|
| 101 | + private function send_request($method, array $parameters = array()) { |
|
| 102 | 102 | $url = self::API_URL . '/' . $method; |
| 103 | 103 | |
| 104 | 104 | return Core_Util::remote_get_body( |
@@ -117,31 +117,31 @@ discard block |
||
| 117 | 117 | * @param SimpleXMLElement $document Document. |
| 118 | 118 | * @return WP_Error|Transaction |
| 119 | 119 | */ |
| 120 | - private function parse_document( SimpleXMLElement $document ) { |
|
| 120 | + private function parse_document(SimpleXMLElement $document) { |
|
| 121 | 121 | $this->error = null; |
| 122 | 122 | |
| 123 | 123 | $name = $document->getName(); |
| 124 | 124 | |
| 125 | - switch ( $name ) { |
|
| 125 | + switch ($name) { |
|
| 126 | 126 | case 'errorresponse': |
| 127 | - $sisow_error = ErrorParser::parse( $document->error ); |
|
| 127 | + $sisow_error = ErrorParser::parse($document->error); |
|
| 128 | 128 | |
| 129 | - $this->error = new WP_Error( 'ideal_sisow_error', $sisow_error->message, $sisow_error ); |
|
| 129 | + $this->error = new WP_Error('ideal_sisow_error', $sisow_error->message, $sisow_error); |
|
| 130 | 130 | |
| 131 | 131 | return $sisow_error; |
| 132 | 132 | case 'transactionrequest': |
| 133 | - $transaction = TransactionParser::parse( $document->transaction ); |
|
| 133 | + $transaction = TransactionParser::parse($document->transaction); |
|
| 134 | 134 | |
| 135 | 135 | return $transaction; |
| 136 | 136 | case 'statusresponse': |
| 137 | - $transaction = TransactionParser::parse( $document->transaction ); |
|
| 137 | + $transaction = TransactionParser::parse($document->transaction); |
|
| 138 | 138 | |
| 139 | 139 | return $transaction; |
| 140 | 140 | default: |
| 141 | 141 | return new WP_Error( |
| 142 | 142 | 'ideal_sisow_error', |
| 143 | 143 | /* translators: %s: XML document element name */ |
| 144 | - sprintf( __( 'Unknwon Sisow message (%s)', 'pronamic_ideal' ), $name ) |
|
| 144 | + sprintf(__('Unknwon Sisow message (%s)', 'pronamic_ideal'), $name) |
|
| 145 | 145 | ); |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -154,36 +154,36 @@ discard block |
||
| 154 | 154 | public function get_directory() { |
| 155 | 155 | $directory = false; |
| 156 | 156 | |
| 157 | - if ( $this->test_mode ) { |
|
| 158 | - $directory = array( '99' => __( 'Sisow Bank (test)', 'pronamic_ideal' ) ); |
|
| 157 | + if ($this->test_mode) { |
|
| 158 | + $directory = array('99' => __('Sisow Bank (test)', 'pronamic_ideal')); |
|
| 159 | 159 | } else { |
| 160 | 160 | // Request. |
| 161 | - $result = $this->send_request( RequestMethods::DIRECTORY_REQUEST ); |
|
| 161 | + $result = $this->send_request(RequestMethods::DIRECTORY_REQUEST); |
|
| 162 | 162 | |
| 163 | - if ( $result instanceof WP_Error ) { |
|
| 163 | + if ($result instanceof WP_Error) { |
|
| 164 | 164 | $this->error = $result; |
| 165 | 165 | |
| 166 | 166 | return $directory; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // XML. |
| 170 | - $xml = Core_Util::simplexml_load_string( $result ); |
|
| 170 | + $xml = Core_Util::simplexml_load_string($result); |
|
| 171 | 171 | |
| 172 | - if ( is_wp_error( $xml ) ) { |
|
| 172 | + if (is_wp_error($xml)) { |
|
| 173 | 173 | $this->error = $xml; |
| 174 | 174 | |
| 175 | 175 | return $directory; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | // Parse. |
| 179 | - if ( $xml instanceof SimpleXMLElement ) { |
|
| 179 | + if ($xml instanceof SimpleXMLElement) { |
|
| 180 | 180 | $directory = array(); |
| 181 | 181 | |
| 182 | - foreach ( $xml->directory->issuer as $issuer ) { |
|
| 182 | + foreach ($xml->directory->issuer as $issuer) { |
|
| 183 | 183 | $id = (string) $issuer->issuerid; |
| 184 | 184 | $name = (string) $issuer->issuername; |
| 185 | 185 | |
| 186 | - $directory[ $id ] = $name; |
|
| 186 | + $directory[$id] = $name; |
|
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | } |
@@ -197,34 +197,34 @@ discard block |
||
| 197 | 197 | * @param TransactionRequest $request Transaction request. |
| 198 | 198 | * @return Transaction|false |
| 199 | 199 | */ |
| 200 | - public function create_transaction( TransactionRequest $request ) { |
|
| 200 | + public function create_transaction(TransactionRequest $request) { |
|
| 201 | 201 | $result = false; |
| 202 | 202 | |
| 203 | 203 | // Request. |
| 204 | - $request->sign( $this->merchant_key ); |
|
| 204 | + $request->sign($this->merchant_key); |
|
| 205 | 205 | |
| 206 | - $response = $this->send_request( RequestMethods::TRANSACTION_REQUEST, $request->get_parameters() ); |
|
| 206 | + $response = $this->send_request(RequestMethods::TRANSACTION_REQUEST, $request->get_parameters()); |
|
| 207 | 207 | |
| 208 | - if ( $response instanceof WP_Error ) { |
|
| 208 | + if ($response instanceof WP_Error) { |
|
| 209 | 209 | $this->error = $response; |
| 210 | 210 | |
| 211 | 211 | return $result; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // XML. |
| 215 | - $xml = Core_Util::simplexml_load_string( $response ); |
|
| 215 | + $xml = Core_Util::simplexml_load_string($response); |
|
| 216 | 216 | |
| 217 | - if ( $xml instanceof WP_Error) ) { |
|
| 217 | + if ($xml instanceof WP_Error) ) { |
|
| 218 | 218 | $this->error = $xml; |
| 219 | 219 | |
| 220 | 220 | return $result; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // Parse. |
| 224 | - if ( $xml instanceof SimpleXMLElement ) { |
|
| 225 | - $message = $this->parse_document( $xml ); |
|
| 224 | + if ($xml instanceof SimpleXMLElement) { |
|
| 225 | + $message = $this->parse_document($xml); |
|
| 226 | 226 | |
| 227 | - if ( $message instanceof Transaction ) { |
|
| 227 | + if ($message instanceof Transaction) { |
|
| 228 | 228 | $result = $message; |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * @param string $merchant_id Merchant ID. |
| 241 | 241 | * @param string $merchant_key Merchant key. |
| 242 | 242 | */ |
| 243 | - public static function create_status_sha1( $transaction_id, $shop_id, $merchant_id, $merchant_key ) { |
|
| 243 | + public static function create_status_sha1($transaction_id, $shop_id, $merchant_id, $merchant_key) { |
|
| 244 | 244 | return sha1( |
| 245 | 245 | $transaction_id . |
| 246 | 246 | $shop_id . |
@@ -255,10 +255,10 @@ discard block |
||
| 255 | 255 | * @param string $transaction_id Transaction ID. |
| 256 | 256 | * @return Transaction|false |
| 257 | 257 | */ |
| 258 | - public function get_status( $transaction_id ) { |
|
| 258 | + public function get_status($transaction_id) { |
|
| 259 | 259 | $status = false; |
| 260 | 260 | |
| 261 | - if ( '' === $transaction_id ) { |
|
| 261 | + if ('' === $transaction_id) { |
|
| 262 | 262 | return $status; |
| 263 | 263 | } |
| 264 | 264 | |
@@ -266,30 +266,30 @@ discard block |
||
| 266 | 266 | $parameters = array( |
| 267 | 267 | 'merchantid' => $this->merchant_id, |
| 268 | 268 | 'trxid' => $transaction_id, |
| 269 | - 'sha1' => self::create_status_sha1( $transaction_id, '', $this->merchant_id, $this->merchant_key ), |
|
| 269 | + 'sha1' => self::create_status_sha1($transaction_id, '', $this->merchant_id, $this->merchant_key), |
|
| 270 | 270 | ); |
| 271 | 271 | |
| 272 | 272 | // Request. |
| 273 | - $result = $this->send_request( RequestMethods::STATUS_REQUEST, $parameters ); |
|
| 273 | + $result = $this->send_request(RequestMethods::STATUS_REQUEST, $parameters); |
|
| 274 | 274 | |
| 275 | - if ( $result instanceof WP_Error ) { |
|
| 275 | + if ($result instanceof WP_Error) { |
|
| 276 | 276 | $this->error = $result; |
| 277 | 277 | |
| 278 | 278 | return $status; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // XML. |
| 282 | - $xml = Core_Util::simplexml_load_string( $result ); |
|
| 282 | + $xml = Core_Util::simplexml_load_string($result); |
|
| 283 | 283 | |
| 284 | - if ( $xml instanceof WP_Error ) { |
|
| 284 | + if ($xml instanceof WP_Error) { |
|
| 285 | 285 | $this->error = $xml; |
| 286 | 286 | |
| 287 | 287 | return $status; |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | // Parse. |
| 291 | - if ( $xml instanceof SimpleXMLElement ) { |
|
| 292 | - $status = $this->parse_document( $xml ); |
|
| 291 | + if ($xml instanceof SimpleXMLElement) { |
|
| 292 | + $status = $this->parse_document($xml); |
|
| 293 | 293 | |
| 294 | 294 | return $status; |
| 295 | 295 | } |
@@ -214,8 +214,10 @@ |
||
| 214 | 214 | // XML. |
| 215 | 215 | $xml = Core_Util::simplexml_load_string( $response ); |
| 216 | 216 | |
| 217 | - if ( $xml instanceof WP_Error) ) { |
|
| 217 | + if ( $xml instanceof WP_Error) { |
|
| 218 | + ) { |
|
| 218 | 219 | $this->error = $xml; |
| 220 | + } |
|
| 219 | 221 | |
| 220 | 222 | return $result; |
| 221 | 223 | } |