Failed Conditions
Push — develop ( a66df3...4f548c )
by Reüel
04:33
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
$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 if ( null !== $payment->get_customer()->get_user_id() ) : ?>
262
263
			<tr>
264
				<th scope="row">
265
					<?php esc_html_e( 'User', 'pronamic_ideal' ); ?>
266
				</th>
267
				<td>
268
					<?php
269
270
					$user_id = $payment->get_customer()->get_user_id();
271
272
					printf(
273
						'<a href="%s">%s</a>',
274
						esc_url( get_edit_user_link( $user_id ) ),
275
						esc_html( $user_id )
276
					);
277
278
					?>
279
				</td>
280
			</tr>
281
282
		<?php endif; ?>
283
284
	<?php endif; ?>
285
286
	<?php
287
288
	$account_holder = get_post_meta( $post_id, '_pronamic_payment_consumer_name', true );
289
290
	if ( ! empty( $account_holder ) ) :
291
	?>
292
293
		<tr>
294
			<th scope="row">
295
				<?php esc_html_e( 'Account Holder', 'pronamic_ideal' ); ?>
296
			</th>
297
			<td>
298
				<?php echo esc_html( $account_holder ); ?>
299
			</td>
300
		</tr>
301
302
	<?php endif; ?>
303
304
	<?php
305
306
	$account_holder_city = get_post_meta( $post_id, '_pronamic_payment_consumer_city', true );
307
308
	if ( ! empty( $account_holder_city ) ) :
309
	?>
310
311
		<tr>
312
			<th scope="row">
313
				<?php esc_html_e( 'Account Holder City', 'pronamic_ideal' ); ?>
314
			</th>
315
			<td>
316
				<?php echo esc_html( $account_holder_city ); ?>
317
			</td>
318
		</tr>
319
320
	<?php endif; ?>
321
322
	<?php
323
324
	$account_number = get_post_meta( $post_id, '_pronamic_payment_consumer_account_number', true );
325
326
	if ( ! empty( $account_number ) ) :
327
	?>
328
329
		<tr>
330
			<th scope="row">
331
				<?php esc_html_e( 'Account Number', 'pronamic_ideal' ); ?>
332
			</th>
333
			<td>
334
				<?php echo esc_html( $account_number ); ?>
335
			</td>
336
		</tr>
337
338
	<?php endif; ?>
339
340
	<?php
341
342
	$iban = get_post_meta( $post_id, '_pronamic_payment_consumer_iban', true );
343
344
	if ( ! empty( $iban ) ) :
345
	?>
346
347
		<tr>
348
			<th scope="row">
349
				<?php
350
351
				printf(
352
					'<abbr title="%s">%s</abbr>',
353
					esc_attr( _x( 'International Bank Account Number', 'IBAN abbreviation title', 'pronamic_ideal' ) ),
354
					esc_html__( 'IBAN', 'pronamic_ideal' )
355
				);
356
357
				?>
358
			</th>
359
			<td>
360
				<?php echo esc_html( $iban ); ?>
361
			</td>
362
		</tr>
363
364
	<?php endif; ?>
365
366
	<?php
367
368
	$bic = get_post_meta( $post_id, '_pronamic_payment_consumer_bic', true );
369
370
	if ( ! empty( $bic ) ) :
371
	?>
372
373
		<tr>
374
			<th scope="row">
375
				<?php
376
377
				printf(
378
					'<abbr title="%s">%s</abbr>',
379
					esc_attr( _x( 'Bank Identifier Code', 'BIC abbreviation title', 'pronamic_ideal' ) ),
380
					esc_html__( 'BIC', 'pronamic_ideal' )
381
				);
382
383
				?>
384
			</th>
385
			<td>
386
				<?php echo esc_html( $bic ); ?>
387
			</td>
388
		</tr>
389
390
	<?php endif; ?>
391
392
	<?php if ( null !== $payment->get_billing_address() ) : ?>
393
394
		<tr>
395
			<th scope="row">
396
				<?php esc_html_e( 'Billing Address', 'pronamic_ideal' ); ?>
397
			</th>
398
			<td>
399
				<?php
400
401
				$address = $payment->get_billing_address();
402
403
				echo nl2br( esc_html( (string) $address ) );
404
405
				?>
406
			</td>
407
		</tr>
408
409
	<?php endif; ?>
410
411
	<?php if ( null !== $payment->get_shipping_address() ) : ?>
412
413
		<tr>
414
			<th scope="row">
415
				<?php esc_html_e( 'Shipping Address', 'pronamic_ideal' ); ?>
416
			</th>
417
			<td>
418
				<?php
419
420
				$address = $payment->get_shipping_address();
421
422
				echo nl2br( esc_html( (string) $address ) );
423
424
				?>
425
			</td>
426
		</tr>
427
428
	<?php endif; ?>
429
430
	<tr>
431
		<th scope="row">
432
			<?php esc_html_e( 'Source', 'pronamic_ideal' ); ?>
433
		</th>
434
		<td>
435
			<?php
436
437
			echo $payment->get_source_text(); // WPCS: XSS ok.
438
439
			?>
440
		</td>
441
	</tr>
442
443
	<?php
