@@ -24,33 +24,33 @@ |
||
| 24 | 24 | * |
| 25 | 25 | * @return Transaction |
| 26 | 26 | */ |
| 27 | - public static function parse( SimpleXMLElement $xml, Transaction $transaction = null ) { |
|
| 28 | - if ( ! $transaction instanceof Transaction ) { |
|
| 27 | + public static function parse(SimpleXMLElement $xml, Transaction $transaction = null) { |
|
| 28 | + if ( ! $transaction instanceof Transaction) { |
|
| 29 | 29 | $transaction = new Transaction(); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if ( $xml->transactionID ) { |
|
| 33 | - $transaction->set_id( Security::filter( $xml->transactionID ) ); |
|
| 32 | + if ($xml->transactionID) { |
|
| 33 | + $transaction->set_id(Security::filter($xml->transactionID)); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if ( $xml->purchaseID ) { |
|
| 37 | - $transaction->set_purchase_id( Security::filter( $xml->purchaseID ) ); |
|
| 36 | + if ($xml->purchaseID) { |
|
| 37 | + $transaction->set_purchase_id(Security::filter($xml->purchaseID)); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if ( $xml->status ) { |
|
| 41 | - $transaction->set_status( Security::filter( $xml->status ) ); |
|
| 40 | + if ($xml->status) { |
|
| 41 | + $transaction->set_status(Security::filter($xml->status)); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if ( $xml->consumerName ) { |
|
| 45 | - $transaction->set_consumer_name( Security::filter( $xml->consumerName ) ); |
|
| 44 | + if ($xml->consumerName) { |
|
| 45 | + $transaction->set_consumer_name(Security::filter($xml->consumerName)); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if ( $xml->consumerIBAN ) { |
|
| 49 | - $transaction->set_consumer_iban( Security::filter( $xml->consumerIBAN ) ); |
|
| 48 | + if ($xml->consumerIBAN) { |
|
| 49 | + $transaction->set_consumer_iban(Security::filter($xml->consumerIBAN)); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - if ( $xml->consumerBIC ) { |
|
| 53 | - $transaction->set_consumer_bic( Security::filter( $xml->consumerBIC ) ); |
|
| 52 | + if ($xml->consumerBIC) { |
|
| 53 | + $transaction->set_consumer_bic(Security::filter($xml->consumerBIC)); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | return $transaction; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @param string $id |
| 126 | 126 | */ |
| 127 | - public function set_id( $id ) { |
|
| 127 | + public function set_id($id) { |
|
| 128 | 128 | $this->id = $id; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @param string $id |
| 148 | 148 | */ |
| 149 | - public function set_purchase_id( $id ) { |
|
| 149 | + public function set_purchase_id($id) { |
|
| 150 | 150 | $this->purchase_id = $id; |
| 151 | 151 | } |
| 152 | 152 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @param string $amount |
| 166 | 166 | */ |
| 167 | - public function set_amount( $amount ) { |
|
| 167 | + public function set_amount($amount) { |
|
| 168 | 168 | $this->amount = $amount; |
| 169 | 169 | } |
| 170 | 170 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * |
| 183 | 183 | * @param string $currency |
| 184 | 184 | */ |
| 185 | - public function set_currency( $currency ) { |
|
| 185 | + public function set_currency($currency) { |
|
| 186 | 186 | $this->currency = $currency; |
| 187 | 187 | } |
| 188 | 188 | |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @param string $expiration_period |
| 202 | 202 | */ |
| 203 | - public function set_expiration_period( $expiration_period ) { |
|
| 203 | + public function set_expiration_period($expiration_period) { |
|
| 204 | 204 | $this->expiration_period = $expiration_period; |
| 205 | 205 | } |
| 206 | 206 | |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @param string $language |
| 220 | 220 | */ |
| 221 | - public function set_language( $language ) { |
|
| 221 | + public function set_language($language) { |
|
| 222 | 222 | $this->language = $language; |
| 223 | 223 | } |
| 224 | 224 | |
@@ -237,8 +237,8 @@ discard block |
||
| 237 | 237 | * |
| 238 | 238 | * @param string $description |
| 239 | 239 | */ |
| 240 | - public function set_description( $description ) { |
|
| 241 | - $this->description = substr( $description, 0, 32 ); |
|
| 240 | + public function set_description($description) { |
|
| 241 | + $this->description = substr($description, 0, 32); |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -264,8 +264,8 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @param string $entrance_code |
| 266 | 266 | */ |
| 267 | - public function set_entrance_code( $entrance_code ) { |
|
| 268 | - $this->entrance_code = substr( $entrance_code, 0, 40 ); |
|
| 267 | + public function set_entrance_code($entrance_code) { |
|
| 268 | + $this->entrance_code = substr($entrance_code, 0, 40); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | * |
| 283 | 283 | * @param string $status |
| 284 | 284 | */ |
| 285 | - public function set_status( $status ) { |
|
| 285 | + public function set_status($status) { |
|
| 286 | 286 | $this->status = $status; |
| 287 | 287 | } |
| 288 | 288 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * |
| 301 | 301 | * @param $name |
| 302 | 302 | */ |
| 303 | - public function set_consumer_name( $name ) { |
|
| 303 | + public function set_consumer_name($name) { |
|
| 304 | 304 | $this->consumer_name = $name; |
| 305 | 305 | } |
| 306 | 306 | |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * |
| 319 | 319 | * @param string $iban |
| 320 | 320 | */ |
| 321 | - public function set_consumer_iban( $iban ) { |
|
| 321 | + public function set_consumer_iban($iban) { |
|
| 322 | 322 | $this->consumer_iban = $iban; |
| 323 | 323 | } |
| 324 | 324 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * |
| 337 | 337 | * @param string $bic |
| 338 | 338 | */ |
| 339 | - public function set_consumer_bic( $bic ) { |
|
| 339 | + public function set_consumer_bic($bic) { |
|
| 340 | 340 | $this->consumer_bic = $bic; |
| 341 | 341 | } |
| 342 | 342 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @param string $id |
| 56 | 56 | */ |
| 57 | - public function set_id( $id ) { |
|
| 57 | + public function set_id($id) { |
|
| 58 | 58 | $this->id = $id; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param string $sub_id |
| 74 | 74 | */ |
| 75 | - public function set_sub_id( $sub_id ) { |
|
| 75 | + public function set_sub_id($sub_id) { |
|
| 76 | 76 | $this->sub_id = $sub_id; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @param string $return_url |
| 92 | 92 | */ |
| 93 | - public function set_return_url( $return_url ) { |
|
| 93 | + public function set_return_url($return_url) { |
|
| 94 | 94 | $this->return_url = $return_url; |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @return string Fingerprint or null on failure |
| 36 | 36 | */ |
| 37 | - public static function get_sha_fingerprint( $certificate ) { |
|
| 38 | - return self::get_fingerprint( $certificate, 'sha1' ); |
|
| 37 | + public static function get_sha_fingerprint($certificate) { |
|
| 38 | + return self::get_fingerprint($certificate, 'sha1'); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return string Fingerprint or null on failure |
| 47 | 47 | */ |
| 48 | - public static function get_md5_fingerprint( $certificate ) { |
|
| 49 | - return self::get_fingerprint( $certificate, 'md5' ); |
|
| 48 | + public static function get_md5_fingerprint($certificate) { |
|
| 49 | + return self::get_fingerprint($certificate, 'md5'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -56,36 +56,36 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @return string Fingerprint or null on failure |
| 58 | 58 | */ |
| 59 | - public static function get_fingerprint( $certificate, $hash = null ) { |
|
| 59 | + public static function get_fingerprint($certificate, $hash = null) { |
|
| 60 | 60 | $fingerprint = null; |
| 61 | 61 | |
| 62 | 62 | // The openssl_x509_read() function will throw an warning if the supplied |
| 63 | 63 | // parameter cannot be coerced into an X509 certificate |
| 64 | 64 | // @codingStandardsIgnoreStart |
| 65 | - $resource = @openssl_x509_read( $certificate ); |
|
| 65 | + $resource = @openssl_x509_read($certificate); |
|
| 66 | 66 | // @codingStandardsIgnoreEnd |
| 67 | 67 | |
| 68 | - if ( false === $resource ) { |
|
| 68 | + if (false === $resource) { |
|
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $output = null; |
| 73 | 73 | |
| 74 | - $result = openssl_x509_export( $resource, $output ); |
|
| 74 | + $result = openssl_x509_export($resource, $output); |
|
| 75 | 75 | |
| 76 | - if ( false === $result ) { |
|
| 76 | + if (false === $result) { |
|
| 77 | 77 | return false; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - $output = str_replace( self::CERTIFICATE_BEGIN, '', $output ); |
|
| 81 | - $output = str_replace( self::CERTIFICATE_END, '', $output ); |
|
| 80 | + $output = str_replace(self::CERTIFICATE_BEGIN, '', $output); |
|
| 81 | + $output = str_replace(self::CERTIFICATE_END, '', $output); |
|
| 82 | 82 | |
| 83 | 83 | // Base64 decode |
| 84 | - $fingerprint = base64_decode( $output ); |
|
| 84 | + $fingerprint = base64_decode($output); |
|
| 85 | 85 | |
| 86 | 86 | // Hash |
| 87 | - if ( null !== $hash ) { |
|
| 88 | - $fingerprint = hash( $hash, $fingerprint ); |
|
| 87 | + if (null !== $hash) { |
|
| 88 | + $fingerprint = hash($hash, $fingerprint); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /* |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @since 1.1.11 |
| 99 | 99 | */ |
| 100 | - $fingerprint = strtoupper( $fingerprint ); |
|
| 100 | + $fingerprint = strtoupper($fingerprint); |
|
| 101 | 101 | |
| 102 | 102 | return $fingerprint; |
| 103 | 103 | } |
@@ -19,9 +19,9 @@ |
||
| 19 | 19 | * |
| 20 | 20 | * @return string |
| 21 | 21 | */ |
| 22 | - public static function format_amount( $amount ) { |
|
| 22 | + public static function format_amount($amount) { |
|
| 23 | 23 | // The amount payable in euro (with a period (.) used as decimal separator) |
| 24 | 24 | // page 18 - http://pronamic.nl/wp-content/uploads/2012/12/iDEAL-Merchant-Integration-Guide-ENG-v3.3.1.pdf |
| 25 | - return number_format( $amount, 2, '.', '' ); |
|
| 25 | + return number_format($amount, 2, '.', ''); |
|
| 26 | 26 | } |
| 27 | 27 | } |
@@ -16,25 +16,25 @@ |
||
| 16 | 16 | class ConfigFactory extends GatewayConfigFactory { |
| 17 | 17 | private $config_class; |
| 18 | 18 | |
| 19 | - public function __construct( $config_class = 'Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\Config', $config_test_class = 'Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\Config' ) { |
|
| 19 | + public function __construct($config_class = 'Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\Config', $config_test_class = 'Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\Config') { |
|
| 20 | 20 | $this->config_class = $config_class; |
| 21 | 21 | $this->config_test_class = $config_test_class; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function get_config( $post_id ) { |
|
| 25 | - $mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
|
| 24 | + public function get_config($post_id) { |
|
| 25 | + $mode = get_post_meta($post_id, '_pronamic_gateway_mode', true); |
|
| 26 | 26 | |
| 27 | - $config_class = ( Gateway::MODE_TEST === $mode ) ? $this->config_test_class : $this->config_class; |
|
| 27 | + $config_class = (Gateway::MODE_TEST === $mode) ? $this->config_test_class : $this->config_class; |
|
| 28 | 28 | |
| 29 | 29 | $config = new $config_class(); |
| 30 | 30 | |
| 31 | - $config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_merchant_id', true ); |
|
| 32 | - $config->sub_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_sub_id', true ); |
|
| 33 | - $config->purchase_id = get_post_meta( $post_id, '_pronamic_gateway_ideal_purchase_id', true ); |
|
| 31 | + $config->merchant_id = get_post_meta($post_id, '_pronamic_gateway_ideal_merchant_id', true); |
|
| 32 | + $config->sub_id = get_post_meta($post_id, '_pronamic_gateway_ideal_sub_id', true); |
|
| 33 | + $config->purchase_id = get_post_meta($post_id, '_pronamic_gateway_ideal_purchase_id', true); |
|
| 34 | 34 | |
| 35 | - $config->private_key = get_post_meta( $post_id, '_pronamic_gateway_ideal_private_key', true ); |
|
| 36 | - $config->private_key_password = get_post_meta( $post_id, '_pronamic_gateway_ideal_private_key_password', true ); |
|
| 37 | - $config->private_certificate = get_post_meta( $post_id, '_pronamic_gateway_ideal_private_certificate', true ); |
|
| 35 | + $config->private_key = get_post_meta($post_id, '_pronamic_gateway_ideal_private_key', true); |
|
| 36 | + $config->private_key_password = get_post_meta($post_id, '_pronamic_gateway_ideal_private_key_password', true); |
|
| 37 | + $config->private_certificate = get_post_meta($post_id, '_pronamic_gateway_ideal_private_certificate', true); |
|
| 38 | 38 | |
| 39 | 39 | return $config; |
| 40 | 40 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @param string $url |
| 124 | 124 | */ |
| 125 | - public function set_acquirer_url( $url ) { |
|
| 125 | + public function set_acquirer_url($url) { |
|
| 126 | 126 | $this->acquirer_url = $url; |
| 127 | 127 | |
| 128 | 128 | $this->directory_request_url = $url; |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @return ResponseMessage |
| 140 | 140 | */ |
| 141 | - private function send_message( $url, RequestMessage $message ) { |
|
| 141 | + private function send_message($url, RequestMessage $message) { |
|
| 142 | 142 | $result = false; |
| 143 | 143 | |
| 144 | 144 | // Sign |
| 145 | 145 | $document = $message->get_document(); |
| 146 | - $document = $this->sign_document( $document ); |
|
| 146 | + $document = $this->sign_document($document); |
|
| 147 | 147 | |
| 148 | - if ( false !== $document ) { |
|
| 148 | + if (false !== $document) { |
|
| 149 | 149 | // Stringify |
| 150 | 150 | $data = $document->saveXML(); |
| 151 | 151 | |
@@ -154,32 +154,32 @@ discard block |
||
| 154 | 154 | * |
| 155 | 155 | * @since 1.1.11 |
| 156 | 156 | */ |
| 157 | - if ( 'https://www.ideal-checkout.nl/simulator/' === $url ) { |
|
| 158 | - $data = $document->C14N( true, false ); |
|
| 157 | + if ('https://www.ideal-checkout.nl/simulator/' === $url) { |
|
| 158 | + $data = $document->C14N(true, false); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // Remote post |
| 162 | - $response = wp_remote_post( $url, array( |
|
| 162 | + $response = wp_remote_post($url, array( |
|
| 163 | 163 | 'method' => 'POST', |
| 164 | 164 | 'headers' => array( |
| 165 | 165 | 'Content-Type' => 'text/xml; charset=' . Message::XML_ENCODING, |
| 166 | 166 | ), |
| 167 | 167 | 'body' => $data, |
| 168 | - ) ); |
|
| 168 | + )); |
|
| 169 | 169 | |
| 170 | 170 | // Handle response |
| 171 | - if ( ! is_wp_error( $response ) ) { |
|
| 172 | - if ( 200 === wp_remote_retrieve_response_code( $response ) ) { |
|
| 173 | - $body = wp_remote_retrieve_body( $response ); |
|
| 171 | + if ( ! is_wp_error($response)) { |
|
| 172 | + if (200 === wp_remote_retrieve_response_code($response)) { |
|
| 173 | + $body = wp_remote_retrieve_body($response); |
|
| 174 | 174 | |
| 175 | - $xml = Core_Util::simplexml_load_string( $body ); |
|
| 175 | + $xml = Core_Util::simplexml_load_string($body); |
|
| 176 | 176 | |
| 177 | - if ( is_wp_error( $xml ) ) { |
|
| 177 | + if (is_wp_error($xml)) { |
|
| 178 | 178 | $this->error = $xml; |
| 179 | 179 | } else { |
| 180 | - $document = self::parse_document( $xml ); |
|
| 180 | + $document = self::parse_document($xml); |
|
| 181 | 181 | |
| 182 | - if ( is_wp_error( $document ) ) { |
|
| 182 | + if (is_wp_error($document)) { |
|
| 183 | 183 | $this->error = $document; |
| 184 | 184 | } else { |
| 185 | 185 | $result = $document; |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | 'wrong_response_code', |
| 191 | 191 | sprintf( |
| 192 | 192 | /* translators: %s: response code */ |
| 193 | - __( 'The response code (<code>%s<code>) from the iDEAL provider was incorrect.', 'pronamic_ideal' ), |
|
| 194 | - wp_remote_retrieve_response_code( $response ) |
|
| 193 | + __('The response code (<code>%s<code>) from the iDEAL provider was incorrect.', 'pronamic_ideal'), |
|
| 194 | + wp_remote_retrieve_response_code($response) |
|
| 195 | 195 | ) |
| 196 | 196 | ); |
| 197 | 197 | } |
@@ -210,33 +210,33 @@ discard block |
||
| 210 | 210 | * |
| 211 | 211 | * @return ResponseMessage|WP_Error |
| 212 | 212 | */ |
| 213 | - private function parse_document( SimpleXMLElement $document ) { |
|
| 213 | + private function parse_document(SimpleXMLElement $document) { |
|
| 214 | 214 | $this->error = null; |
| 215 | 215 | |
| 216 | 216 | $name = $document->getName(); |
| 217 | 217 | |
| 218 | - switch ( $name ) { |
|
| 218 | + switch ($name) { |
|
| 219 | 219 | case AcquirerErrorResMessage::NAME: |
| 220 | - $message = AcquirerErrorResMessage::parse( $document ); |
|
| 220 | + $message = AcquirerErrorResMessage::parse($document); |
|
| 221 | 221 | |
| 222 | 222 | $this->error = new WP_Error( |
| 223 | 223 | 'IDealAdvancedV3_error', |
| 224 | - sprintf( '%s. %s', $message->error->get_message(), $message->error->get_detail() ), |
|
| 224 | + sprintf('%s. %s', $message->error->get_message(), $message->error->get_detail()), |
|
| 225 | 225 | $message->error |
| 226 | 226 | ); |
| 227 | 227 | |
| 228 | 228 | return $message; |
| 229 | 229 | case DirectoryResponseMessage::NAME: |
| 230 | - return DirectoryResponseMessage::parse( $document ); |
|
| 230 | + return DirectoryResponseMessage::parse($document); |
|
| 231 | 231 | case TransactionResponseMessage::NAME: |
| 232 | - return TransactionResponseMessage::parse( $document ); |
|
| 232 | + return TransactionResponseMessage::parse($document); |
|
| 233 | 233 | case AcquirerStatusResMessage::NAME: |
| 234 | - return AcquirerStatusResMessage::parse( $document ); |
|
| 234 | + return AcquirerStatusResMessage::parse($document); |
|
| 235 | 235 | default: |
| 236 | 236 | return new WP_Error( |
| 237 | 237 | 'IDealAdvancedV3_error', |
| 238 | 238 | /* translators: %s: XML document element name */ |
| 239 | - sprintf( __( 'Unknwon iDEAL message (%s)', 'pronamic_ideal' ), $name ) |
|
| 239 | + sprintf(__('Unknwon iDEAL message (%s)', 'pronamic_ideal'), $name) |
|
| 240 | 240 | ); |
| 241 | 241 | } |
| 242 | 242 | } |
@@ -252,12 +252,12 @@ discard block |
||
| 252 | 252 | $request_dir_message = new DirectoryRequestMessage(); |
| 253 | 253 | |
| 254 | 254 | $merchant = $request_dir_message->get_merchant(); |
| 255 | - $merchant->set_id( $this->merchant_id ); |
|
| 256 | - $merchant->set_sub_id( $this->sub_id ); |
|
| 255 | + $merchant->set_id($this->merchant_id); |
|
| 256 | + $merchant->set_sub_id($this->sub_id); |
|
| 257 | 257 | |
| 258 | - $response_dir_message = $this->send_message( $this->directory_request_url, $request_dir_message ); |
|
| 258 | + $response_dir_message = $this->send_message($this->directory_request_url, $request_dir_message); |
|
| 259 | 259 | |
| 260 | - if ( $response_dir_message instanceof DirectoryResponseMessage ) { |
|
| 260 | + if ($response_dir_message instanceof DirectoryResponseMessage) { |
|
| 261 | 261 | $directory = $response_dir_message->get_directory(); |
| 262 | 262 | } |
| 263 | 263 | |
@@ -272,20 +272,20 @@ discard block |
||
| 272 | 272 | * |
| 273 | 273 | * @return TransactionResponseMessage |
| 274 | 274 | */ |
| 275 | - public function create_transaction( Transaction $transaction, $return_url, $issuer_id ) { |
|
| 275 | + public function create_transaction(Transaction $transaction, $return_url, $issuer_id) { |
|
| 276 | 276 | $message = new TransactionRequestMessage(); |
| 277 | 277 | |
| 278 | 278 | $merchant = $message->get_merchant(); |
| 279 | - $merchant->set_id( $this->merchant_id ); |
|
| 280 | - $merchant->set_sub_id( $this->sub_id ); |
|
| 281 | - $merchant->set_return_url( $return_url ); |
|
| 279 | + $merchant->set_id($this->merchant_id); |
|
| 280 | + $merchant->set_sub_id($this->sub_id); |
|
| 281 | + $merchant->set_return_url($return_url); |
|
| 282 | 282 | |
| 283 | 283 | $message->issuer = new Issuer(); |
| 284 | - $message->issuer->set_id( $issuer_id ); |
|
| 284 | + $message->issuer->set_id($issuer_id); |
|
| 285 | 285 | |
| 286 | 286 | $message->transaction = $transaction; |
| 287 | 287 | |
| 288 | - return $this->send_message( $this->transaction_request_url, $message ); |
|
| 288 | + return $this->send_message($this->transaction_request_url, $message); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -295,17 +295,17 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @return TransactionResponseMessage |
| 297 | 297 | */ |
| 298 | - public function get_status( $transaction_id ) { |
|
| 298 | + public function get_status($transaction_id) { |
|
| 299 | 299 | $message = new AcquirerStatusReqMessage(); |
| 300 | 300 | |
| 301 | 301 | $merchant = $message->get_merchant(); |
| 302 | - $merchant->set_id( $this->merchant_id ); |
|
| 303 | - $merchant->set_sub_id( $this->sub_id ); |
|
| 302 | + $merchant->set_id($this->merchant_id); |
|
| 303 | + $merchant->set_sub_id($this->sub_id); |
|
| 304 | 304 | |
| 305 | 305 | $message->transaction = new Transaction(); |
| 306 | - $message->transaction->set_id( $transaction_id ); |
|
| 306 | + $message->transaction->set_id($transaction_id); |
|
| 307 | 307 | |
| 308 | - return $this->send_message( $this->status_request_url, $message ); |
|
| 308 | + return $this->send_message($this->status_request_url, $message); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * |
| 318 | 318 | * @return DOMDocument |
| 319 | 319 | */ |
| 320 | - private function sign_document( DOMDocument $document ) { |
|
| 320 | + private function sign_document(DOMDocument $document) { |
|
| 321 | 321 | $result = false; |
| 322 | 322 | |
| 323 | 323 | try { |
@@ -325,14 +325,14 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | // For canonicalization purposes the exclusive (9) algorithm must be used. |
| 327 | 327 | // @link http://pronamic.nl/wp-content/uploads/2012/12/iDEAL-Merchant-Integration-Guide-ENG-v3.3.1.pdf #page 30 |
| 328 | - $dsig->setCanonicalMethod( XMLSecurityDSig::EXC_C14N ); |
|
| 328 | + $dsig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N); |
|
| 329 | 329 | |
| 330 | 330 | // For hashing purposes the SHA-256 (11) algorithm must be used. |
| 331 | 331 | // @link http://pronamic.nl/wp-content/uploads/2012/12/iDEAL-Merchant-Integration-Guide-ENG-v3.3.1.pdf #page 30 |
| 332 | 332 | $dsig->addReference( |
| 333 | 333 | $document, |
| 334 | 334 | XMLSecurityDSig::SHA256, |
| 335 | - array( 'http://www.w3.org/2000/09/xmldsig#enveloped-signature' ), |
|
| 335 | + array('http://www.w3.org/2000/09/xmldsig#enveloped-signature'), |
|
| 336 | 336 | array( |
| 337 | 337 | 'force_uri' => true, |
| 338 | 338 | ) |
@@ -340,39 +340,39 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | // For signature purposes the RSAWithSHA 256 (12) algorithm must be used. |
| 342 | 342 | // @link http://pronamic.nl/wp-content/uploads/2012/12/iDEAL-Merchant-Integration-Guide-ENG-v3.3.1.pdf #page 31 |
| 343 | - $key = new XMLSecurityKey( XMLSecurityKey::RSA_SHA256, array( |
|
| 343 | + $key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, array( |
|
| 344 | 344 | 'type' => 'private', |
| 345 | - ) ); |
|
| 345 | + )); |
|
| 346 | 346 | |
| 347 | 347 | $key->passphrase = $this->private_key_password; |
| 348 | 348 | |
| 349 | - $key->loadKey( $this->private_key ); |
|
| 349 | + $key->loadKey($this->private_key); |
|
| 350 | 350 | |
| 351 | 351 | // Test if we can get an private key object, to prefent the following errors: |
| 352 | 352 | // Warning: openssl_sign() [function.openssl-sign]: supplied key param cannot be coerced into a private key |
| 353 | - $result = openssl_get_privatekey( $this->private_key, $this->private_key_password ); |
|
| 353 | + $result = openssl_get_privatekey($this->private_key, $this->private_key_password); |
|
| 354 | 354 | |
| 355 | - if ( false !== $result ) { |
|
| 355 | + if (false !== $result) { |
|
| 356 | 356 | // Sign |
| 357 | - $dsig->sign( $key ); |
|
| 357 | + $dsig->sign($key); |
|
| 358 | 358 | |
| 359 | 359 | // The public key must be referenced using a fingerprint of an X.509 |
| 360 | 360 | // certificate. The fingerprint must be calculated according |
| 361 | 361 | // to the following formula HEX(SHA-1(DER certificate)) (13) |
| 362 | 362 | // @link http://pronamic.nl/wp-content/uploads/2012/12/iDEAL-Merchant-Integration-Guide-ENG-v3.3.1.pdf #page 31 |
| 363 | - $fingerprint = Security::get_sha_fingerprint( $this->private_certificate ); |
|
| 363 | + $fingerprint = Security::get_sha_fingerprint($this->private_certificate); |
|
| 364 | 364 | |
| 365 | - $dsig->addKeyInfoAndName( $fingerprint ); |
|
| 365 | + $dsig->addKeyInfoAndName($fingerprint); |
|
| 366 | 366 | |
| 367 | 367 | // Add the signature |
| 368 | - $dsig->appendSignature( $document->documentElement ); |
|
| 368 | + $dsig->appendSignature($document->documentElement); |
|
| 369 | 369 | |
| 370 | 370 | $result = $document; |
| 371 | 371 | } else { |
| 372 | - throw new Exception( 'Can not load private key' ); |
|
| 372 | + throw new Exception('Can not load private key'); |
|
| 373 | 373 | } |
| 374 | - } catch ( Exception $e ) { |
|
| 375 | - $this->error = new WP_Error( 'xml_security', $e->getMessage(), $e ); |
|
| 374 | + } catch (Exception $e) { |
|
| 375 | + $this->error = new WP_Error('xml_security', $e->getMessage(), $e); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | return $result; |
@@ -29,19 +29,19 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @param Config $config Config. |
| 31 | 31 | */ |
| 32 | - public function __construct( Config $config ) { |
|
| 33 | - parent::__construct( $config ); |
|
| 32 | + public function __construct(Config $config) { |
|
| 33 | + parent::__construct($config); |
|
| 34 | 34 | |
| 35 | 35 | $this->supports = array( |
| 36 | 36 | 'payment_status_request', |
| 37 | 37 | ); |
| 38 | 38 | |
| 39 | - $this->set_method( self::METHOD_HTTP_REDIRECT ); |
|
| 39 | + $this->set_method(self::METHOD_HTTP_REDIRECT); |
|
| 40 | 40 | |
| 41 | 41 | // Client. |
| 42 | 42 | $client = new Client(); |
| 43 | 43 | |
| 44 | - $client->set_acquirer_url( $config->get_payment_server_url() ); |
|
| 44 | + $client->set_acquirer_url($config->get_payment_server_url()); |
|
| 45 | 45 | |
| 46 | 46 | $client->merchant_id = $config->merchant_id; |
| 47 | 47 | $client->sub_id = $config->sub_id; |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | public function get_issuers() { |
| 63 | 63 | $directory = $this->client->get_directory(); |
| 64 | 64 | |
| 65 | - if ( ! $directory ) { |
|
| 65 | + if ( ! $directory) { |
|
| 66 | 66 | $this->error = $this->client->get_error(); |
| 67 | 67 | |
| 68 | 68 | return array(); |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $groups = array(); |
| 72 | 72 | |
| 73 | - foreach ( $directory->get_countries() as $country ) { |
|
| 73 | + foreach ($directory->get_countries() as $country) { |
|
| 74 | 74 | $issuers = array(); |
| 75 | 75 | |
| 76 | - foreach ( $country->get_issuers() as $issuer ) { |
|
| 77 | - $issuers[ $issuer->get_id() ] = $issuer->get_name(); |
|
| 76 | + foreach ($country->get_issuers() as $issuer) { |
|
| 77 | + $issuers[$issuer->get_id()] = $issuer->get_name(); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $groups[] = array( |
@@ -114,38 +114,38 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @param Payment $payment Payment. |
| 116 | 116 | */ |
| 117 | - public function start( Payment $payment ) { |
|
| 117 | + public function start(Payment $payment) { |
|
| 118 | 118 | // Purchase ID. |
| 119 | - $purchase_id = $payment->format_string( $this->config->purchase_id ); |
|
| 119 | + $purchase_id = $payment->format_string($this->config->purchase_id); |
|
| 120 | 120 | |
| 121 | - $payment->set_meta( 'purchase_id', $purchase_id ); |
|
| 121 | + $payment->set_meta('purchase_id', $purchase_id); |
|
| 122 | 122 | |
| 123 | 123 | // Transaction. |
| 124 | 124 | $transaction = new Transaction(); |
| 125 | - $transaction->set_purchase_id( $purchase_id ); |
|
| 126 | - $transaction->set_amount( $payment->get_total_amount()->get_value() ); |
|
| 127 | - $transaction->set_currency( $payment->get_total_amount()->get_currency()->get_alphabetic_code() ); |
|
| 128 | - $transaction->set_expiration_period( 'PT30M' ); |
|
| 129 | - $transaction->set_description( $payment->get_description() ); |
|
| 130 | - $transaction->set_entrance_code( $payment->get_entrance_code() ); |
|
| 131 | - |
|
| 132 | - if ( null !== $payment->get_customer() ) { |
|
| 133 | - $transaction->set_language( $payment->get_customer()->get_language() ); |
|
| 125 | + $transaction->set_purchase_id($purchase_id); |
|
| 126 | + $transaction->set_amount($payment->get_total_amount()->get_value()); |
|
| 127 | + $transaction->set_currency($payment->get_total_amount()->get_currency()->get_alphabetic_code()); |
|
| 128 | + $transaction->set_expiration_period('PT30M'); |
|
| 129 | + $transaction->set_description($payment->get_description()); |
|
| 130 | + $transaction->set_entrance_code($payment->get_entrance_code()); |
|
| 131 | + |
|
| 132 | + if (null !== $payment->get_customer()) { |
|
| 133 | + $transaction->set_language($payment->get_customer()->get_language()); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Create transaction. |
| 137 | - $result = $this->client->create_transaction( $transaction, $payment->get_return_url(), $payment->get_issuer() ); |
|
| 137 | + $result = $this->client->create_transaction($transaction, $payment->get_return_url(), $payment->get_issuer()); |
|
| 138 | 138 | |
| 139 | 139 | $error = $this->client->get_error(); |
| 140 | 140 | |
| 141 | - if ( is_wp_error( $error ) ) { |
|
| 142 | - $this->set_error( $error ); |
|
| 141 | + if (is_wp_error($error)) { |
|
| 142 | + $this->set_error($error); |
|
| 143 | 143 | |
| 144 | 144 | return; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - $payment->set_action_url( $result->issuer->get_authentication_url() ); |
|
| 148 | - $payment->set_transaction_id( $result->transaction->get_id() ); |
|
| 147 | + $payment->set_action_url($result->issuer->get_authentication_url()); |
|
| 148 | + $payment->set_transaction_id($result->transaction->get_id()); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -153,20 +153,20 @@ discard block |
||
| 153 | 153 | * |
| 154 | 154 | * @param Payment $payment Payment. |
| 155 | 155 | */ |
| 156 | - public function update_status( Payment $payment ) { |
|
| 157 | - $result = $this->client->get_status( $payment->get_transaction_id() ); |
|
| 156 | + public function update_status(Payment $payment) { |
|
| 157 | + $result = $this->client->get_status($payment->get_transaction_id()); |
|
| 158 | 158 | |
| 159 | 159 | $error = $this->client->get_error(); |
| 160 | 160 | |
| 161 | - if ( is_wp_error( $error ) ) { |
|
| 162 | - $this->set_error( $error ); |
|
| 161 | + if (is_wp_error($error)) { |
|
| 162 | + $this->set_error($error); |
|
| 163 | 163 | } else { |
| 164 | 164 | $transaction = $result->transaction; |
| 165 | 165 | |
| 166 | - $payment->set_status( $transaction->get_status() ); |
|
| 167 | - $payment->set_consumer_name( $transaction->get_consumer_name() ); |
|
| 168 | - $payment->set_consumer_iban( $transaction->get_consumer_iban() ); |
|
| 169 | - $payment->set_consumer_bic( $transaction->get_consumer_bic() ); |
|
| 166 | + $payment->set_status($transaction->get_status()); |
|
| 167 | + $payment->set_consumer_name($transaction->get_consumer_name()); |
|
| 168 | + $payment->set_consumer_iban($transaction->get_consumer_iban()); |
|
| 169 | + $payment->set_consumer_bic($transaction->get_consumer_bic()); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | } |