Skip to content

Commit 121dc63

Browse files
committed
text: attempt to track dispute owed money
1 parent 3911e9e commit 121dc63

File tree

3 files changed

+1852
-1735
lines changed

3 files changed

+1852
-1735
lines changed

src/lib/server/stripe.server.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { STRIPE_KEY } from "$env/static/private"
1+
import { FIXER_API_KEY, STRIPE_KEY } from "$env/static/private"
22
import type { BundleSchema, NewScriptSchema, PriceSchema } from "$lib/client/schemas"
33
import type { Interval, Price, Scripter } from "$lib/types/collection"
44
import type { Database } from "$lib/types/supabase"
55
import type { SupabaseClient } from "@supabase/supabase-js"
66
import Stripe from "stripe"
77

8+
//@ts-ignore
9+
export const stripe = new Stripe(STRIPE_KEY, { apiVersion: "2025-08-27.basil", typescript: true })
810

911
export async function createCustomer(id: string, email: string, discord: string, username: string) {
1012
let customer: Stripe.Customer
@@ -141,22 +143,23 @@ export async function createAccount(
141143
return
142144
}
143145

144-
const { error: err } = await supabase
145-
.schema("profiles")
146-
.from("scripters")
147-
.update({ stripe: account.id })
148-
.eq("id", scripter.id)
146+
const promises = await Promise.all([
147+
supabase.schema("profiles").from("scripters").update({ stripe: account.id }).eq("id", scripter.id),
148+
supabase.schema("profiles").from("balances").update({ stripe: account.id }).eq("id", scripter.id)
149+
])
149150

150-
if (err) {
151-
console.error(err)
152-
return
151+
for (let i = 0; i < promises.length; i++) {
152+
if (promises[i].error) {
153+
console.error(promises[i].error)
154+
return
155+
}
153156
}
154157

155158
try {
156159
accountLink = await stripe.accountLinks.create({
157160
account: account.id,
158-
refresh_url: baseURL + "/api/stripe/connect/reauth",
159-
return_url: baseURL + "/api/stripe/connect/return",
161+
refresh_url: baseURL + "/dashboard/",
162+
return_url: baseURL + "/dashboard/",
160163
type: "account_onboarding"
161164
})
162165
} catch (err) {
@@ -350,3 +353,5 @@ export async function createScriptProduct(script: NewScriptSchema, name: string,
350353

351354
await Promise.all(stripePromises)
352355
}
356+
357+
export async function convertCurrency(from: string, to: string, amount: number) {}

0 commit comments

Comments
 (0)