move rhailib to herolib

This commit is contained in:
Timur Gordon
2025-08-21 14:32:24 +02:00
parent aab2b6f128
commit aa0248ef17
121 changed files with 16412 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
// 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!");

View File

@@ -0,0 +1,34 @@
// Response handler for successful payment intent creation
// This script is triggered when a payment intent is successfully created
print("✅ Payment Intent Created Successfully!");
print("=====================================");
// The response data is available as 'parsed_data'
if parsed_data != () {
print(`Payment Intent ID: ${parsed_data.id}`);
print(`Amount: ${parsed_data.amount}`);
print(`Currency: ${parsed_data.currency}`);
print(`Status: ${parsed_data.status}`);
if parsed_data.client_secret != () {
print(`Client Secret: ${parsed_data.client_secret}`);
}
// You can now trigger additional workflows
print("🔄 Triggering next steps...");
// Example: Send confirmation email
// eval_file("flows/send_payment_confirmation_email.rhai");
// Example: Update user account
// eval_file("flows/update_user_payment_status.rhai");
// Example: Log analytics event
// eval_file("flows/log_payment_analytics.rhai");
} else {
print("⚠️ No response data received");
}
print("🎉 Payment intent response processing complete!");