Update ExtraordinaryUser.tsx

This commit is contained in:
2025-12-12 19:15:00 +01:00
committed by GitHub
parent 0225518d9a
commit e2c66d63db

View File

@@ -60,7 +60,9 @@ export const ExtraordinaryUser: React.FC = () => {
const updatedDetails = await CondoService.getExpenseDetails(expenseId); const updatedDetails = await CondoService.getExpenseDetails(expenseId);
setSelectedExpense(updatedDetails); setSelectedExpense(updatedDetails);
} }
} catch(e) { alert("Errore registrazione pagamento"); } } catch(e: any) {
alert(`Errore registrazione pagamento: ${e.message || "Errore sconosciuto"}`);
}
}; };
const handleCardClick = async (expenseId: string) => { const handleCardClick = async (expenseId: string) => {
@@ -341,11 +343,19 @@ export const ExtraordinaryUser: React.FC = () => {
}] }]
}); });
}} }}
onApprove={(data, actions) => { onApprove={async (data, actions) => {
if(!actions.order) return Promise.resolve(); if(!actions.order) return;
return actions.order.capture().then(() => { try {
handlePaymentSuccess(selectedExpense.id, remaining); await actions.order.capture();
}); await handlePaymentSuccess(selectedExpense.id, remaining);
} catch (err) {
console.error("PayPal Capture Error", err);
alert("Errore durante il completamento del pagamento PayPal.");
}
}}
onError={(err) => {
console.error("PayPal Button Error", err);
alert("Errore caricamento PayPal: " + err.toString());
}} }}
/> />
</PayPalScriptProvider> </PayPalScriptProvider>