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:
@@ -860,9 +860,9 @@ function showPaymentModal(option) {
|
||||
<label style="display: block; margin-bottom: 5px; color: #333; font-weight: 500;">Payment Method *</label>
|
||||
<select name="payment_method" required style="width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px;">
|
||||
<option value="">Select payment method</option>
|
||||
<option value="credit_card">Credit Card</option>
|
||||
<option value="paypal">PayPal</option>
|
||||
<option value="bank_transfer">Bank Transfer</option>
|
||||
${typeof MOLLIE_ENABLED !== 'undefined' && MOLLIE_ENABLED ? '<option value="credit_card">Credit Card</option>' : ''}
|
||||
${typeof PAYPAL_ENABLED !== 'undefined' && PAYPAL_ENABLED ? '<option value="paypal">PayPal</option>' : ''}
|
||||
${typeof PAY_ON_DELIVERY_ENABLED !== 'undefined' && PAY_ON_DELIVERY_ENABLED ? '<option value="bank_transfer">Bank Transfer</option>' : ''}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -906,6 +906,16 @@ function showPaymentModal(option) {
|
||||
document.getElementById("paymentForm").onsubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(e.target);
|
||||
const paymentMethod = formData.get("payment_method");
|
||||
|
||||
// Auto-determine payment provider based on payment method
|
||||
let paymentProvider = 'mollie'; // default
|
||||
if (paymentMethod === 'paypal') {
|
||||
paymentProvider = 'paypal';
|
||||
} else if (paymentMethod === 'credit_card' || paymentMethod === 'bank_transfer') {
|
||||
paymentProvider = 'mollie';
|
||||
}
|
||||
|
||||
const paymentData = {
|
||||
name: formData.get("name"),
|
||||
email: formData.get("email"),
|
||||
@@ -913,7 +923,8 @@ function showPaymentModal(option) {
|
||||
city: formData.get("city"),
|
||||
postal: formData.get("postal"),
|
||||
country: formData.get("country"),
|
||||
payment_method: formData.get("payment_method"),
|
||||
payment_method: paymentMethod,
|
||||
payment_provider: paymentProvider,
|
||||
version_id: option.version_id,
|
||||
price: price,
|
||||
currency: currency
|
||||
@@ -1010,7 +1021,9 @@ async function processPayment(paymentData, option, modal) {
|
||||
const paymentRequest = {
|
||||
serial_number: deviceSerialNumber,
|
||||
version_id: option.version_id,
|
||||
user_data: paymentData // name, email, address only
|
||||
payment_method: paymentData.payment_method,
|
||||
payment_provider: paymentData.payment_provider,
|
||||
user_data: paymentData // name, email, address, etc.
|
||||
};
|
||||
|
||||
// Debug logging
|
||||
@@ -1018,13 +1031,15 @@ async function processPayment(paymentData, option, modal) {
|
||||
console.log("=== DEBUG: Payment Request ===");
|
||||
console.log("Serial Number:", deviceSerialNumber);
|
||||
console.log("Version ID:", option.version_id);
|
||||
console.log("Payment Method:", paymentData.payment_method);
|
||||
console.log("Payment Provider:", paymentData.payment_provider);
|
||||
console.log("User Data:", paymentData);
|
||||
console.log("Request payload:", paymentRequest);
|
||||
}
|
||||
|
||||
await logCommunication(`Payment initiated for version ${option.version_id}`, 'sent');
|
||||
await logCommunication(`Payment initiated for version ${option.version_id} via ${paymentData.payment_provider}`, 'sent');
|
||||
|
||||
// Call payment API to create Mollie payment
|
||||
// Call payment API (handles both Mollie and PayPal)
|
||||
const response = await fetch(link + "/v2/payment", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
@@ -1052,16 +1067,16 @@ async function processPayment(paymentData, option, modal) {
|
||||
}
|
||||
|
||||
if (result.checkout_url) {
|
||||
await logCommunication(`Redirecting to Mollie payment: ${result.payment_id}`, 'sent');
|
||||
await logCommunication(`Redirecting to ${paymentData.payment_provider} payment: ${result.payment_id}`, 'sent');
|
||||
|
||||
if (typeof DEBUG !== 'undefined' && DEBUG) {
|
||||
console.log("DEBUG: Redirecting to Mollie checkout...");
|
||||
console.log(`DEBUG: Redirecting to ${paymentData.payment_provider} checkout...`);
|
||||
}
|
||||
|
||||
// Close modal before redirect
|
||||
document.body.removeChild(modal);
|
||||
|
||||
// Redirect to Mollie checkout page
|
||||
// Redirect to payment checkout page
|
||||
window.location.href = result.checkout_url;
|
||||
} else {
|
||||
throw new Error(result.error || "No checkout URL received");
|
||||
|
||||
Reference in New Issue
Block a user