Finish onramps
Course: PayTM Part-2 - chapter 2
Right now, we’re able to see the onramp transactions that have been seeded.
We don’t see any new ones though
Clicking on this button should initiate a new entry in the onRampTransactions table, that is eventually fulfilled by the bank-webhook module

Let’s implement this feature via a server action
- Create a new action in
lib/actions/createOnrampTransaction.ts
"use server";
import prisma from "@repo/db/client";import { getServerSession } from "next-auth";import { authOptions } from "../auth";
export async function createOnRampTransaction(provider: string, amount: number) { // Ideally the token should come from the banking provider (hdfc/axis) const session = await getServerSession(authOptions); if (!session?.user || !session.user?.id) { return { message: "Unauthenticated request" } } const token = (Math.random() * 1000).toString(); await prisma.onRampTransaction.create({ data: { provider, status: "Processing", startTime: new Date(), token: token, userId: Number(session?.user?.id), amount: amount * 100 } });
return { message: "Done" }}- Call the action when the button is pressed (
AddMoneyCard)
$1bNotice more balances getting added , but the balance will remain the same. This is because the bank hasn’t yet approved the txn

Simulating the bank webhook
Section titled “Simulating the bank webhook”-
cd
apps/bank-webhook -
npm run dev (If it fails, try installing esbuild)
-
In another terminal, get the
tokenfor one of the onRamp transactions by runningnpx prisma studioinpackages/db
-
Simulate a hdfcBank transaction POST http://localhost:3003/hdfcWebhook
{ "token": "970.4572088875194", "user_identifier": 1, "amount": "210"}💡 Do you really need the amount/user id to come from the hdfc bank server? Or is the token enough?