444
445
	$ga_tracked = $payment->get_ga_tracked();
446
447
	$ga_property_id = get_option( 'pronamic_pay_google_analytics_property' );
448
449
	?>
450
451
	<?php if ( $ga_tracked || ! empty( $ga_property_id ) ) : ?>
452
453
		<tr>
454
			<th scope="row">
455
				<?php esc_html_e( 'Google Analytics', 'pronamic_ideal' ); ?>
456
			</th>
457
			<td>
458
				<?php
459
460
				if ( $ga_tracked ) :
461
462
					esc_html_e( 'Ecommerce conversion tracked', 'pronamic_ideal' );
463
464
				else :
465
466
					esc_html_e( 'Ecommerce conversion not tracked', 'pronamic_ideal' );
467
468
				endif;
469
470
				?>
471
			</td>
472
		</tr>
473
474
	<?php endif; ?>
475
476
	<?php if ( 's2member' === $payment->get_source() ) : ?>
477
478
		<tr>
479
			<th scope="row">
480
				<?php esc_html_e( 'Period', 'pronamic_ideal' ); ?>
481
			</th>
482
			<td>
483
				<?php echo esc_html( get_post_meta( $payment->get_id(), '_pronamic_payment_s2member_period', true ) ); ?>
484
			</td>
485
		</tr>
486
		<tr>
487
			<th scope="row">
488
				<?php esc_html_e( 'Level', 'pronamic_ideal' ); ?>
489
			</th>
490
			<td>
491
				<?php echo esc_html( get_post_meta( $payment->get_id(), '_pronamic_payment_s2member_level', true ) ); ?>
492
			</td>
493
		</tr>
494
495
	<?php endif; ?>
496
497
	<?php if ( 'wp-e-commerce' === $payment->get_source() ) : ?>
498
499
		<tr>
500
			<th scope="row">
501
				<?php esc_html_e( 'Purchase ID', 'pronamic_ideal' ); ?>
502
			</th>
503
			<td>
504
				<?php echo esc_html( get_post_meta( $payment->get_id(), '_pronamic_payment_wpsc_purchase_id', true ) ); ?>
505
			</td>
506
		</tr>
507
		<tr>
508
			<th scope="row">
509
				<?php esc_html_e( 'Session ID', 'pronamic_ideal' ); ?>
510
			</th>
511
			<td>
512
				<?php echo esc_html( get_post_meta( $payment->get_id(), '_pronamic_payment_wpsc_session_id', true ) ); ?>
513
			</td>
514
		</tr>
515
516
	<?php endif; ?>
517
518
	<?php if ( 'membership' === $payment->get_source() ) : ?>
519
520
		<tr>
521
			<th scope="row">
522
				<?php esc_html_e( 'User ID', 'pronamic_ideal' ); ?>
523
			</th>
524
			<td>
525
				<?php echo esc_html( get_post_meta( $payment->get_id(), '_pronamic_payment_membership_user_id', true ) ); ?>
526
			</td>
527
		</tr>
528
		<tr>
529
			<th scope="row">
530
				<?php esc_html_e( 'Subscription ID', 'pronamic_ideal' ); ?>
531
			</th>
532
			<td>
533
				<?php echo esc_html( get_post_meta( $payment->get_id(), '_pronamic_payment_membership_subscription_id', true ) ); ?>
534
			</td>
535
		</tr>
536
537
	<?php endif; ?>
538
539
	<?php if ( PRONAMIC_PAY_DEBUG ) : ?>
540
541
		<tr>
542
			<th scope="row">
543
				<?php esc_html_e( 'User Agent', 'pronamic_ideal' ); ?>
544
			</th>
545
			<td>
546
				<?php echo esc_html( $payment->user_agent ); ?>
547
			</td>
548
		</tr>
549
		<tr>
550
			<th scope="row">
551
				<?php esc_html_e( 'IP Address', 'pronamic_ideal' ); ?>
552
			</th>
553
			<td>
554
				<?php echo esc_html( $payment->user_ip ); ?>
555
			</td>
556
		</tr>
557
558
		<?php if ( null !== $payment->get_version() ) : ?>
559
560
			<tr>
561
				<th scope="row">
562
					<?php esc_html_e( 'Version', 'pronamic_ideal' ); ?>
563
				</th>
564
				<td>
565
					<?php echo esc_html( $payment->get_version() ); ?>
566
				</td>
567
			</tr>
568
569
		<?php endif ?>
570
571
		<?php if ( null !== $payment->get_mode() ) : ?>
572
573
			<tr>
574
				<th scope="row">
575
					<?php esc_html_e( 'Mode', 'pronamic_ideal' ); ?>
576
				</th>
577
				<td>
578
					<?php
579
580
					switch ( $payment->get_mode() ) {
581
						case 'live':
582
							esc_html_e( 'Live', 'pronamic_ideal' );
583
584
							break;
585
						case 'test':
586
							esc_html_e( 'Test', 'pronamic_ideal' );
587
588
							break;
589
						default:
590
							echo esc_html( $payment->get_mode() );
591
592
							break;
593
					}
594
595
					?>
596
				</td>
597
			</tr>
598
599
		<?php endif ?>
600
601
	<?php endif; ?>
602
</table>
603