Failed Conditions
Push — develop ( 5619b1...05b205 )
by Remco
04:23
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-2019 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
if ( null === $payment ) {
25
	return;
26
}
27
28
$purchase_id = get_post_meta( $post_id, '_pronamic_payment_purchase_id', true );
29
30
?>
31
<table class="form-table">
32
	<tr>
33
		<th scope="row">
34
			<?php esc_html_e( 'Date', 'pronamic_ideal' ); ?>
35
		</th>
36
		<td>
37
			<?php echo esc_html( $payment->date->format_i18n() ); ?>
38
		</td>
39
	</tr>
40
	<tr>
41
		<th scope="row">
42
			<?php esc_html_e( 'ID', 'pronamic_ideal' ); ?>
43
		</th>
44
		<td>
45
			<?php echo esc_html( $post_id ); ?>
46
		</td>
47
	</tr>
48
	<tr>
49
		<th scope="row">
50
			<?php esc_html_e( 'Order ID', 'pronamic_ideal' ); ?>
51
		</th>
52
		<td>
53
			<?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

53
			<?php echo esc_html( /** @scrutinizer ignore-type */ get_post_meta( $post_id, '_pronamic_payment_order_id', true ) ); ?>
Loading history...
54
		</td>
55
	</tr>
56
	<tr>
57
		<th scope="row">
58
			<?php esc_html_e( 'Description', 'pronamic_ideal' ); ?>
59
		</th>
60
		<td>
61
			<?php echo esc_html( get_post_meta( $post_id, '_pronamic_payment_description', true ) ); ?>
62
		</td>
63
	</tr>
64
	<tr>
65
		<th scope="row">
66
			<?php esc_html_e( 'Amount', 'pronamic_ideal' ); ?>
67
		</th>
68
		<td>
69
			<?php
70
71
			echo esc_html( $payment->get_total_amount()->format_i18n() );
72
73
			?>
74
		</td>
75
	</tr>
76
	<tr>
77
		<th scope="row">
78
			<?php esc_html_e( 'Transaction ID', 'pronamic_ideal' ); ?>
79
		</th>
80
		<td>
81
			<?php do_action( 'manage_' . $post_type . '_posts_custom_column', 'pronamic_payment_transaction', $post_id ); ?>
82
		</td>
83
	</tr>
84
85
	<?php if ( $purchase_id ) : ?>
86
87
		<tr>
88
			<th scope="row">
89
				<?php esc_html_e( 'Purchase ID', 'pronamic_ideal' ); ?>
90
			</th>
91
			<td>
92
				<?php echo esc_html( $purchase_id ); ?>
93
			</td>
94
		</tr>
95
96
	<?php endif; ?>
97
98
	<tr>
99
		<th scope="row">
100
			<?php esc_html_e( 'Gateway', 'pronamic_ideal' ); ?>
101
		</th>
102
		<td>
103
			<?php edit_post_link( get_the_title( $payment->config_id ), '', '', $payment->config_id ); ?>
104
		</td>
105
	</tr>
106
	<tr>
107
		<th scope="row">
108
			<?php esc_html_e( 'Payment Method', 'pronamic_ideal' ); ?>
109
		</th>
110
		<td>
111
			<?php
112
113
			$method = $payment->get_meta( 'method' );
114
115
			$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

115
			$name = PaymentMethods::get_name( /** @scrutinizer ignore-type */ $method );
Loading history...
116
117
			echo esc_html( $name );
118
119
			$issuer = $payment->get_meta( 'issuer' );
120
121
			if ( $issuer ) {
122
				echo esc_html( sprintf( ' (`%s`)', $issuer ) );
123
			}
124
125
			?>
126
		</td>
127
	</tr>
128
	<tr>
129
		<th scope="row">
130
			<?php esc_html_e( 'Action URL', 'pronamic_ideal' ); ?>
131
		</th>
132
		<td>
133
			<?php
134
135
			$url = get_post_meta( $post_id, '_pronamic_payment_action_url', true );
136
137
			printf(
138
				'<a href="%s" target="_blank">%s</a>',
139
				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

139
				esc_attr( /** @scrutinizer ignore-type */ $url ),
Loading history...
140
				esc_html( $url )
141
			);
142
143
			?>
144
		</td>
145
	</tr>
146
	<tr>
147
		<th scope="row">
148
			<?php esc_html_e( 'Return URL', 'pronamic_ideal' ); ?>
149
		</th>
150
		<td>
151
			<?php
152
153
			$url = $payment->get_return_url();
154
155
			printf(
156
				'<a href="%s">%s</a>',
157
				esc_attr( $url ),
158
				esc_html( $url )
159
			);
160
161
			?>
162
		</td>
163
	</tr>
164
	<tr>
165
		<th scope="row">
166
			<?php esc_html_e( 'Redirect URL', 'pronamic_ideal' ); ?>
167
		</th>
168
		<td>
169
			<?php
170
171
			$url = $payment->get_return_redirect_url();
172
173
			printf(
174
				'<a href="%s">%s</a>',
175
				esc_attr( $url ),
176
				esc_html( $url )
177
			);
178
179
			?>
180
		</td>
181
	</tr>
182
	<tr>
183
		<th scope="row">
184
			<?php esc_html_e( 'Status', 'pronamic_ideal' ); ?>
185
		</th>
186
		<td>
187
			<?php
188
189
			$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

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