Failed Conditions
Push — develop ( 7671b8...0351bb )
by Reüel
03:52
created

admin/meta-box-payment-info.php (4 issues)

1
<?php
2
/**
3
 * Meta Box Payment Info
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2018 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay
9
 */
10
11
use Pronamic\WordPress\Pay\Core\PaymentMethods;
12
use Pronamic\WordPress\Pay\Gender;
13
14
$post_id = get_the_ID();
15
16
if ( empty( $post_id ) ) {
17
	return;
18
}
19
20
$post_type = 'pronamic_payment';
21
22
$payment = get_pronamic_payment( $post_id );
23
24
$purchase_id = get_post_meta( $post_id, '_pronamic_payment_purchase_id', true );
25
26
?>
27
<table class="form-table">
28
	<tr>
29
		<th scope="row">
30
			<?php esc_html_e( 'Date', 'pronamic_ideal' ); ?>
31
		</th>
32
		<td>
33
			<?php echo esc_html( $payment->date->format_i18n() ); ?>
34
		</td>
35
	</tr>
36
	<tr>
37
		<th scope="row">
38
			<?php esc_html_e( 'ID', 'pronamic_ideal' ); ?>
39
		</th>
40
		<td>
41
			<?php echo esc_html( $post_id ); ?>
42
		</td>
43
	</tr>
44
	<tr>
45
		<th scope="row">
46
			<?php esc_html_e( 'Order ID', 'pronamic_ideal' ); ?>
47
		</th>
48
		<td>
49
			<?php echo esc_html( get_post_meta( $post_id, '_pronamic_payment_order_id', true ) ); ?>
