PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.0
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.0
2.4.0 2.4.1 2.3.8 2.3.7 2.3.6 2.3.5 2.3.4 2.3.3 2.3.2 2.3.1 2.2.0 2.1.21 2.1.20 2.1.19 2.1.18 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.2 All 57 releases
easy-invoice / templates / payments / view.php

view.php in Easy Invoice – Invoice Generator, PDF Quotes & Payments 2.4.0, at templates/payments/view.php

198 lines 10.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Payment View Template
4 *
5 * @package Easy_Invoice
6 */
7
8 namespace EasyInvoice\Templates\Payments;
9
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14 use EasyInvoice\Models\Payment;
15 use EasyInvoice\Models\Invoice;
16
17 if (!isset($payment) || !($payment instanceof Payment)) {
18 wp_die(esc_html__('Invalid payment', 'easy-invoice'));
19 }
20
21 $invoice_post = get_post($payment->getInvoiceId());
22 $invoice = $invoice_post ? new Invoice($invoice_post) : null;
23
24
25 ?>
26
27 <div class="p-8">
28 <div class="flex justify-between items-center mb-6">
29 <h1 class="text-2xl font-bold text-gray-900">
30 <?php /* translators: %s: payment id. */ printf(esc_html__('Payment #%s', 'easy-invoice'), (int) $payment->getId()); ?>
31 </h1>
32 <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice-payments')); ?>"
33 class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
34 <?php esc_html_e('Back to Payments', 'easy-invoice'); ?>
35 </a>
36 </div>
37
38 <div class="bg-white shadow overflow-hidden sm:rounded-lg">
39 <div class="px-4 py-5 sm:px-6 border-b border-gray-200">
40 <h2 class="text-lg font-medium text-gray-900"><?php esc_html_e('Payment Information', 'easy-invoice'); ?></h2>
41 </div>
42 <div class="border-t border-gray-200">
43 <dl>
44 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
45 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Payment ID', 'easy-invoice'); ?></dt>
46 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">#<?php echo (int) $payment->getId(); ?></dd>
47 </div>
48 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
49 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Invoice', 'easy-invoice'); ?></dt>
50 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
51 <?php if ($invoice): ?>
52 <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice&action=edit&id=' . $invoice->getId())); ?>"
53 class="text-indigo-600 hover:text-indigo-900">
54 <?php echo esc_html($invoice->getNumber()); ?>
55 </a>
56 <?php else: ?>
57 <span class="text-gray-400"><?php esc_html_e('Invoice not found', 'easy-invoice'); ?></span>
58 <?php endif; ?>
59 </dd>
60 </div>
61 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
62 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Amount', 'easy-invoice'); ?></dt>
63 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
64 <?php echo esc_html($payment->getCurrencySymbol() . number_format((float) $payment->getAmount(), 2)); ?>
65 </dd>
66 </div>
67 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
68 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Payment Method', 'easy-invoice'); ?></dt>
69 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
70 <?php
71 $payment_method = $payment->getPaymentMethod();
72 if (empty($payment_method)) {
73 // Try direct property access
74 $payment_method = $payment->payment_method;
75 }
76 if (empty($payment_method)) {
77 // Try direct meta access
78 $payment_method = get_post_meta($payment->getId(), '_payment_method', true);
79 }
80
81
82
83 echo esc_html(ucfirst($payment_method ?: __('Not specified', 'easy-invoice')));
84 ?>
85 </dd>
86 </div>
87 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
88 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Status', 'easy-invoice'); ?></dt>
89 <dd class="mt-1 text-sm sm:mt-0 sm:col-span-2">
90 <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full
91 <?php
92 switch ($payment->getStatus()) {
93 case 'completed':
94 echo 'bg-green-100 text-green-800';
95 break;
96 case 'pending':
97 echo 'bg-yellow-100 text-yellow-800';
98 break;
99 case 'failed':
100 echo 'bg-red-100 text-red-800';
101 break;
102 default:
103 echo 'bg-gray-100 text-gray-800';
104 }
105 ?>">
106 <?php echo esc_html(ucfirst($payment->getStatus())); ?>
107 </span>
108 </dd>
109 </div>
110 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
111 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Date', 'easy-invoice'); ?></dt>
112 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
113 <?php echo esc_html(date_i18n(get_option('date_format'), strtotime($payment->getPaymentDate()))); ?>
114 </dd>
115 </div>
116 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
117 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Type', 'easy-invoice'); ?></dt>
118 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
119 <?php echo esc_html(ucfirst($payment->getPaymentType())); ?>
120 </dd>
121 </div>
122 <?php if ($payment->getRecurringId()) : ?>
123 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
124 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Recurring ID', 'easy-invoice'); ?></dt>
125 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
126 <?php echo esc_html($payment->getRecurringId()); ?>
127 </dd>
128 </div>
129 <?php endif; ?>
130 <?php if ($payment->getParentPaymentId()) : ?>
131 <div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
132 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Parent Payment', 'easy-invoice'); ?></dt>
133 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
134 <a href="<?php echo esc_url(admin_url('admin.php?page=easy-invoice-payments&action=view&id=' . $payment->getParentPaymentId())); ?>"
135 class="text-indigo-600 hover:text-indigo-900">
136 #<?php echo (int) $payment->getParentPaymentId(); ?>
137 </a>
138 </dd>
139 </div>
140 <?php endif; ?>
141 <?php if ($payment->getNotes()) : ?>
142 <div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
143 <dt class="text-sm font-medium text-gray-500"><?php esc_html_e('Notes', 'easy-invoice'); ?></dt>
144 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
145 <?php echo nl2br(esc_html($payment->getNotes())); ?>
146 </dd>
147 </div>
148 <?php endif; ?>
149 </dl>
150 </div>
151
152 <?php
153 $gateway_response_raw = $payment->getGatewayResponse();
154 $gateway_response = null;
155
156 if ($gateway_response_raw) {
157 // Try to decode JSON if it's a string
158 if (is_string($gateway_response_raw)) {
159 $gateway_response = json_decode($gateway_response_raw, true);
160 } elseif (is_array($gateway_response_raw)) {
161 $gateway_response = $gateway_response_raw;
162 }
163 }
164
165 if ($gateway_response && is_array($gateway_response)) :
166 ?>
167 <div class="px-4 py-5 sm:px-6 border-t border-gray-200">
168 <h2 class="text-lg font-medium text-gray-900"><?php esc_html_e('Gateway Response', 'easy-invoice'); ?></h2>
169 </div>
170 <div class="border-t border-gray-200">
171 <dl>
172 <?php
173 $loop = 0;
174 foreach ($gateway_response as $key => $value) :
175 $loop++;
176 ?>
177 <div class="<?php echo $loop % 2 === 0 ? 'bg-white' : 'bg-gray-50'; ?> px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
178 <dt class="text-sm font-medium text-gray-500"><?php echo esc_html(ucwords(str_replace('_', ' ', $key))); ?></dt>
179 <dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
180 <?php
181 if (is_array($value)) {
182 echo '<pre class="text-xs bg-gray-100 p-2 rounded overflow-x-auto">' . esc_html(json_encode($value, JSON_PRETTY_PRINT)) . '</pre>';
183 } elseif (is_bool($value)) {
184 echo $value ? 'Yes' : 'No';
185 } elseif (is_null($value)) {
186 echo '<em>null</em>';
187 } else {
188 echo esc_html($value);
189 }
190 ?>
191 </dd>
192 </div>
193 <?php endforeach; ?>
194 </dl>
195 </div>
196 <?php endif; ?>
197 </div>
198 </div>