-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move payment to home and enable fetching data
- Loading branch information
Showing
7 changed files
with
39 additions
and
22 deletions.
There are no files selected for viewing
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,5 @@ | ||
import type { ParamMatcher } from '@sveltejs/kit'; | ||
|
||
export const match: ParamMatcher = (param) => { | ||
return /^\d+$/.test(param); | ||
}; |
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
File renamed without changes.
File renamed without changes.
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 @@ | ||
import type { PageServerLoad } from './$types'; | ||
import RazorPay from 'razorpay'; | ||
import { KEY_ID, KEY_SECRET } from '$env/static/private'; | ||
import type { Product } from '../+layout.server'; | ||
import { error } from '@sveltejs/kit'; | ||
|
||
const razorpay = new RazorPay({ | ||
key_id: KEY_ID, | ||
key_secret: KEY_SECRET | ||
}); | ||
|
||
export const load: PageServerLoad = async ({ url, parent }) => { | ||
const id = Number(url.searchParams.get('id')); | ||
const products: { products: Product[] } = await parent(); | ||
|
||
try { | ||
const product = products.products.filter((e) => e.id === id)[0]; | ||
|
||
const response = await razorpay.orders.create({ | ||
amount: product.bidPrice, | ||
currency: 'INR' | ||
}); | ||
return { product, id: response.id }; | ||
} catch (e) { | ||
throw error(404, { message: 'ID not found!' }); | ||
} | ||
}; |
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 was deleted.
Oops, something went wrong.