PluginProbe
Easy Invoice – Invoice Generator, PDF Quotes & Payments / 2.4.2
Easy Invoice – Invoice Generator, PDF Quotes & Payments v2.4.2
2.4.3 2.4.4 2.4.2 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 All 60 releases
← All changes | includes/Services/EmailManager.php +39 -8 2.4.0 → 2.4.2 View file →
@@ -114,9 +114,9 @@
114 114 // A client has submitted a manual payment (bank transfer, cheque,
115 115 // cash, with or without proof) that now waits for verification. The
116 116 // only listener used to live in an admin class nothing instantiates,
117 117 // so the admin was never told.
118 - add_action('easy_invoice_manual_payment_submitted', [$this, 'handleManualPaymentSubmitted'], 10, 2);
118 + add_action('easy_invoice_manual_payment_submitted', [$this, 'handleManualPaymentSubmitted'], 10, 3);
119 119 }
120 120
121 121 /**
122 122 * Load email settings
@@ -1685,9 +1685,9 @@
1685 1685 *
1686 1686 * @param int $invoice_id The invoice paid.
1687 1687 * @param string $payment_method Gateway or payment type submitted.
1688 1688 */
1689 - public function handleManualPaymentSubmitted($invoice_id, $payment_method = 'manual'): void {
1689 + public function handleManualPaymentSubmitted($invoice_id, $payment_method = 'manual', $payment_id = 0): void {
1690 1690 $post = get_post((int) $invoice_id);
1691 1691 if (!$post) {
1692 1692 return;
1693 1693 }
@@ -1694,15 +1694,26 @@
1694 1694 $invoice = new Invoice($post);
1695 1695 if (!$invoice->getId()) {
1696 1696 return;
1697 1697 }
1698 + $payment_id = (int) $payment_id;
1698 1699 $payment_data = [
1699 1700 'payment_method' => (string) $payment_method,
1700 - 'pending' => true,
1701 + 'pending' => true,
1702 + 'payment_id' => $payment_id,
1701 1703 ];
1702 - $notes = get_post_meta($invoice->getId(), '_manual_payment_notes', true);
1703 - if ($notes) {
1704 - $payment_data['notes'] = $notes;
1704 + if ($payment_id) {
1705 + $payment_data['amount'] = (float) get_post_meta($payment_id, '_amount', true);
1706 + $payment_data['notes'] = (string) get_post_meta($payment_id, '_notes', true);
1707 + $payment_data['reference'] = (string) get_post_meta($payment_id, \EasyInvoice\Services\OfflinePayments::META_REFERENCE, true);
1708 + if (\EasyInvoice\Services\OfflinePayments::hasProof($payment_id)) {
1709 + $payment_data['proof_url'] = \EasyInvoice\Services\OfflinePayments::proofUrl($payment_id);
1710 + }
1711 + } else {
1712 + $notes = get_post_meta($invoice->getId(), '_manual_payment_notes', true);
1713 + if ($notes) {
1714 + $payment_data['notes'] = $notes;
1715 + }
1705 1716 }
1706 1717 $this->sendAdminPaymentNotification($invoice, $payment_data);
1707 1718 }
1708 1719
@@ -1898,13 +1909,30 @@
1898 1909 $message .= "\n";
1899 1910 /* translators: %s: transaction id. */
1900 1911 $message .= sprintf(__('- Transaction ID: %s', 'easy-invoice'), $payment_data['transaction_id']);
1901 1912 }
1913 + if (!empty($payment_data['reference'])) {
1914 + $message .= "\n";
1915 + /* translators: %s: reference the client typed. */
1916 + $message .= sprintf(__('- Reference given by the client: %s', 'easy-invoice'), $payment_data['reference']);
1917 + }
1918 + if (!empty($payment_data['proof_url'])) {
1919 + $message .= "\n";
1920 + /* translators: %s: link. */
1921 + $message .= sprintf(__('- Receipt attached: %s', 'easy-invoice'), $payment_data['proof_url']);
1922 + } elseif ($pending) {
1923 + $message .= "\n";
1924 + $message .= __('- No receipt was attached.', 'easy-invoice');
1925 + }
1902 1926
1903 1927 $message .= "\n\n";
1904 - $message .= __('Please review this payment in the admin dashboard:', 'easy-invoice');
1928 + $message .= $pending
1929 + ? __('Confirm or reject it on the Payments screen:', 'easy-invoice')
1930 + : __('Please review this payment in the admin dashboard:', 'easy-invoice');
1905 1931 $message .= "\n";
1906 - $message .= admin_url('admin.php?page=easy-invoice-payments&action=verify&invoice_id=' . $invoice_id);
1932 + $message .= !empty($payment_data['payment_id'])
1933 + ? admin_url('admin.php?page=easy-invoice-payments&action=view&id=' . (int) $payment_data['payment_id'])
1934 + : admin_url('admin.php?page=easy-invoice-payments&status=pending');
1907 1935 $message .= "\n\n";
1908 1936 $message .= __('This is an automated message from Easy Invoice.', 'easy-invoice');
1909 1937
1910 1938 return $message;
@@ -2128,8 +2156,11 @@
2128 2156 * @param string $method Payment method
2129 2157 * @return string Payment method label
2130 2158 */
2131 2159 private function getPaymentMethodLabel(string $method): string {
2160 + if (class_exists('\\EasyInvoice\\Services\\OfflinePayments') && \EasyInvoice\Services\OfflinePayments::isOffline($method)) {
2161 + return \EasyInvoice\Services\OfflinePayments::label($method);
2162 + }
2132 2163 $labels = [
2133 2164 'bank' => __('Bank Transfer', 'easy-invoice'),
2134 2165 'bank_transfer' => __('Bank Transfer', 'easy-invoice'),
2135 2166 'cash' => __('Cash', 'easy-invoice'),