Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
60e4dedb1b
commit
ef5bf529c8
@@ -124,8 +124,9 @@ export const createPaymentRequest = createServerFn({ method: "POST" })
|
||||
export const refreshPaymentStatus = createServerFn({ method: "POST" })
|
||||
.middleware([attachSupabaseAuth, requireSupabaseAuth])
|
||||
.inputValidator((data: { id: string }) => data)
|
||||
.handler(async ({ data }) => {
|
||||
const { data: row } = await supabaseAdmin
|
||||
.handler(async ({ data, context }) => {
|
||||
const { supabase } = context;
|
||||
const { data: row } = await supabase
|
||||
.from("payment_requests")
|
||||
.select("*")
|
||||
.eq("id", data.id)
|
||||
@@ -135,7 +136,7 @@ export const refreshPaymentStatus = createServerFn({ method: "POST" })
|
||||
const stripe = getStripe();
|
||||
const session = await stripe.checkout.sessions.retrieve(row.stripe_session_id);
|
||||
if (session.payment_status === "paid") {
|
||||
await supabaseAdmin
|
||||
await supabase
|
||||
.from("payment_requests")
|
||||
.update({
|
||||
status: "paid",
|
||||
@@ -152,8 +153,8 @@ export const refreshPaymentStatus = createServerFn({ method: "POST" })
|
||||
export const markPaymentEmailSent = createServerFn({ method: "POST" })
|
||||
.middleware([attachSupabaseAuth, requireSupabaseAuth])
|
||||
.inputValidator((data: { id: string }) => data)
|
||||
.handler(async ({ data }) => {
|
||||
await supabaseAdmin
|
||||
.handler(async ({ data, context }) => {
|
||||
await context.supabase
|
||||
.from("payment_requests")
|
||||
.update({ email_sent_at: new Date().toISOString() })
|
||||
.eq("id", data.id);
|
||||
@@ -163,8 +164,8 @@ export const markPaymentEmailSent = createServerFn({ method: "POST" })
|
||||
export const cancelPaymentRequest = createServerFn({ method: "POST" })
|
||||
.middleware([attachSupabaseAuth, requireSupabaseAuth])
|
||||
.inputValidator((data: { id: string }) => data)
|
||||
.handler(async ({ data }) => {
|
||||
await supabaseAdmin
|
||||
.handler(async ({ data, context }) => {
|
||||
await context.supabase
|
||||
.from("payment_requests")
|
||||
.update({ status: "canceled" })
|
||||
.eq("id", data.id);
|
||||
|
||||
Reference in New Issue
Block a user