Apply patch [skip ci]

This commit is contained in:
open-swe-dev-andrinoid[bot] 2026-01-21 23:03:28 +00:00
parent 8d38a5eb74
commit b6af1c4e5b

View File

@ -73,21 +73,39 @@ export const handler = define.handlers({
const payment_method_id = formData.get("payment_method_id") as string;
const lease_id = formData.get("lease_id") as string;
// TODO: Implement actual payment processing with Stripe or similar
// For now, simulate successful payment
if (isE2EEnabled()) {
await createPaymentTransaction(
// Call the payment intent creation endpoint
const intentResponse = await fetch("/api/payments/create_intent", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
lease_id,
amount,
getE2ENow(),
"ach",
"completed",
);
payment_method: "ach",
}),
});
const intentData = await intentResponse.json();
if (!intentData.success) {
console.error("Payment intent creation failed:", intentData.error);
return page({
error: intentData.error || "Failed to create payment intent. Please try again.",
});
}
// Redirect to confirmation page with payment details
const redirectUrl = new URL("/tenant/rent/confirmation", ctx.req.url);
redirectUrl.searchParams.set("success", "true");
redirectUrl.searchParams.set("amount", String(amount));
if (intentData.mode === "stripe") {
redirectUrl.searchParams.set("payment_intent_id", intentData.payment_intent_id);
redirectUrl.searchParams.set("client_secret", intentData.client_secret);
}
return new Response("", {
status: 302,
headers: { Location: "/tenant/rent/confirmation?success=true" },
headers: { Location: redirectUrl.toString() },
});
} catch (error) {
console.error("Error processing payment:", error);
@ -348,3 +366,4 @@ export default define.page(
},
);