Passed
Push — master ( 630282...53b4bc )
by Reüel
04:35
created
src/ConfigFactory.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@
 block discarded – undo
15 15
  * @since 1.0.0
16 16
  */
17 17
 class ConfigFactory extends GatewayConfigFactory {
18
-	public function get_config( $post_id ) {
18
+	public function get_config($post_id) {
19 19
 		$config = new Config();
20 20
 
21
-		$config->storename = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_storename', true );
22
-		$config->secret    = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_secret', true );
23
-		$config->mode      = get_post_meta( $post_id, '_pronamic_gateway_mode', true );
24
-		$config->order_id  = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_order_id', true );
21
+		$config->storename = get_post_meta($post_id, '_pronamic_gateway_ems_ecommerce_storename', true);
22
+		$config->secret    = get_post_meta($post_id, '_pronamic_gateway_ems_ecommerce_secret', true);
23
+		$config->mode      = get_post_meta($post_id, '_pronamic_gateway_mode', true);
24
+		$config->order_id  = get_post_meta($post_id, '_pronamic_gateway_ems_ecommerce_order_id', true);
25 25
 
26 26
 		return $config;
27 27
 	}
Please login to merge, or discard this patch.
src/Client.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 *
157 157
 	 * @param string $url Action URL.
158 158
 	 */
159
-	public function set_action_url( $url ) {
159
+	public function set_action_url($url) {
160 160
 		$this->action_url = $url;
161 161
 	}
162 162
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 *
175 175
 	 * @param string $code Currency numeric code.
176 176
 	 */
177
-	public function set_currency_numeric_code( $code ) {
177
+	public function set_currency_numeric_code($code) {
178 178
 		$this->currency_numeric_code = $code;
179 179
 	}
180 180
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 *
193 193
 	 * @param string $storename Storename.
194 194
 	 */
195
-	public function set_storename( $storename ) {
195
+	public function set_storename($storename) {
196 196
 		$this->storename = $storename;
197 197
 	}
198 198
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @param string $return_url Return URL.
214 214
 	 */
215
-	public function set_return_url( $return_url ) {
215
+	public function set_return_url($return_url) {
216 216
 		$this->return_url = $return_url;
217 217
 	}
218 218
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 *
231 231
 	 * @param float $amount Amount.
232 232
 	 */
233
-	public function set_amount( $amount ) {
233
+	public function set_amount($amount) {
234 234
 		$this->amount = $amount;
235 235
 	}
236 236
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @param string $notification_url Notification URL.
250 250
 	 */
251
-	public function set_notification_url( $notification_url ) {
251
+	public function set_notification_url($notification_url) {
252 252
 		$this->notification_url = $notification_url;
253 253
 	}
254 254
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @param string $language Language.
268 268
 	 */
269
-	public function set_language( $language ) {
269
+	public function set_language($language) {
270 270
 		$this->language = $language;
271 271
 	}
272 272
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @param string $payment_method Payment method.
277 277
 	 */
278
-	public function set_payment_method( $payment_method ) {
278
+	public function set_payment_method($payment_method) {
279 279
 		$this->payment_method = $payment_method;
280 280
 	}
281 281
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @param string $order_id Order ID.
304 304
 	 */
305
-	public function set_order_id( $order_id ) {
305
+	public function set_order_id($order_id) {
306 306
 		$this->order_id = $order_id;
307 307
 	}
308 308
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 *
321 321
 	 * @param int $payment_id Payment ID.
322 322
 	 */
323
-	public function set_payment_id( $payment_id ) {
323
+	public function set_payment_id($payment_id) {
324 324
 		$this->payment_id = $payment_id;
325 325
 	}
326 326
 
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
 	 *
332 332
 	 * @return DateTime
333 333
 	 */
334
-	public function get_transaction_datetime( $create_new = false ) {
335
-		if ( null === $this->transaction_datetime || $create_new ) {
336
-			$this->transaction_datetime = new DateTime( null, new DateTimeZone( 'UTC' ) );
334
+	public function get_transaction_datetime($create_new = false) {
335
+		if (null === $this->transaction_datetime || $create_new) {
336
+			$this->transaction_datetime = new DateTime(null, new DateTimeZone('UTC'));
337 337
 		}
338 338
 
339 339
 		return $this->transaction_datetime;
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	 *
345 345
 	 * @param DateTime $datetime Transaction date time.
346 346
 	 */
347
-	public function set_transaction_datetime( DateTime $datetime ) {
347
+	public function set_transaction_datetime(DateTime $datetime) {
348 348
 		$this->transaction_datetime = $datetime;
349 349
 	}
350 350
 
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 			// According the EMS documentation the timezone should be in `Area/Location` notation, but it seems like `UTC` is also working.
361 361
 			'timezone'       => 'UTC',
362 362
 			// In WordPress, PHP's `time()` will always return `UTC` and is the same as calling `current_time( 'timestamp', true )`.
363
-			'txndatetime'    => $this->get_transaction_datetime()->format( 'Y:m:d-H:i:s' ),
363
+			'txndatetime'    => $this->get_transaction_datetime()->format('Y:m:d-H:i:s'),
364 364
 			'hash_algorithm' => 'SHA256',
365 365
 			'storename'      => $this->get_storename(),
366 366
 			'mode'           => 'payonly',
367
-			'chargetotal'    => number_format( ( $this->get_amount() / 100 ), 2, '.', '' ),
367
+			'chargetotal'    => number_format(($this->get_amount() / 100), 2, '.', ''),
368 368
 			'currency'       => $this->get_currency_numeric_code(),
369 369
 		);
370 370
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 		);
382 382
 
383 383
 		// @link http://briancray.com/2009/04/25/remove-null-values-php-arrays/
384
-		$optional_fields = array_filter( $optional_fields );
384
+		$optional_fields = array_filter($optional_fields);
385 385
 
386 386
 		// Data.
387 387
 		$data = $required_fields + $optional_fields;
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 *
406 406
 	 * @return void
407 407
 	 */
408
-	public function set_secret( $secret ) {
408
+	public function set_secret($secret) {
409 409
 		$this->secret = $secret;
410 410
 	}
411 411
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 			$secret,
427 427
 		);
428 428
 
429
-		return self::compute_hash( $values );
429
+		return self::compute_hash($values);
430 430
 	}
431 431
 
432 432
 	/**
@@ -436,11 +436,11 @@  discard block
 block discarded – undo
436 436
 	 *
437 437
 	 * @return string
438 438
 	 */
439
-	public static function compute_hash( $values ) {
440
-		$value = implode( '', $values );
441
-		$value = bin2hex( $value );
439
+	public static function compute_hash($values) {
440
+		$value = implode('', $values);
441
+		$value = bin2hex($value);
442 442
 
443
-		return hash( self::HASH_ALGORITHM_SHA256, $value );
443
+		return hash(self::HASH_ALGORITHM_SHA256, $value);
444 444
 	}
445 445
 
446 446
 	/**
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 	 *
463 463
 	 * @param string $issuer_id Issuer ID.
464 464
 	 */
465
-	public function set_issuer_id( $issuer_id ) {
465
+	public function set_issuer_id($issuer_id) {
466 466
 		$this->issuer_id = $issuer_id;
467 467
 	}
468 468
 
Please login to merge, or discard this patch.
src/Gateway.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -30,23 +30,23 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @param Config $config Config.
32 32
 	 */
33
-	public function __construct( Config $config ) {
34
-		parent::__construct( $config );
33
+	public function __construct(Config $config) {
34
+		parent::__construct($config);
35 35
 
36
-		$this->set_method( self::METHOD_HTML_FORM );
36
+		$this->set_method(self::METHOD_HTML_FORM);
37 37
 
38 38
 		// Client.
39 39
 		$this->client = new Client();
40 40
 
41 41
 		$action_url = Client::ACTION_URL_PRODUCTION;
42 42
 
43
-		if ( self::MODE_TEST === $config->mode ) {
43
+		if (self::MODE_TEST === $config->mode) {
44 44
 			$action_url = Client::ACTION_URL_TEST;
45 45
 		}
46 46
 
47
-		$this->client->set_action_url( $action_url );
48
-		$this->client->set_storename( $config->storename );
49
-		$this->client->set_secret( $config->secret );
47
+		$this->client->set_action_url($action_url);
48
+		$this->client->set_storename($config->storename);
49
+		$this->client->set_secret($config->secret);
50 50
 	}
51 51
 
52 52
 	/**
@@ -70,31 +70,31 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @param Payment $payment Payment.
72 72
 	 */
73
-	public function start( Payment $payment ) {
74
-		$payment->set_action_url( $this->client->get_action_url() );
73
+	public function start(Payment $payment) {
74
+		$payment->set_action_url($this->client->get_action_url());
75 75
 
76
-		$this->client->set_payment_id( $payment->get_id() );
77
-		$this->client->set_currency_numeric_code( $payment->get_total_amount()->get_currency()->get_numeric_code() );
78
-		$this->client->set_order_id( $payment->format_string( $this->config->order_id ) );
79
-		$this->client->set_return_url( home_url( '/' ) );
80
-		$this->client->set_notification_url( home_url( '/' ) );
81
-		$this->client->set_amount( $payment->get_total_amount()->get_cents() );
82
-		$this->client->set_issuer_id( $payment->get_issuer() );
76
+		$this->client->set_payment_id($payment->get_id());
77
+		$this->client->set_currency_numeric_code($payment->get_total_amount()->get_currency()->get_numeric_code());
78
+		$this->client->set_order_id($payment->format_string($this->config->order_id));
79
+		$this->client->set_return_url(home_url('/'));
80
+		$this->client->set_notification_url(home_url('/'));
81
+		$this->client->set_amount($payment->get_total_amount()->get_cents());
82
+		$this->client->set_issuer_id($payment->get_issuer());
83 83
 
84 84
 		// Language.
85
-		if ( null !== $payment->get_customer() ) {
86
-			$this->client->set_language( $payment->get_customer()->get_locale() );
85
+		if (null !== $payment->get_customer()) {
86
+			$this->client->set_language($payment->get_customer()->get_locale());
87 87
 		}
88 88
 
89 89
 		// Payment method.
90
-		$payment_method = PaymentMethods::transform( $payment->get_method() );
90
+		$payment_method = PaymentMethods::transform($payment->get_method());
91 91
 
92
-		if ( null === $payment_method && '' !== $payment->get_method() ) {
92
+		if (null === $payment_method && '' !== $payment->get_method()) {
93 93
 			// Leap of faith if the WordPress payment method could not transform to a EMS method?
94 94
 			$payment_method = $payment->get_method();
95 95
 		}
96 96
 
97
-		$this->client->set_payment_method( $payment_method );
97
+		$this->client->set_payment_method($payment_method);
98 98
 	}
99 99
 
100 100
 	/**
@@ -112,40 +112,40 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @param Payment $payment Payment.
114 114
 	 */
115
-	public function update_status( Payment $payment ) {
116
-		$approval_code = filter_input( INPUT_POST, 'approval_code', FILTER_SANITIZE_STRING );
115
+	public function update_status(Payment $payment) {
116
+		$approval_code = filter_input(INPUT_POST, 'approval_code', FILTER_SANITIZE_STRING);
117 117
 
118
-		$input_hash = filter_input( INPUT_POST, 'response_hash' );
118
+		$input_hash = filter_input(INPUT_POST, 'response_hash');
119 119
 
120 120
 		$hash_values = array(
121 121
 			$this->client->get_secret(),
122 122
 			$approval_code,
123
-			filter_input( INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING ),
124
-			filter_input( INPUT_POST, 'currency', FILTER_SANITIZE_STRING ),
125
-			filter_input( INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING ),
123
+			filter_input(INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING),
124
+			filter_input(INPUT_POST, 'currency', FILTER_SANITIZE_STRING),
125
+			filter_input(INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING),
126 126
 			$this->client->get_storename(),
127 127
 		);
128 128
 
129
-		if ( filter_has_var( INPUT_POST, 'notification_hash' ) ) {
130
-			$input_hash = filter_input( INPUT_POST, 'notification_hash' );
129
+		if (filter_has_var(INPUT_POST, 'notification_hash')) {
130
+			$input_hash = filter_input(INPUT_POST, 'notification_hash');
131 131
 
132 132
 			$hash_values = array(
133
-				filter_input( INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING ),
133
+				filter_input(INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING),
134 134
 				$this->client->get_secret(),
135
-				filter_input( INPUT_POST, 'currency', FILTER_SANITIZE_STRING ),
136
-				filter_input( INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING ),
135
+				filter_input(INPUT_POST, 'currency', FILTER_SANITIZE_STRING),
136
+				filter_input(INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING),
137 137
 				$this->client->get_storename(),
138 138
 				$approval_code,
139 139
 			);
140 140
 		}
141 141
 
142
-		$hash = Client::compute_hash( $hash_values );
142
+		$hash = Client::compute_hash($hash_values);
143 143
 
144 144
 		// Check if the posted hash is equal to the calculated response or notification hash.
145
-		if ( 0 === strcasecmp( $input_hash, $hash ) ) {
146
-			$response_code = substr( $approval_code, 0, 1 );
145
+		if (0 === strcasecmp($input_hash, $hash)) {
146
+			$response_code = substr($approval_code, 0, 1);
147 147
 
148
-			switch ( $response_code ) {
148
+			switch ($response_code) {
149 149
 				case 'Y':
150 150
 					$status = Statuses::SUCCESS;
151 151
 
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
 				case 'N':
154 154
 					$status = Statuses::FAILURE;
155 155
 
156
-					$fail_code = filter_input( INPUT_POST, 'fail_rc', FILTER_SANITIZE_NUMBER_INT );
156
+					$fail_code = filter_input(INPUT_POST, 'fail_rc', FILTER_SANITIZE_NUMBER_INT);
157 157
 
158
-					if ( '5993' === $fail_code ) {
158
+					if ('5993' === $fail_code) {
159 159
 						$status = Statuses::CANCELLED;
160 160
 					}
161 161
 
@@ -168,43 +168,43 @@  discard block
 block discarded – undo
168 168
 			}
169 169
 
170 170
 			// Set the status of the payment.
171
-			$payment->set_status( $status );
171
+			$payment->set_status($status);
172 172
 
173 173
 			$labels = array(
174
-				'approval_code'           => __( 'Approval code', 'pronamic_ideal' ),
175
-				'oid'                     => __( 'Order ID', 'pronamic_ideal' ),
176
-				'refnumber'               => _x( 'Reference number', 'creditcard', 'pronamic_ideal' ),
177
-				'status'                  => __( 'Status', 'pronamic_ideal' ),
178
-				'txndate_processed'       => __( 'Time of transaction processing', 'pronamic_ideal' ),
179
-				'tdate'                   => __( 'Identification for transaction', 'pronamic_ideal' ),
180
-				'fail_reason'             => __( 'Fail reason', 'pronamic_ideal' ),
181
-				'response_hash'           => __( 'Response hash', 'pronamic_ideal' ),
182
-				'processor_response_code' => __( 'Processor response code', 'pronamic_ideal' ),
183
-				'fail_rc'                 => __( 'Fail code', 'pronamic_ideal' ),
184
-				'terminal_id'             => __( 'Terminal ID', 'pronamic_ideal' ),
185
-				'ccbin'                   => __( 'Creditcard issuing bank', 'pronamic_ideal' ),
186
-				'cccountry'               => __( 'Creditcard country', 'pronamic_ideal' ),
187
-				'ccbrand'                 => __( 'Creditcard brand', 'pronamic_ideal' ),
174
+				'approval_code'           => __('Approval code', 'pronamic_ideal'),
175
+				'oid'                     => __('Order ID', 'pronamic_ideal'),
176
+				'refnumber'               => _x('Reference number', 'creditcard', 'pronamic_ideal'),
177
+				'status'                  => __('Status', 'pronamic_ideal'),
178
+				'txndate_processed'       => __('Time of transaction processing', 'pronamic_ideal'),
179
+				'tdate'                   => __('Identification for transaction', 'pronamic_ideal'),
180
+				'fail_reason'             => __('Fail reason', 'pronamic_ideal'),
181
+				'response_hash'           => __('Response hash', 'pronamic_ideal'),
182
+				'processor_response_code' => __('Processor response code', 'pronamic_ideal'),
183
+				'fail_rc'                 => __('Fail code', 'pronamic_ideal'),
184
+				'terminal_id'             => __('Terminal ID', 'pronamic_ideal'),
185
+				'ccbin'                   => __('Creditcard issuing bank', 'pronamic_ideal'),
186
+				'cccountry'               => __('Creditcard country', 'pronamic_ideal'),
187
+				'ccbrand'                 => __('Creditcard brand', 'pronamic_ideal'),
188 188
 			);
189 189
 
190 190
 			$note = '';
191 191
 
192 192
 			$note .= '<p>';
193
-			$note .= __( 'EMS e-Commerce transaction data in response message:', 'pronamic_ideal' );
193
+			$note .= __('EMS e-Commerce transaction data in response message:', 'pronamic_ideal');
194 194
 			$note .= '</p>';
195 195
 
196 196
 			$note .= '<dl>';
197 197
 
198
-			foreach ( $labels as $key => $label ) {
199
-				if ( filter_has_var( INPUT_POST, $key ) ) {
200
-					$note .= sprintf( '<dt>%s</dt>', esc_html( $label ) );
201
-					$note .= sprintf( '<dd>%s</dd>', esc_html( filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING ) ) );
198
+			foreach ($labels as $key => $label) {
199
+				if (filter_has_var(INPUT_POST, $key)) {
200
+					$note .= sprintf('<dt>%s</dt>', esc_html($label));
201
+					$note .= sprintf('<dd>%s</dd>', esc_html(filter_input(INPUT_POST, $key, FILTER_SANITIZE_STRING)));
202 202
 				}
203 203
 			}
204 204
 
205 205
 			$note .= '</dl>';
206 206
 
207
-			$payment->add_note( $note );
207
+			$payment->add_note($note);
208 208
 		}
209 209
 	}
210 210
 }
Please login to merge, or discard this patch.