Skip to content

Commit

Permalink
Update: basic fixes in token and cancel payment
Browse files Browse the repository at this point in the history
  • Loading branch information
sudhanshugautam2911 committed Nov 7, 2024
1 parent bd1e8e6 commit 7eda286
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions apps/bank-webhook/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ app.post("/hdfcWebhook", async (req, res) => {
// TODO: Add zod validation here?
// TODO: HDFC bank should ideally send us a secret so we know this is sent by them
// TODO: Only if it is processing we should proceed

const paymentInformation: {
token: string;
userId: string;
Expand All @@ -27,7 +28,7 @@ app.post("/hdfcWebhook", async (req, res) => {
};

try {
if (paymentInformation.paymentStatus == 'success') {
if (paymentInformation.paymentStatus === 'success') {
await db.$transaction([
db.balance.updateMany({
where: {
Expand All @@ -49,7 +50,7 @@ app.post("/hdfcWebhook", async (req, res) => {
})
]);
} else {
db.onRampTransaction.updateMany({
await db.onRampTransaction.updateMany({
where: {
token: paymentInformation.token
},
Expand Down
2 changes: 1 addition & 1 deletion apps/mock-hdfc/app/lib/actions/validatePayment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function validatePayment(token: any) {
const payload = {
token: token,
user_identifier: decodedData.userId,
amount: decodedData.amount*100,
amount: decodedData.amount,
paymentStatus: 'success'
}

Expand Down
2 changes: 1 addition & 1 deletion apps/user-app/app/lib/actions/createOnrampTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function createOnRampTransaction(provider: string, amount: number)
// this token will be sent from hdfc - for now just hardcoding it
const payload = {
userId: session.user.id,
amount: amount
amount: amount*100
}
const token = jwt.sign(payload, process.env.JWT_SECRET as string);

Expand Down
5 changes: 4 additions & 1 deletion apps/user-app/components/OnRampTransactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ export const OnRampTransactions = ({
</div>
</Card>
}

const sortedTransactions = [...transactions].sort((a,b) => b.time.getTime() - a.time.getTime() )

return <Card title="Recent Transactions">
<div className="pt-2 divider-line">
{transactions.map((t,index) => <div key={index} className="flex justify-between">
{sortedTransactions.map((t,index) => <div key={index} className="flex justify-between">
<div>
<div className="text-sm">
Received INR
Expand Down

0 comments on commit 7eda286

Please sign in to comment.