-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fe1713
commit 8836269
Showing
4 changed files
with
35 additions
and
40 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"use server" | ||
import { getServerSession } from "next-auth"; | ||
import { authOptions } from "../auth"; | ||
import prisma from "@repo/db/client"; | ||
|
||
export async function createOnRampTransactions({amount, provider}:{amount:number, provider:string}) { | ||
const session = await getServerSession(authOptions); | ||
const userId = session.user?.id; | ||
const token = Math.random().toString(36).substring(7); | ||
if (!userId) { | ||
throw new Error("User not logged in"); | ||
} | ||
const transaction = await prisma.onRampTransaction.create({ | ||
data: { | ||
userId: Number(userId), | ||
startTime: new Date(), | ||
token:token, | ||
status:"Processing", | ||
amount: amount * 100, | ||
provider:provider | ||
} | ||
}) | ||
return { | ||
message: "Transaction initiated", | ||
transaction | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters