Add Mollie payment integration: Implement lazy loading for PaymentSuccess page, update CartTab and OrderProcessingService to handle Mollie payment intents, and enhance ProfilePage to manage payment completion for both Stripe and Mollie. Update base URL for development environment.

This commit is contained in:
sebseb7
2025-07-15 12:13:57 +02:00
parent 9072a3c977
commit 5157b7d781
6 changed files with 325 additions and 31 deletions

View File

@@ -377,34 +377,23 @@ class CartTab extends Component {
(total, item) => total + item.price * item.quantity,
0
);
const totalAmount = Math.round((subtotal + deliveryCost) * 100); // Convert to cents
const totalAmount = Math.round((subtotal + deliveryCost) * 100) / 100;
if (this.context && this.context.socket && this.context.socket.connected) {
this.context.socket.emit(
"createMollieIntent",
{ amount: totalAmount, invoiceId: 'A-34344' },
(response) => {
if (response.success) {
localStorage.setItem('pendingPayment', JSON.stringify({
paymentId: response.paymentId,
amount: totalAmount,
timestamp: Date.now()
}));
window.location.href = response.checkoutUrl;
} else {
console.error("Error:", response.error);
}
}
);
} else {
console.error("Socket context not available");
this.setState({
isCompletingOrder: false,
completionError: "Cannot connect to server. Please try again later.",
});
}
// Prepare complete order data for Mollie intent creation
const mollieOrderData = {
amount: totalAmount,
items: cartItems,
invoiceAddress,
deliveryAddress: useSameAddress ? invoiceAddress : deliveryAddress,
deliveryMethod,
paymentMethod: "mollie",
deliveryCost,
note,
domain: window.location.origin,
saveAddressForFuture,
};
this.orderService.createMollieIntent(mollieOrderData);
return;
}