Fix email system and implement OTP confirmation flow
Email System Fixes: - Fix email sending after payment: handle-order-paid now calls send-notification instead of send-email-v2 directly, properly processing template variables - Fix order_created email timing: sent immediately after order creation, before payment QR code generation - Update email templates to use short order ID (8 chars) instead of full UUID - Add working "Akses Sekarang" buttons to payment_success and access_granted emails - Add platform_url column to platform_settings for email links OTP Verification Flow: - Create dedicated /confirm-otp page for users who close registration modal - Add link in checkout modal and email to dedicated OTP page - Update OTP email template with better copywriting and dedicated page link - Fix send-auth-otp to fetch platform settings for dynamic brand_name and platform_url - Auto-login users after OTP verification in checkout flow Admin Features: - Add delete user functionality with cascade deletion of all related data - Update IntegrasiTab to read/write email settings from platform_settings only - Add test email template for email configuration testing Cleanup: - Remove obsolete send-consultation-reminder and send-test-email functions - Update send-email-v2 to read email config from platform_settings - Remove footer links (Ubah Preferensi/Unsubscribe) from email templates 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -309,18 +309,30 @@ async function sendNotification(
|
||||
return;
|
||||
}
|
||||
|
||||
// Send email via Mailketing
|
||||
await fetch(`${Deno.env.get("SUPABASE_URL")}/functions/v1/send-email-v2`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${Deno.env.get("SUPABASE_ANON_KEY")}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
to: data.email,
|
||||
subject: template.email_subject,
|
||||
html: template.email_body_html,
|
||||
shortcodeData: data,
|
||||
}),
|
||||
});
|
||||
// Send email via send-notification (which will process shortcodes and call send-email-v2)
|
||||
try {
|
||||
const notificationResponse = await fetch(`${Deno.env.get("SUPABASE_URL")}/functions/v1/send-notification`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
template_key: templateKey,
|
||||
recipient_email: data.email,
|
||||
recipient_name: data.user_name || data.nama,
|
||||
variables: data,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!notificationResponse.ok) {
|
||||
const errorText = await notificationResponse.text();
|
||||
console.error("[HANDLE-PAID] Notification send failed:", notificationResponse.status, errorText);
|
||||
} else {
|
||||
const result = await notificationResponse.json();
|
||||
console.log("[HANDLE-PAID] Notification sent successfully for template:", templateKey, result);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[HANDLE-PAID] Exception sending notification:", error);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user