38 lines
1.3 KiB
Plaintext
38 lines
1.3 KiB
Plaintext
// Error handler for failed payment intent creation
|
|
// This script is triggered when a payment intent creation fails
|
|
|
|
print("❌ Payment Intent Creation Failed!");
|
|
print("==================================");
|
|
|
|
// The error data is available as 'parsed_error'
|
|
if parsed_error != () {
|
|
print(`Error: ${parsed_error}`);
|
|
|
|
// You can handle different types of errors
|
|
if parsed_error.contains("authentication") {
|
|
print("🔑 Authentication error - check API key");
|
|
// eval_file("flows/handle_auth_error.rhai");
|
|
} else if parsed_error.contains("insufficient_funds") {
|
|
print("💰 Insufficient funds error");
|
|
// eval_file("flows/handle_insufficient_funds.rhai");
|
|
} else if parsed_error.contains("card_declined") {
|
|
print("💳 Card declined error");
|
|
// eval_file("flows/handle_card_declined.rhai");
|
|
} else {
|
|
print("⚠️ General payment error");
|
|
// eval_file("flows/handle_general_payment_error.rhai");
|
|
}
|
|
|
|
// Log the error for monitoring
|
|
print("📊 Logging error for analytics...");
|
|
// eval_file("flows/log_payment_error.rhai");
|
|
|
|
// Notify relevant parties
|
|
print("📧 Sending error notifications...");
|
|
// eval_file("flows/send_error_notification.rhai");
|
|
|
|
} else {
|
|
print("⚠️ No error data received");
|
|
}
|
|
|
|
print("🔄 Error handling complete!"); |