0 ignored issues
show
It seems like get_post_meta($post_id, ...ayment_order_id', true) can also be of type false; however, parameter $text of esc_html() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

49
			<?php echo esc_html( /** @scrutinizer ignore-type */ get_post_meta( $post_id, '_pronamic_payment_order_id', true ) ); ?>
Loading history...
50
		</td>
51
	</tr>
52
	<tr>
53
		<th scope="row">
54
			<?php esc_html_e( 'Description', 'pronamic_ideal' ); ?>
55
		</th>
56
		<td>
57
			<?php echo esc_html( get_post_meta( $post_id, '_pronamic_payment_description', true ) ); ?>
58
		</td>
59
	</tr>
60
	<tr>
61
		<th scope="row">
62
			<?php esc_html_e( 'Amount', 'pronamic_ideal' ); ?>
63
		</th>
64
		<td>
65
			<?php
66
67
			echo esc_html( $payment->get_total_amount()->format_i18n() );
68
69
			?>
70
		</td>
71
	</tr>
72
	<tr>
73
		<th scope="row">
74
			<?php esc_html_e( 'Transaction ID', 'pronamic_ideal' ); ?>
75
		</th>
76
		<td>
77
			<?php do_action( 'manage_' . $post_type . '_posts_custom_column', 'pronamic_payment_transaction', $post_id ); ?>
78
		</td>
79
	</tr>
80
81
	<?php if ( $purchase_id ) : ?>
82
83
		<tr>
84
			<th scope="row">
85
				<?php esc_html_e( 'Purchase ID', 'pronamic_ideal' ); ?>
86
			</th>
87
			<td>
88
				<?php echo esc_html( $purchase_id ); ?>
89
			</td>
90
		</tr>
91
92
	<?php endif; ?>
93
94
	<tr>
95
		<th scope="row">
96
			<?php esc_html_e( 'Gateway', 'pronamic_ideal' ); ?>
97
		</th>
98
		<td>
99
			<?php edit_post_link( get_the_title( $payment->config_id ), '', '', $payment->config_id ); ?>
100
		</td>
101
	</tr>
102
	<tr>
103
		<th scope="row">
104
			<?php esc_html_e( 'Payment Method', 'pronamic_ideal' ); ?>
105
		</th>
106
		<td>
107
			<?php
108
109
			$method = $payment->get_meta( 'method' );
110
111
			$name = PaymentMethods::get_name( $method );
0 ignored issues
show
It seems like $method can also be of type false; however, parameter $method of Pronamic\WordPress\Pay\C...mentMethods::get_name() does only seem to accept null|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

111
			$name = PaymentMethods::get_name( /** @scrutinizer ignore-type */ $method );
Loading history...
112
113
			echo esc_html( $name );
114
115
			$issuer = $payment->get_meta( 'issuer' );
116
117
			if ( $issuer ) {
118
				echo esc_html( sprintf( ' (`%s`)', $issuer ) );
119
			}
120
121
			?>
122
		</td>
123
	</tr>
124
	<tr>
125
		<th scope="row">
126
			<?php esc_html_e( 'Action URL', 'pronamic_ideal' ); ?>
127
		</th>
128
		<td>
129
			<?php
130
131
			$url = get_post_meta( $post_id, '_pronamic_payment_action_url', true );
132
133
			printf(
134
				'<a href="%s" target="_blank">%s</a>',
135
				esc_attr( $url ),
0 ignored issues
show
It seems like $url can also be of type false; however, parameter $text of esc_attr() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

135
				esc_attr( /** @scrutinizer ignore-type */ $url ),
Loading history...
136
				esc_html( $url )
137
			);
138
139
			?>
140
		</td>
141
	</tr>
142
	<tr>
143
		<th scope="row">
144
			<?php esc_html_e( 'Return URL', 'pronamic_ideal' ); ?>
145
		</th>
146
		<td>
147
			<?php
148
149
			$url = $payment->get_return_url();
150
151
			printf(
152
				'<a href="%s">%s</a>',
153
				esc_attr( $url ),
154
				esc_html( $url )
155
			);
156
157
			?>
158
		</td>
159
	</tr>
160
	<tr>
161
		<th scope="row">
162
			<?php esc_html_e( 'Redirect URL', 'pronamic_ideal' ); ?>
163
		</th>
164
		<td>
165
			<?php
166
167
			$url = $payment->get_return_redirect_url();
168
169
			printf(
170
				'<a href="%s">%s</a>',
171
				esc_attr( $url ),
172
				esc_html( $url )
173
			);
174
175
			?>
176
		</td>
177
	</tr>
178
	<tr>
179
		<th scope="row">
180
			<?php esc_html_e( 'Status', 'pronamic_ideal' ); ?>
181
		</th>
182
		<td>
183
			<?php
184
185
			$status_object = get_post_status_object( get_post_status( $post_id ) );
0 ignored issues
show
It seems like get_post_status($post_id) can also be of type false; however, parameter $post_status of get_post_status_object() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

185
			$status_object = get_post_status_object( /** @scrutinizer ignore-type */ get_post_status( $post_id ) );
Loading history...
186
187
			if ( isset( $status_object, $status_object->label ) ) {
188
				echo esc_html( $status_object->label );
189
			} else {
190
				echo '—';
191
			}
192
193
			?>
194
		</td>
195
	</tr>
196
197
	<?php if ( null !== $payment->get_customer() ) : ?>
198
199
		<tr>
200
			<th scope="row">
201
				<?php esc_html_e( 'Customer', 'pronamic_ideal' ); ?>
202
			</th>
203
			<td>
204
				<?php
205
206
				if ( null !== $payment->get_customer()->get_name() ) {
207
					echo esc_html( $payment->get_customer()->get_name() );
208
				}
209
210
				?>
211
			</td>
212
		</tr>
213
214
		<?php if ( null !== $payment->get_customer()->get_birth_date() ) : ?>
215
216
			<tr>
217
				<th scope="row">
218
					<?php esc_html_e( 'Date of birth', 'pronamic_ideal' ); ?>
219
				</th>
220
				<td>
221
					<?php
222
223
					echo esc_html( $payment->get_customer()->get_birth_date()->format_i18n( 'D j M Y' ) )
224
225
					?>
226
				</td>
227
			</tr>
228
229
		<?php endif; ?>
230
231
		<?php if ( null !== $payment->get_customer()->get_gender() ) : ?>
232
233
			<tr>
234
				<th scope="row">
235
					<?php esc_html_e( 'Gender', 'pronamic_ideal' ); ?>
236
				</th>
237
				<td>
238
					<?php
239
240
					switch ( $payment->get_customer()->get_gender() ) {
241
						case Gender::FEMALE:
242
							echo esc_html( __( 'Female', 'pronamic_ideal' ) );
243
244
							break;
245
						case Gender::MALE:
246
							echo esc_html( __( 'Male', 'pronamic_ideal' ) );
247
248
							break;
249
						case Gender::OTHER:
250
							echo esc_html( __( 'Other', 'pronamic_ideal' ) );
251
252
							break;
253
					}
254
255
					?>
256
				</td>
257
			</tr>
258
259
		<?php endif; ?>
260
261
	<?php endif; ?>
262
263
	<?php
264
265
	$account_holder = get_post_meta( $post_id, '_pronamic_payment_consumer_name', true );
266
267
	if ( ! empty( $account_holder ) ) :
268
	?>
269
270
		<tr>
271
			<th scope="row">
272
				<?php esc_html_e( 'Account Holder', 'pronamic_ideal' ); ?>
273
			</th>
274
			<td>
275
				<?php echo esc_html( $account_holder ); ?>
276
			</td>
277
		</tr>
278
279
	<?php endif; ?>
280
281
	<?php
282
283
	$account_holder_city = get_post_meta( $post_id, '_pronamic_payment_consumer_city', true );
284
285
	if ( ! empty( $account_holder_city ) ) :
286
	?>
287
288
		<tr>
289
			<th scope="row">
290
				<?php esc_html_e( 'Account Holder City', 'pronamic_ideal' ); ?>
291
			</th>
292
			<td>
293
				<?php echo esc_html( $account_holder_city ); ?>
294
			</td>
295
		</tr>
296
297
	<?php endif; ?>
298
299
	<?php
300
301
	$iban = get_post_meta( $post_id, '_pronamic_payment_consumer_iban', true );
302
303
	if ( ! empty( $iban ) ) :
304
	?>
305
306
		<tr>
307
			<th scope="row">
308
				<?php
309
310
				printf(
311
					'<abbr title="%s">%s</abbr>',
312
					esc_attr( _x( 'International Bank Account Number', 'IBAN abbreviation title', 'pronamic_ideal' ) ),
313
					esc_html__( 'IBAN', 'pronamic_ideal' )
314
				);
315
316
				?>
317
			</th>
318
			<td>
319
				<?php echo esc_html( $iban ); ?>
320
			</td>
321
		</tr>
322
323
	<?php endif; ?>
324
325
	<?php
326
327
	$bic = get_post_meta( $post_id, '_pronamic_payment_consumer_bic', true );
328
329
	if ( ! empty( $bic ) ) :
330
	?>
331
332
		<tr>
333
			<th scope="row">
334
				<?php
335
336
				printf(
337
					'<abbr title="%s">%s</abbr>',
338
					esc_attr( _x( 'Bank Identifier Code', 'BIC abbreviation title', 'pronamic_ideal' ) ),
339
					esc_html__( 'BIC', 'pronamic_ideal' )
340
				);
341
342
				?>
343
			</th>
344
			<td>
345
				<?php echo esc_html( $bic ); ?>
346
			</td>
347
		</tr>
348
349
	<?php endif; ?>
350
351
	<?php if ( null !== $payment->get_billing_address() ) : ?>
352
353
		<tr>
354
			<th scope="row">
355
				<?php esc_html_e( 'Billing Address', 'pronamic_ideal' ); ?>
356
			</th>
357
			<td>
358
				<?php
359
360
				$address = $payment->get_billing_address();
361
362
				echo nl2br( esc_html( (string) $address ) );
363
364
				?>
365
			</td>
366
		</tr>
367
368
	<?php endif; ?>
369
370
	<?php if ( null !== $payment->get_shipping_address() ) : ?>
371
372
		<tr>
373
			<th scope="row">
374
				<?php esc_html_e( 'Shipping Address', 'pronamic_ideal' ); ?>
375
			</th>
376
			<td>
377
				<?php
378
379
				$address = $payment->get_shipping_address();
380
381
				echo nl2br( esc_html( (string) $address ) );
382
383
				?>
384
			</td>
385
		</tr>
386
387
	<?php endif; ?>
388
389
	<tr>
390
		<th scope="row">
391
			<?php esc_html_e( 'Source', 'pronamic_ideal' ); ?>
392
		</th>
393
		<td>
394
			<?php
395
396
			echo $payment->get_source_text(); // WPCS: XSS ok.
397
398
			?>
399
		</td>
400
	</tr>
401
402
	<?php
403
404
	$ga_tracked = $payment->get_ga_tracked();
405
406
	$ga_property_id = get_option( 'pronamic_pay_google_analytics_property' );
407
408
	?>
409
410
	<?php if ( $ga_tracked || ! empty( $ga_property_id ) ) : ?>
411
412
		<tr>
413
			<th scope="row">
414
				<?php esc_html_e( 'Google Analytics', 'pronamic_ideal' ); ?>
415
			</th>
416
			<td>
417
				<?php
418
419
				if ( $ga_tracked ) :
420
421
					esc_html_e( 'Ecommerce conversion tracked', 'pronamic_ideal' );
422
423
				else :
424
425
					esc_html_e( 'Ecommerce conversion not tracked', 'pronamic_ideal' );
426
427
				endif;
428
429
				?>
430
			</td>
431
		</tr>
432
433
	<?php endif; ?>
434
435
	<?php if ( 's2member' === $payment->get_source() ) : ?>
436
437
		<tr>
438
			<th scope="row">
439
				<?php esc_html_e( 'Period', 'pronamic_ideal' ); ?>
440
			</th>
441
			<td>
442
				<?php echo esc_html( get_post_meta( $payment->get_id(), '_pronamic_payment_s2member_period', true ) ); ?>
443
			</td>
444
		</tr>
445
		<tr>
446
			<th scope="row">
447
				<?php esc_html_e( 'Level', 'pronamic_ideal' ); ?>
448
			</th>
449
			<td>
450
				<?php echo esc_html( get_post_meta( $payment->get_id(), '_pronamic_payment_s2member_level', true ) ); ?>
451
			</td>
452
		</tr>
453
454
	<?php endif; ?>
455
456
	<?php if ( 'wp-e-commerce' === $payment->get_source() ) : ?>
457
458
		<tr>
459
			<th scope="row">
460
				<?php esc_html_e( 'Purchase ID', 'pronamic_ideal' ); ?>
461
			</th>
462
			<td>
463
				<?php echo esc_html( get_post_meta( $payment->get_id(), '_pronamic_payment_wpsc_purchase_id', true ) ); ?>
464
			</td>
465
		</tr>
466
		<tr>
467
			<th scope="row">
468
				<?php esc_html_e( 'Session ID', 'pronamic_ideal' ); ?>
469
			</th>
470
			<td>
471
				<?php echo esc_html( get_post_meta( $payment->get_id(), '_pronamic_payment_wpsc_session_id', true ) ); ?>
472
			</td>
473
		</tr>
474
475
	<?php endif; ?>
476
477
	<?php if ( 'membership' === $payment->get_source() ) : ?>
478
479
		<tr>
480
			<th scope="row">
481
				<?php esc_html_e( 'User ID', 'pronamic_ideal' ); ?>
482
			</th>
483
			<td>
484
				<?php echo esc_html( get_post_meta( $payment->get_id(), '_pronamic_payment_membership_user_id', true ) ); ?>
485
			</td>
486
		</tr>
487
		<tr>
488
			<th scope="row">
489
				<?php esc_html_e( 'Subscription ID', 'pronamic_ideal' ); ?>
490
			</th>
491
			<td>
492
				<?php echo esc_html( get_post_meta( $payment->get_id(), '_pronamic_payment_membership_subscription_id', true ) ); ?>
493
			</td>
494
		</tr>
495
496
	<?php endif; ?>
497
498
	<?php if ( PRONAMIC_PAY_DEBUG ) : ?>
499
500
		<tr>
501
			<th scope="row">
502
				<?php esc_html_e( 'User Agent', 'pronamic_ideal' ); ?>
503
			</th>
504
			<td>
505
				<?php echo esc_html( $payment->user_agent ); ?>
506
			</td>
507
		</tr>
508
		<tr>
509
			<th scope="row">
510
				<?php esc_html_e( 'IP Address', 'pronamic_ideal' ); ?>
511
			</th>
512
			<td>
513
				<?php echo esc_html( $payment->user_ip ); ?>
514
			</td>
515
		</tr>
516
517
		<?php if ( null !== $payment->get_version() ) : ?>
518
519
			<tr>
520
				<th scope="row">
521
					<?php esc_html_e( 'Version', 'pronamic_ideal' ); ?>
522
				</th>
523
				<td>
524
					<?php echo esc_html( $payment->get_version() ); ?>
525
				</td>
526
			</tr>
527
528
		<?php endif ?>
529
530
		<?php if ( null !== $payment->get_mode() ) : ?>
531
532
			<tr>
533
				<th scope="row">
534
					<?php esc_html_e( 'Mode', 'pronamic_ideal' ); ?>
535
				</th>
536
				<td>
537
					<?php
538
539
					switch ( $payment->get_mode() ) {
540
						case 'live':
541
							esc_html_e( 'Live', 'pronamic_ideal' );
542
543
							break;
544
						case 'test':
545
							esc_html_e( 'Test', 'pronamic_ideal' );
546
547
							break;
548
						default:
549
							echo esc_html( $payment->get_mode() );
550
551
							break;
552
					}
553
554
					?>
555
				</td>
556
			</tr>
557
558
		<?php endif ?>
559
560
	<?php endif; ?>
561
</table>
562