- Implemented the software tool page with user interface for connecting devices. - Added functionality to display connection status and software upgrade options. - Included a help modal with step-by-step instructions for users. - Integrated error handling and user permission checks. - Enhanced user experience with dynamic content updates and visual feedback.
3.5 KiB
Payment Integration Implementation Summary
Overview
Complete payment integration for software upgrades using existing ecommerce infrastructure (transaction API, invoice API, PHPMailer, DomPDF).
New Files to Create
1. /webhook_mollie.php (Root directory)
Purpose: Mollie webhook handler specifically for software upgrades Based on: Existing webhook.php from commerce product Key features:
- ✅ Uses
/v2/transactions/API for status updates (consistent with commerce) - ✅ Uses
/v2/invoice/API for invoice generation - ✅ Creates PDF invoice with DomPDF
- ✅ Sends email via PHPMailer
- ✅ Creates software license
- ✅ Multi-language support
- ✅ Sends to bookkeeping if configured
Webhook URL: https://yourdomain.com/webhook_mollie.php
2. /api/v2/post/payment.php
Purpose: Create Mollie payment for software upgrade Input: serial_number, version_id, user_data Output: {checkout_url, payment_id} Security: Server-side price calculation
3. /api/v2/get/payment.php
Purpose: Retrieve payment status Input: ?payment_id=xxx Output: {payment_id, payment_status, serial_number, equipment_id, ...}
Modified Files
1. /assets/functions.php
Add new functions:
generateUniqueLicenseKey()- Generate unique license keysgenerateSoftwareInvoice($invoice_data, $order_id, $language)- Generate HTML invoice for software upgrades- Based on existing
generateInvoice()function - Custom template for software licenses
- Shows: Device serial number, software version, license key, expiry date
- Returns: [$html_content, $customer_email, $order_id]
- Based on existing
2. /assets/softwaretool.js
Modify:
processPayment()- Call/v2/post/paymentAPIdownloadAndInstallSoftware()- Add serial number verification
3. /softwaretool.php
Add: Payment return detection (?payment_id=xxx)
Database
No changes needed - Uses existing:
transactionstable (txn_id, payment_status, payment_amount, etc.)transactions_itemstable (item_id, item_options with JSON)
Payment Status Codes (Matching Commerce System)
0= Pending1= Paid101= Open/Pending (Mollie)102= Failed103= Expired999= Canceled
Implementation Order
- ✅ Add Mollie constants to config.php
- Create helper functions in functions.php:
generateUniqueLicenseKey()generateSoftwareInvoice()
- Create
/api/v2/post/payment.php - Create
/api/v2/get/payment.php - Create
/webhook_mollie.php - Modify frontend JavaScript
- Modify softwaretool.php
- Test in DEBUG mode
- Test with Mollie sandbox
- Deploy to production
Key Benefits
- Consistent with ecommerce - Uses same API structure
- Professional invoices - PDF generation + email delivery
- Complete audit trail - Transactions + invoices + licenses
- Multi-language - Invoice language based on customer country
- Bookkeeping integration - Auto-send to bookkeeping email
- Refund handling - Webhook detects refunds (TODO: disable license)
Invoice Email Template
The email will include:
- Subject: "Software Upgrade - Invoice: [ORDER_ID]"
- HTML body with invoice details
- PDF attachment (Invoice_[ORDER_ID].pdf)
- Sent to customer email + bookkeeping (if configured)
Invoice contains:
- Customer details (name, address, email)
- Order ID / Transaction ID
- Software upgrade details (version, device serial number)
- License key + expiry date (2099-12-31)
- Price breakdown
- Company information