Apply patch [skip ci]
This commit is contained in:
parent
8d38a5eb74
commit
b6af1c4e5b
@ -73,21 +73,39 @@ export const handler = define.handlers({
|
|||||||
const payment_method_id = formData.get("payment_method_id") as string;
|
const payment_method_id = formData.get("payment_method_id") as string;
|
||||||
const lease_id = formData.get("lease_id") as string;
|
const lease_id = formData.get("lease_id") as string;
|
||||||
|
|
||||||
// TODO: Implement actual payment processing with Stripe or similar
|
// Call the payment intent creation endpoint
|
||||||
// For now, simulate successful payment
|
const intentResponse = await fetch("/api/payments/create_intent", {
|
||||||
if (isE2EEnabled()) {
|
method: "POST",
|
||||||
await createPaymentTransaction(
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({
|
||||||
lease_id,
|
lease_id,
|
||||||
amount,
|
amount,
|
||||||
getE2ENow(),
|
payment_method: "ach",
|
||||||
"ach",
|
}),
|
||||||
"completed",
|
});
|
||||||
);
|
|
||||||
|
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("", {
|
return new Response("", {
|
||||||
status: 302,
|
status: 302,
|
||||||
headers: { Location: "/tenant/rent/confirmation?success=true" },
|
headers: { Location: redirectUrl.toString() },
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error processing payment:", error);
|
console.error("Error processing payment:", error);
|
||||||
@ -348,3 +366,4 @@ export default define.page(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user