Passed
Push — master ( 5dd164...f5ff3b )
by Reüel
04:40 queued 10s
created
src/ConfigFactory.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,25 +16,25 @@
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
src/Settings.php 1 patch
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 class Settings extends GatewaySettings {
18 18
 	public function __construct() {
19 19
 		// Filters
20
-		add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) );
20
+		add_filter('pronamic_pay_gateway_fields', array($this, 'fields'));
21 21
 
22 22
 		// Actions
23
-		add_action( 'current_screen', array( $this, 'maybe_download_private_certificate' ) );
24
-		add_action( 'current_screen', array( $this, 'maybe_download_private_key' ) );
23
+		add_action('current_screen', array($this, 'maybe_download_private_certificate'));
24
+		add_action('current_screen', array($this, 'maybe_download_private_key'));
25 25
 	}
26 26
 
27
-	public function fields( array $fields ) {
27
+	public function fields(array $fields) {
28 28
 		/*
29 29
 		 * Private Key and Certificate
30 30
 		 */
@@ -32,83 +32,83 @@  discard block
 block discarded – undo
32 32
 		// Private key and certificate information
33 33
 		$fields[] = array(
34 34
 			'section'  => 'ideal',
35
-			'methods'  => array( 'ideal-advanced-v3' ),
36
-			'title'    => __( 'Private key and certificate', 'pronamic_ideal' ),
35
+			'methods'  => array('ideal-advanced-v3'),
36
+			'title'    => __('Private key and certificate', 'pronamic_ideal'),
37 37
 			'type'     => 'description',
38
-			'callback' => array( $this, 'field_security' ),
38
+			'callback' => array($this, 'field_security'),
39 39
 		);
40 40
 
41 41
 		// Organization
42 42
 		$fields[] = array(
43 43
 			'filter'   => FILTER_SANITIZE_STRING,
44 44
 			'section'  => 'ideal',
45
-			'methods'  => array( 'ideal-advanced-v3' ),
45
+			'methods'  => array('ideal-advanced-v3'),
46 46
 			'group'    => 'pk-cert',
47 47
 			'meta_key' => '_pronamic_gateway_organization',
48
-			'title'    => __( 'Organization', 'pronamic_ideal' ),
48
+			'title'    => __('Organization', 'pronamic_ideal'),
49 49
 			'type'     => 'text',
50
-			'tooltip'  => __( 'Organization name, e.g. Pronamic', 'pronamic_ideal' ),
50
+			'tooltip'  => __('Organization name, e.g. Pronamic', 'pronamic_ideal'),
51 51
 		);
52 52
 
53 53
 		// Organization Unit
54 54
 		$fields[] = array(
55 55
 			'filter'   => FILTER_SANITIZE_STRING,
56 56
 			'section'  => 'ideal',
57
-			'methods'  => array( 'ideal-advanced-v3' ),
57
+			'methods'  => array('ideal-advanced-v3'),
58 58
 			'group'    => 'pk-cert',
59 59
 			'meta_key' => '_pronamic_gateway_organization_unit',
60
-			'title'    => __( 'Organization Unit', 'pronamic_ideal' ),
60
+			'title'    => __('Organization Unit', 'pronamic_ideal'),
61 61
 			'type'     => 'text',
62
-			'tooltip'  => __( 'Organization unit, e.g. Administration', 'pronamic_ideal' ),
62
+			'tooltip'  => __('Organization unit, e.g. Administration', 'pronamic_ideal'),
63 63
 		);
64 64
 
65 65
 		// Locality
66 66
 		$fields[] = array(
67 67
 			'filter'   => FILTER_SANITIZE_STRING,
68 68
 			'section'  => 'ideal',
69
-			'methods'  => array( 'ideal-advanced-v3' ),
69
+			'methods'  => array('ideal-advanced-v3'),
70 70
 			'group'    => 'pk-cert',
71 71
 			'meta_key' => '_pronamic_gateway_locality',
72
-			'title'    => __( 'City', 'pronamic_ideal' ),
72
+			'title'    => __('City', 'pronamic_ideal'),
73 73
 			'type'     => 'text',
74
-			'tooltip'  => __( 'City, e.g. Amsterdam', 'pronamic_ideal' ),
74
+			'tooltip'  => __('City, e.g. Amsterdam', 'pronamic_ideal'),
75 75
 		);
76 76
 
77 77
 		// State or Province
78 78
 		$fields[] = array(
79 79
 			'filter'   => FILTER_SANITIZE_STRING,
80 80
 			'section'  => 'ideal',
81
-			'methods'  => array( 'ideal-advanced-v3' ),
81
+			'methods'  => array('ideal-advanced-v3'),
82 82
 			'group'    => 'pk-cert',
83 83
 			'meta_key' => '_pronamic_gateway_state_or_province',
84
-			'title'    => __( 'State / province', 'pronamic_ideal' ),
84
+			'title'    => __('State / province', 'pronamic_ideal'),
85 85
 			'type'     => 'text',
86
-			'tooltip'  => __( 'State or province, e.g. Friesland', 'pronamic_ideal' ),
86
+			'tooltip'  => __('State or province, e.g. Friesland', 'pronamic_ideal'),
87 87
 		);
88 88
 
89 89
 		// Country
90
-		$locale = explode( '_', get_locale() );
90
+		$locale = explode('_', get_locale());
91 91
 
92
-		$locale = array_pop( $locale );
92
+		$locale = array_pop($locale);
93 93
 
94 94
 		$fields[] = array(
95 95
 			'filter'      => FILTER_SANITIZE_STRING,
96 96
 			'section'     => 'ideal',
97
-			'methods'     => array( 'ideal-advanced-v3' ),
97
+			'methods'     => array('ideal-advanced-v3'),
98 98
 			'group'       => 'pk-cert',
99 99
 			'meta_key'    => '_pronamic_gateway_country',
100
-			'title'       => __( 'Country', 'pronamic_ideal' ),
100
+			'title'       => __('Country', 'pronamic_ideal'),
101 101
 			'type'        => 'text',
102 102
 			'tooltip'     => sprintf(
103 103
 				'%s %s (ISO-3166-1 alpha-2)',
104
-				__( '2 letter country code, e.g.', 'pronamic_ideal' ),
105
-				strtoupper( $locale )
104
+				__('2 letter country code, e.g.', 'pronamic_ideal'),
105
+				strtoupper($locale)
106 106
 			),
107 107
 			'size'        => 2,
108 108
 			'description' => sprintf(
109 109
 				'%s %s',
110
-				__( '2 letter country code, e.g.', 'pronamic_ideal' ),
111
-				strtoupper( $locale )
110
+				__('2 letter country code, e.g.', 'pronamic_ideal'),
111
+				strtoupper($locale)
112 112
 			),
113 113
 		);
114 114
 
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 		$fields[] = array(
117 117
 			'filter'   => FILTER_SANITIZE_STRING,
118 118
 			'section'  => 'ideal',
119
-			'methods'  => array( 'ideal-advanced-v3' ),
119
+			'methods'  => array('ideal-advanced-v3'),
120 120
 			'group'    => 'pk-cert',
121 121
 			'meta_key' => '_pronamic_gateway_email',
122
-			'title'    => __( 'E-mail address', 'pronamic_ideal' ),
122
+			'title'    => __('E-mail address', 'pronamic_ideal'),
123 123
 			'tooltip'  => sprintf(
124 124
 				/* translators: %s: admin email */
125
-				__( 'E-mail address, e.g. %s', 'pronamic_ideal' ),
126
-				get_option( 'admin_email' )
125
+				__('E-mail address, e.g. %s', 'pronamic_ideal'),
126
+				get_option('admin_email')
127 127
 			),
128 128
 			'type'     => 'text',
129 129
 		);
@@ -132,66 +132,66 @@  discard block
 block discarded – undo
132 132
 		$fields[] = array(
133 133
 			'filter'   => FILTER_SANITIZE_NUMBER_INT,
134 134
 			'section'  => 'ideal',
135
-			'methods'  => array( 'ideal-advanced-v3' ),
135
+			'methods'  => array('ideal-advanced-v3'),
136 136
 			'group'    => 'pk-cert',
137 137
 			'meta_key' => '_pronamic_gateway_number_days_valid',
138
-			'title'    => __( 'Number Days Valid', 'pronamic_ideal' ),
138
+			'title'    => __('Number Days Valid', 'pronamic_ideal'),
139 139
 			'type'     => 'text',
140 140
 			'default'  => 1825,
141
-			'tooltip'  => __( 'Number of days the generated certificate will be valid for, e.g. 1825 days for the maximum duration of 5 years.', 'pronamic_ideal' ),
141
+			'tooltip'  => __('Number of days the generated certificate will be valid for, e.g. 1825 days for the maximum duration of 5 years.', 'pronamic_ideal'),
142 142
 		);
143 143
 
144 144
 		// Private Key Password
145 145
 		$fields[] = array(
146 146
 			'filter'   => FILTER_SANITIZE_STRING,
147 147
 			'section'  => 'ideal',
148
-			'methods'  => array( 'ideal-advanced-v3' ),
148
+			'methods'  => array('ideal-advanced-v3'),
149 149
 			'group'    => 'pk-cert',
150 150
 			'meta_key' => '_pronamic_gateway_ideal_private_key_password',
151
-			'title'    => __( 'Private Key Password', 'pronamic_ideal' ),
151
+			'title'    => __('Private Key Password', 'pronamic_ideal'),
152 152
 			'type'     => 'text',
153
-			'classes'  => array( 'regular-text', 'code' ),
153
+			'classes'  => array('regular-text', 'code'),
154 154
 			'default'  => wp_generate_password(),
155
-			'tooltip'  => __( 'A random password which will be used for the generation of the private key and certificate.', 'pronamic_ideal' ),
155
+			'tooltip'  => __('A random password which will be used for the generation of the private key and certificate.', 'pronamic_ideal'),
156 156
 		);
157 157
 
158 158
 		// Private Key
159 159
 		$fields[] = array(
160 160
 			'filter'   => FILTER_SANITIZE_STRING,
161 161
 			'section'  => 'ideal',
162
-			'methods'  => array( 'ideal-advanced-v3' ),
162
+			'methods'  => array('ideal-advanced-v3'),
163 163
 			'group'    => 'pk-cert',
164 164
 			'meta_key' => '_pronamic_gateway_ideal_private_key',
165
-			'title'    => __( 'Private Key', 'pronamic_ideal' ),
165
+			'title'    => __('Private Key', 'pronamic_ideal'),
166 166
 			'type'     => 'textarea',
167
-			'callback' => array( $this, 'field_private_key' ),
168
-			'classes'  => array( 'code' ),
169
-			'tooltip'  => __( 'The private key is used for secure communication with the payment provider. If left empty, the private key will be generated using the given private key password.', 'pronamic_ideal' ),
167
+			'callback' => array($this, 'field_private_key'),
168
+			'classes'  => array('code'),
169
+			'tooltip'  => __('The private key is used for secure communication with the payment provider. If left empty, the private key will be generated using the given private key password.', 'pronamic_ideal'),
170 170
 		);
171 171
 
172 172
 		// Private Certificate
173 173
 		$fields[] = array(
174 174
 			'filter'   => FILTER_SANITIZE_STRING,
175 175
 			'section'  => 'ideal',
176
-			'methods'  => array( 'ideal-advanced-v3' ),
176
+			'methods'  => array('ideal-advanced-v3'),
177 177
 			'group'    => 'pk-cert',
178 178
 			'meta_key' => '_pronamic_gateway_ideal_private_certificate',
179
-			'title'    => __( 'Private Certificate', 'pronamic_ideal' ),
179
+			'title'    => __('Private Certificate', 'pronamic_ideal'),
180 180
 			'type'     => 'textarea',
181
-			'callback' => array( $this, 'field_private_certificate' ),
182
-			'classes'  => array( 'code' ),
183
-			'tooltip'  => __( 'The certificate is used for secure communication with the payment provider. If left empty, the certificate will be generated using the private key and given organization details.', 'pronamic_ideal' ),
181
+			'callback' => array($this, 'field_private_certificate'),
182
+			'classes'  => array('code'),
183
+			'tooltip'  => __('The certificate is used for secure communication with the payment provider. If left empty, the certificate will be generated using the private key and given organization details.', 'pronamic_ideal'),
184 184
 		);
185 185
 
186 186
 		// Transaction feedback
187 187
 		$fields[] = array(
188 188
 			'section' => 'ideal',
189
-			'methods' => array( 'ideal-advanced-v3' ),
190
-			'title'   => __( 'Transaction feedback', 'pronamic_ideal' ),
189
+			'methods' => array('ideal-advanced-v3'),
190
+			'title'   => __('Transaction feedback', 'pronamic_ideal'),
191 191
 			'type'    => 'description',
192 192
 			'html'    => sprintf(
193 193
 				'<span class="dashicons dashicons-yes"></span> %s',
194
-				__( 'Payment status updates will be processed without any additional configuration.', 'pronamic_ideal' )
194
+				__('Payment status updates will be processed without any additional configuration.', 'pronamic_ideal')
195 195
 			),
196 196
 		);
197 197
 
@@ -204,25 +204,25 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @param array $field
206 206
 	 */
207
-	public function field_security( $field ) {
208
-		$certificate = get_post_meta( get_the_ID(), '_pronamic_gateway_ideal_private_certificate', true );
207
+	public function field_security($field) {
208
+		$certificate = get_post_meta(get_the_ID(), '_pronamic_gateway_ideal_private_certificate', true);
209 209
 
210 210
 		?>
211 211
 		<p>
212
-			<?php if ( empty( $certificate ) ) : ?>
212
+			<?php if (empty($certificate)) : ?>
213 213
 
214 214
 				<span
215
-					class="dashicons dashicons-no"></span> <?php esc_html_e( 'The private key and certificate have not yet been configured.', 'pronamic_ideal' ); ?>
215
+					class="dashicons dashicons-no"></span> <?php esc_html_e('The private key and certificate have not yet been configured.', 'pronamic_ideal'); ?>
216 216
 				<br/>
217 217
 
218 218
 				<br/>
219 219
 
220
-				<?php esc_html_e( 'A private key and certificate are required for communication with the payment provider. Enter the organization details from the iDEAL account below to generate these required files.', 'pronamic_ideal' ); ?>
220
+				<?php esc_html_e('A private key and certificate are required for communication with the payment provider. Enter the organization details from the iDEAL account below to generate these required files.', 'pronamic_ideal'); ?>
221 221
 
222 222
 			<?php else : ?>
223 223
 
224 224
 				<span
225
-					class="dashicons dashicons-yes"></span> <?php esc_html_e( 'A private key and certificate have been configured. The certificate must be uploaded to the payment provider dashboard to complete configuration.', 'pronamic_ideal' ); ?>
225
+					class="dashicons dashicons-yes"></span> <?php esc_html_e('A private key and certificate have been configured. The certificate must be uploaded to the payment provider dashboard to complete configuration.', 'pronamic_ideal'); ?>
226 226
 				<br/>
227 227
 
228 228
 				<br/>
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 				<?php
231 231
 
232 232
 				submit_button(
233
-					__( 'Download certificate', 'pronamic_ideal' ),
233
+					__('Download certificate', 'pronamic_ideal'),
234 234
 					'secondary',
235 235
 					'download_private_certificate',
236 236
 					false
@@ -238,37 +238,37 @@  discard block
 block discarded – undo
238 238
 
239 239
 				?>
240 240
 
241
-				<a class="pronamic-pay-btn-link" href="#" id="pk-cert-fields-toggle"><?php esc_html_e( 'Show details…', 'pronamic_ideal' ); ?></a>
241
+				<a class="pronamic-pay-btn-link" href="#" id="pk-cert-fields-toggle"><?php esc_html_e('Show details…', 'pronamic_ideal'); ?></a>
242 242
 
243 243
 			<?php endif; ?>
244 244
 		</p>
245 245
 		<?php
246 246
 	}
247 247
 
248
-	public function field_private_key( $field ) {
249
-		$private_key          = get_post_meta( get_the_ID(), '_pronamic_gateway_ideal_private_key', true );
250
-		$private_key_password = get_post_meta( get_the_ID(), '_pronamic_gateway_ideal_private_key_password', true );
251
-		$number_days_valid    = get_post_meta( get_the_ID(), '_pronamic_gateway_number_days_valid', true );
248
+	public function field_private_key($field) {
249
+		$private_key          = get_post_meta(get_the_ID(), '_pronamic_gateway_ideal_private_key', true);
250
+		$private_key_password = get_post_meta(get_the_ID(), '_pronamic_gateway_ideal_private_key_password', true);
251
+		$number_days_valid    = get_post_meta(get_the_ID(), '_pronamic_gateway_number_days_valid', true);
252 252
 
253
-		$filename = __( 'ideal.key', 'pronamic_ideal' );
253
+		$filename = __('ideal.key', 'pronamic_ideal');
254 254
 
255
-		if ( ! empty( $private_key_password ) && ! empty( $number_days_valid ) ) {
255
+		if ( ! empty($private_key_password) && ! empty($number_days_valid)) {
256 256
 			$command = sprintf(
257 257
 				'openssl genrsa -aes128 -out %s -passout pass:%s 2048',
258
-				escapeshellarg( $filename ),
259
-				escapeshellarg( $private_key_password )
258
+				escapeshellarg($filename),
259
+				escapeshellarg($private_key_password)
260 260
 			);
261 261
 
262 262
 			?>
263 263
 
264
-			<p><?php esc_html_e( 'OpenSSL command', 'pronamic_ideal' ); ?></p>
265
-			<input id="pronamic_ideal_openssl_command_key" name="pronamic_ideal_openssl_command_key" value="<?php echo esc_attr( $command ); ?>" type="text" class="large-text code" readonly="readonly"/>
264
+			<p><?php esc_html_e('OpenSSL command', 'pronamic_ideal'); ?></p>
265
+			<input id="pronamic_ideal_openssl_command_key" name="pronamic_ideal_openssl_command_key" value="<?php echo esc_attr($command); ?>" type="text" class="large-text code" readonly="readonly"/>
266 266
 
267 267
 			<?php
268 268
 		} else {
269 269
 			printf(
270 270
 				'<p class="pronamic-pay-description description">%s</p>',
271
-				esc_html__( 'Leave empty and save the configuration to generate the private key or view the OpenSSL command.', 'pronamic_ideal' )
271
+				esc_html__('Leave empty and save the configuration to generate the private key or view the OpenSSL command.', 'pronamic_ideal')
272 272
 			);
273 273
 		}
274 274
 
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
 		<p>
277 277
 			<?php
278 278
 
279
-			if ( ! empty( $private_key ) ) {
279
+			if ( ! empty($private_key)) {
280 280
 				submit_button(
281
-					__( 'Download', 'pronamic_ideal' ),
281
+					__('Download', 'pronamic_ideal'),
282 282
 					'secondary',
283 283
 					'download_private_key',
284 284
 					false
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 
290 290
 			printf(
291 291
 				'<label class="pronamic-pay-form-control-file-button button">%s <input type="file" name="%s" /></label>',
292
-				esc_html__( 'Upload', 'pronamic_ideal' ),
292
+				esc_html__('Upload', 'pronamic_ideal'),
293 293
 				'_pronamic_gateway_ideal_private_key_file'
294 294
 			);
295 295
 
@@ -298,79 +298,79 @@  discard block
 block discarded – undo
298 298
 		<?php
299 299
 	}
300 300
 
301
-	public function field_private_certificate( $field ) {
302
-		$certificate = get_post_meta( get_the_ID(), '_pronamic_gateway_ideal_private_certificate', true );
301
+	public function field_private_certificate($field) {
302
+		$certificate = get_post_meta(get_the_ID(), '_pronamic_gateway_ideal_private_certificate', true);
303 303
 
304
-		$private_key_password = get_post_meta( get_the_ID(), '_pronamic_gateway_ideal_private_key_password', true );
305
-		$number_days_valid    = get_post_meta( get_the_ID(), '_pronamic_gateway_number_days_valid', true );
304
+		$private_key_password = get_post_meta(get_the_ID(), '_pronamic_gateway_ideal_private_key_password', true);
305
+		$number_days_valid    = get_post_meta(get_the_ID(), '_pronamic_gateway_number_days_valid', true);
306 306
 
307
-		$filename_key = __( 'ideal.key', 'pronamic_ideal' );
308
-		$filename_cer = __( 'ideal.cer', 'pronamic_ideal' );
307
+		$filename_key = __('ideal.key', 'pronamic_ideal');
308
+		$filename_cer = __('ideal.cer', 'pronamic_ideal');
309 309
 
310 310
 		// @link http://www.openssl.org/docs/apps/req.html
311 311
 		$subj_args = array(
312
-			'C'            => get_post_meta( get_the_ID(), '_pronamic_gateway_country', true ),
313
-			'ST'           => get_post_meta( get_the_ID(), '_pronamic_gateway_state_or_province', true ),
314
-			'L'            => get_post_meta( get_the_ID(), '_pronamic_gateway_locality', true ),
315
-			'O'            => get_post_meta( get_the_ID(), '_pronamic_gateway_organization', true ),
316
-			'OU'           => get_post_meta( get_the_ID(), '_pronamic_gateway_organization_unit', true ),
317
-			'CN'           => get_post_meta( get_the_ID(), '_pronamic_gateway_organization', true ),
318
-			'emailAddress' => get_post_meta( get_the_ID(), '_pronamic_gateway_email', true ),
312
+			'C'            => get_post_meta(get_the_ID(), '_pronamic_gateway_country', true),
313
+			'ST'           => get_post_meta(get_the_ID(), '_pronamic_gateway_state_or_province', true),
314
+			'L'            => get_post_meta(get_the_ID(), '_pronamic_gateway_locality', true),
315
+			'O'            => get_post_meta(get_the_ID(), '_pronamic_gateway_organization', true),
316
+			'OU'           => get_post_meta(get_the_ID(), '_pronamic_gateway_organization_unit', true),
317
+			'CN'           => get_post_meta(get_the_ID(), '_pronamic_gateway_organization', true),
318
+			'emailAddress' => get_post_meta(get_the_ID(), '_pronamic_gateway_email', true),
319 319
 		);
320 320
 
321
-		$subj_args = array_filter( $subj_args );
321
+		$subj_args = array_filter($subj_args);
322 322
 
323 323
 		$subj = '';
324
-		foreach ( $subj_args as $type => $value ) {
325
-			$subj .= '/' . $type . '=' . addslashes( $value );
324
+		foreach ($subj_args as $type => $value) {
325
+			$subj .= '/' . $type . '=' . addslashes($value);
326 326
 		}
327 327
 
328
-		if ( ! empty( $subj ) ) {
329
-			$command = trim( sprintf(
328
+		if ( ! empty($subj)) {
329
+			$command = trim(sprintf(
330 330
 				'openssl req -x509 -sha256 -new -key %s -passin pass:%s -days %s -out %s %s',
331
-				escapeshellarg( $filename_key ),
332
-				escapeshellarg( $private_key_password ),
333
-				escapeshellarg( $number_days_valid ),
334
-				escapeshellarg( $filename_cer ),
335
-				empty( $subj ) ? '' : sprintf( '-subj %s', escapeshellarg( $subj ) )
336
-			) );
331
+				escapeshellarg($filename_key),
332
+				escapeshellarg($private_key_password),
333
+				escapeshellarg($number_days_valid),
334
+				escapeshellarg($filename_cer),
335
+				empty($subj) ? '' : sprintf('-subj %s', escapeshellarg($subj))
336
+			));
337 337
 
338 338
 			?>
339 339
 
340
-			<p><?php esc_html_e( 'OpenSSL command', 'pronamic_ideal' ); ?></p>
341
-			<input id="pronamic_ideal_openssl_command_certificate" name="pronamic_ideal_openssl_command_certificate" value="<?php echo esc_attr( $command ); ?>" type="text" class="large-text code" readonly="readonly"/>
340
+			<p><?php esc_html_e('OpenSSL command', 'pronamic_ideal'); ?></p>
341
+			<input id="pronamic_ideal_openssl_command_certificate" name="pronamic_ideal_openssl_command_certificate" value="<?php echo esc_attr($command); ?>" type="text" class="large-text code" readonly="readonly"/>
342 342
 
343 343
 			<?php
344 344
 		} else {
345 345
 			printf(
346 346
 				'<p class="pronamic-pay-description description">%s</p>',
347
-				esc_html__( 'Leave empty and save the configuration to generate the certificate or view the OpenSSL command.', 'pronamic_ideal' )
347
+				esc_html__('Leave empty and save the configuration to generate the certificate or view the OpenSSL command.', 'pronamic_ideal')
348 348
 			);
349 349
 		}
350 350
 
351
-		if ( ! empty( $certificate ) ) {
352
-			$fingerprint = Security::get_sha_fingerprint( $certificate );
353
-			$fingerprint = str_split( $fingerprint, 2 );
354
-			$fingerprint = implode( ':', $fingerprint );
351
+		if ( ! empty($certificate)) {
352
+			$fingerprint = Security::get_sha_fingerprint($certificate);
353
+			$fingerprint = str_split($fingerprint, 2);
354
+			$fingerprint = implode(':', $fingerprint);
355 355
 
356 356
 			echo '<dl>';
357 357
 
358
-			echo '<dt>', esc_html__( 'SHA Fingerprint', 'pronamic_ideal' ), '</dt>';
359
-			echo '<dd>', esc_html( $fingerprint ), '</dd>';
358
+			echo '<dt>', esc_html__('SHA Fingerprint', 'pronamic_ideal'), '</dt>';
359
+			echo '<dd>', esc_html($fingerprint), '</dd>';
360 360
 
361
-			$info = openssl_x509_parse( $certificate );
361
+			$info = openssl_x509_parse($certificate);
362 362
 
363
-			if ( $info ) {
364
-				$date_format = __( 'M j, Y @ G:i', 'pronamic_ideal' );
363
+			if ($info) {
364
+				$date_format = __('M j, Y @ G:i', 'pronamic_ideal');
365 365
 
366
-				if ( isset( $info['validFrom_time_t'] ) ) {
367
-					echo '<dt>', esc_html__( 'Valid From', 'pronamic_ideal' ), '</dt>';
368
-					echo '<dd>', esc_html( date_i18n( $date_format, $info['validFrom_time_t'] ) ), '</dd>';
366
+				if (isset($info['validFrom_time_t'])) {
367
+					echo '<dt>', esc_html__('Valid From', 'pronamic_ideal'), '</dt>';
368
+					echo '<dd>', esc_html(date_i18n($date_format, $info['validFrom_time_t'])), '</dd>';
369 369
 				}
370 370
 
371
-				if ( isset( $info['validTo_time_t'] ) ) {
372
-					echo '<dt>', esc_html__( 'Valid To', 'pronamic_ideal' ), '</dt>';
373
-					echo '<dd>', esc_html( date_i18n( $date_format, $info['validTo_time_t'] ) ), '</dd>';
371
+				if (isset($info['validTo_time_t'])) {
372
+					echo '<dt>', esc_html__('Valid To', 'pronamic_ideal'), '</dt>';
373
+					echo '<dd>', esc_html(date_i18n($date_format, $info['validTo_time_t'])), '</dd>';
374 374
 				}
375 375
 			}
376 376
 
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
 		<p>
382 382
 			<?php
383 383
 
384
-			if ( ! empty( $certificate ) ) {
384
+			if ( ! empty($certificate)) {
385 385
 				submit_button(
386
-					__( 'Download', 'pronamic_ideal' ),
386
+					__('Download', 'pronamic_ideal'),
387 387
 					'secondary',
388 388
 					'download_private_certificate',
389 389
 					false
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 
395 395
 			printf(
396 396
 				'<label class="pronamic-pay-form-control-file-button button">%s <input type="file" name="%s" /></label>',
397
-				esc_html__( 'Upload', 'pronamic_ideal' ),
397
+				esc_html__('Upload', 'pronamic_ideal'),
398 398
 				'_pronamic_gateway_ideal_private_certificate_file'
399 399
 			);
400 400
 
@@ -407,16 +407,16 @@  discard block
 block discarded – undo
407 407
 	 * Download private certificate
408 408
 	 */
409 409
 	public function maybe_download_private_certificate() {
410
-		if ( filter_has_var( INPUT_POST, 'download_private_certificate' ) ) {
411
-			$post_id = filter_input( INPUT_POST, 'post_ID', FILTER_SANITIZE_STRING );
410
+		if (filter_has_var(INPUT_POST, 'download_private_certificate')) {
411
+			$post_id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_STRING);
412 412
 
413
-			$filename = sprintf( 'ideal-private-certificate-%s.cer', $post_id );
413
+			$filename = sprintf('ideal-private-certificate-%s.cer', $post_id);
414 414
 
415
-			header( 'Content-Description: File Transfer' );
416
-			header( 'Content-Disposition: attachment; filename=' . $filename );
417
-			header( 'Content-Type: application/x-x509-ca-cert; charset=' . get_option( 'blog_charset' ), true );
415
+			header('Content-Description: File Transfer');
416
+			header('Content-Disposition: attachment; filename=' . $filename);
417
+			header('Content-Type: application/x-x509-ca-cert; charset=' . get_option('blog_charset'), true);
418 418
 
419
-			echo get_post_meta( $post_id, '_pronamic_gateway_ideal_private_certificate', true ); //xss ok
419
+			echo get_post_meta($post_id, '_pronamic_gateway_ideal_private_certificate', true); //xss ok
420 420
 
421 421
 			exit;
422 422
 		}
@@ -426,16 +426,16 @@  discard block
 block discarded – undo
426 426
 	 * Download private key
427 427
 	 */
428 428
 	public function maybe_download_private_key() {
429
-		if ( filter_has_var( INPUT_POST, 'download_private_key' ) ) {
430
-			$post_id = filter_input( INPUT_POST, 'post_ID', FILTER_SANITIZE_STRING );
429
+		if (filter_has_var(INPUT_POST, 'download_private_key')) {
430
+			$post_id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_STRING);
431 431
 
432
-			$filename = sprintf( 'ideal-private-key-%s.key', $post_id );
432
+			$filename = sprintf('ideal-private-key-%s.key', $post_id);
433 433
 
434
-			header( 'Content-Description: File Transfer' );
435
-			header( 'Content-Disposition: attachment; filename=' . $filename );
436
-			header( 'Content-Type: application/pgp-keys; charset=' . get_option( 'blog_charset' ), true );
434
+			header('Content-Description: File Transfer');
435
+			header('Content-Disposition: attachment; filename=' . $filename);
436
+			header('Content-Type: application/pgp-keys; charset=' . get_option('blog_charset'), true);
437 437
 
438
-			echo get_post_meta( $post_id, '_pronamic_gateway_ideal_private_key', true ); //xss ok
438
+			echo get_post_meta($post_id, '_pronamic_gateway_ideal_private_key', true); //xss ok
439 439
 
440 440
 			exit;
441 441
 		}
@@ -444,41 +444,41 @@  discard block
 block discarded – undo
444 444
 	/***
445 445
 	 * Save post.
446 446
 	 */
447
-	public function save_post( $data ) {
447
+	public function save_post($data) {
448 448
 		// Files
449 449
 		$files = array(
450 450
 			'_pronamic_gateway_ideal_private_key_file' => '_pronamic_gateway_ideal_private_key',
451 451
 			'_pronamic_gateway_ideal_private_certificate_file' => '_pronamic_gateway_ideal_private_certificate',
452 452
 		);
453 453
 
454
-		foreach ( $files as $name => $meta_key ) {
455
-			if ( isset( $_FILES[ $name ] ) && UPLOAD_ERR_OK === $_FILES[ $name ]['error'] ) { // WPCS: input var okay.
456
-				$value = file_get_contents( $_FILES[ $name ]['tmp_name'] ); // WPCS: input var okay. // WPCS: sanitization ok.
454
+		foreach ($files as $name => $meta_key) {
455
+			if (isset($_FILES[$name]) && UPLOAD_ERR_OK === $_FILES[$name]['error']) { // WPCS: input var okay.
456
+				$value = file_get_contents($_FILES[$name]['tmp_name']); // WPCS: input var okay. // WPCS: sanitization ok.
457 457
 
458
-				$data[ $meta_key ] = $value;
458
+				$data[$meta_key] = $value;
459 459
 			}
460 460
 		}
461 461
 
462 462
 		// Generate private key and certificate
463
-		if ( empty( $data['_pronamic_gateway_ideal_private_key_password'] ) ) {
463
+		if (empty($data['_pronamic_gateway_ideal_private_key_password'])) {
464 464
 			// Without private key password we can't create private key and certifiate.
465 465
 			return $data;
466 466
 		}
467 467
 
468
-		if ( ! in_array( 'aes-128-cbc', openssl_get_cipher_methods(), true ) ) {
468
+		if ( ! in_array('aes-128-cbc', openssl_get_cipher_methods(), true)) {
469 469
 			// Without AES-128-CBC ciphter method we can't create private key and certificate.
470 470
 			return $data;
471 471
 		}
472 472
 
473 473
 		// Private key
474
-		$pkey = openssl_pkey_get_private( $data['_pronamic_gateway_ideal_private_key'], $data['_pronamic_gateway_ideal_private_key_password'] );
474
+		$pkey = openssl_pkey_get_private($data['_pronamic_gateway_ideal_private_key'], $data['_pronamic_gateway_ideal_private_key_password']);
475 475
 
476
-		if ( false === $pkey ) {
476
+		if (false === $pkey) {
477 477
 			// If we can't open the private key we will create a new private key and certificate.
478 478
 
479
-			if ( defined( 'OPENSSL_CIPHER_AES_128_CBC' ) ) {
479
+			if (defined('OPENSSL_CIPHER_AES_128_CBC')) {
480 480
 				$cipher = OPENSSL_CIPHER_AES_128_CBC;
481
-			} elseif ( defined( 'OPENSSL_CIPHER_3DES' ) ) {
481
+			} elseif (defined('OPENSSL_CIPHER_3DES')) {
482 482
 				// @link https://www.pronamic.nl/wp-content/uploads/2011/12/iDEAL_Advanced_PHP_EN_V2.2.pdf
483 483
 				$cipher = OPENSSL_CIPHER_3DES;
484 484
 			} else {
@@ -497,16 +497,16 @@  discard block
 block discarded – undo
497 497
 				'basicConstraints'       => 'CA:true',
498 498
 			);
499 499
 
500
-			$pkey = openssl_pkey_new( $args );
500
+			$pkey = openssl_pkey_new($args);
501 501
 
502
-			if ( false === $pkey ) {
502
+			if (false === $pkey) {
503 503
 				return $data;
504 504
 			}
505 505
 
506 506
 			// Export key
507
-			$result = openssl_pkey_export( $pkey, $private_key, $data['_pronamic_gateway_ideal_private_key_password'], $args );
507
+			$result = openssl_pkey_export($pkey, $private_key, $data['_pronamic_gateway_ideal_private_key_password'], $args);
508 508
 
509
-			if ( false === $result ) {
509
+			if (false === $result) {
510 510
 				return $data;
511 511
 			}
512 512
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 		}
517 517
 
518 518
 		// Certificate
519
-		if ( empty( $data['_pronamic_gateway_ideal_private_certificate'] ) ) {
519
+		if (empty($data['_pronamic_gateway_ideal_private_certificate'])) {
520 520
 			$required_keys = array(
521 521
 				'countryName',
522 522
 				'stateOrProvinceName',
@@ -536,16 +536,16 @@  discard block
 block discarded – undo
536 536
 				'emailAddress'           => $data['_pronamic_gateway_email'],
537 537
 			);
538 538
 
539
-			$distinguished_name = array_filter( $distinguished_name );
539
+			$distinguished_name = array_filter($distinguished_name);
540 540
 
541 541
 			// Create certificate only if distinguished name contains all required elements
542 542
 			// @link http://stackoverflow.com/questions/13169588/how-to-check-if-multiple-array-keys-exists
543
-			if ( count( array_intersect_key( array_flip( $required_keys ), $distinguished_name ) ) === count( $required_keys ) ) {
544
-				$csr = openssl_csr_new( $distinguished_name, $pkey );
543
+			if (count(array_intersect_key(array_flip($required_keys), $distinguished_name)) === count($required_keys)) {
544
+				$csr = openssl_csr_new($distinguished_name, $pkey);
545 545
 
546
-				$cert = openssl_csr_sign( $csr, null, $pkey, $data['_pronamic_gateway_number_days_valid'], $args, time() );
546
+				$cert = openssl_csr_sign($csr, null, $pkey, $data['_pronamic_gateway_number_days_valid'], $args, time());
547 547
 
548
-				openssl_x509_export( $cert, $certificate );
548
+				openssl_x509_export($cert, $certificate);
549 549
 
550 550
 				$data['_pronamic_gateway_ideal_private_certificate'] = $certificate;
551 551
 			}
Please login to merge, or discard this patch.
src/Client.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Gateway.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.