Add PayPal webhook handler and marketing styles

- Implemented PayPal webhook for handling payment notifications, including signature verification and transaction updates.
- Created invoice generation and license management for software upgrades upon successful payment.
- Added comprehensive logging for debugging purposes.
- Introduced new CSS styles for the marketing file management system, including layout, toolbar, breadcrumb navigation, search filters, and file management UI components.
This commit is contained in:
“VeLiTi”
2026-01-09 15:19:28 +01:00
parent 08263c7933
commit 2520fb2b75
38 changed files with 4166 additions and 1107 deletions

View File

@@ -216,10 +216,8 @@ try {
date('Y-m-d H:i:s')
]);
$invoice_id = $pdo->lastInsertId();
debuglog("WEBHOOK: Invoice created with ID: $invoice_id");
} else {
$invoice_id = $existing_invoice['id'];
debuglog("WEBHOOK: Invoice already exists with ID: $invoice_id");
}
// Fetch full invoice data with customer details for email
@@ -238,13 +236,9 @@ try {
$stmt->execute([$invoice_id]);
$invoice_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
debuglog("WEBHOOK: Invoice data fetched: " . print_r($invoice_data, true));
if (!empty($invoice_data)) {
debuglog("WEBHOOK: Transforming invoice data...");
// Transform the data (group items like the API does)
$invoice_cust = transformOrderData($invoice_data);
debuglog("WEBHOOK: Transformed invoice data: " . print_r($invoice_cust, true));
// Determine invoice language
if (!empty($invoice_cust['customer']['language'])) {
@@ -256,35 +250,22 @@ try {
}
// Generate invoice HTML (using custom template for software upgrades)
debuglog("WEBHOOK: Calling generateSoftwareInvoice with language: $invoice_language");
list($data,$customer_email,$order_id) = generateSoftwareInvoice($invoice_cust,$orderId,$invoice_language);
debuglog("WEBHOOK: Invoice generated - Customer email: $customer_email, Order ID: $order_id");
debuglog("WEBHOOK: Invoice HTML length: " . strlen($data));
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
//CREATE PDF using DomPDF
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
debuglog("WEBHOOK: Creating PDF...");
$dompdf->loadHtml($data);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$subject = 'Software Upgrade - Invoice: '.$order_id;
$attachment = $dompdf->output();
debuglog("WEBHOOK: PDF created, size: " . strlen($attachment) . " bytes");
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
//Send email via PHPMailer
//+++++++++++++++++++++++++++++++++++++++++++++++++++++
debuglog("WEBHOOK: Attempting to send email to: $customer_email");
debuglog("WEBHOOK: Email subject: $subject");
debuglog("WEBHOOK: Email config - Host: " . (defined('email_host_name') ? email_host_name : 'NOT DEFINED'));
debuglog("WEBHOOK: Email config - Port: " . (defined('email_outgoing_port') ? email_outgoing_port : 'NOT DEFINED'));
debuglog("WEBHOOK: Email config - Security: " . (defined('email_outgoing_security') ? email_outgoing_security : 'NOT DEFINED'));
debuglog("WEBHOOK: Email config - Username: " . (defined('email') ? email : 'NOT DEFINED'));
// The send_mail function will exit on error and debuglog the error
$mail_result = send_mail($customer_email, $subject, $data, $attachment, $subject);
debuglog("WEBHOOK: Email sent successfully to: $customer_email");
// Send to bookkeeping if configured
if(invoice_bookkeeping){