-
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.
- Loading branch information
1 parent
e254c4e
commit 30e946e
Showing
7 changed files
with
85 additions
and
81 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 |
---|---|---|
@@ -1 +1 @@ | ||
# SynergyWebsiteCashfree | ||
# SynergyWebsiteCashfree |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
export interface db_registration { | ||
id?: number | ||
created_at: Date | string | ||
name: string | ||
email: string | ||
education: string | ||
event: string | ||
amount: number | ||
status: boolean | ||
team: string[] | ||
rzp_pid?: string | ||
rzp_oid?: string | ||
rzp_sig?: string | ||
phone: string | ||
cf_id: string | ||
cf_token: string | ||
cf_status: string | ||
rzp_status: string | ||
} | ||
id?: number; | ||
created_at: Date | string; | ||
name: string; | ||
email: string; | ||
education: string; | ||
event: string; | ||
amount: number; | ||
status: boolean; | ||
team: string[]; | ||
rzp_pid?: string; | ||
rzp_oid?: string; | ||
rzp_sig?: string; | ||
phone: string; | ||
cf_id: string; | ||
cf_token: string; | ||
cf_status: string; | ||
rzp_status: string; | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export function slugify(str: string) { | ||
return str | ||
.toLowerCase() | ||
.replace(/[^\w ]+/g, '') | ||
.replace(/ +/g, '-'); | ||
} | ||
.replace(/[^\w ]+/g, "") | ||
.replace(/ +/g, "-"); | ||
} |
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ import { events } from "$lib/data/events"; | |
import { error, json } from "@sveltejs/kit"; | ||
import { slugify } from "$lib/util"; | ||
import { supabaseClient } from "$lib/db"; | ||
import {dev} from '$app/environment'; | ||
import { dev } from "$app/environment"; | ||
import { CF_API_KEY, CF_SECRET_KEY } from "$env/static/private"; | ||
|
||
// TODO: const PG_URL = (dev) ? 'https://sandbox.cashfree.com/pg/orders':"" | ||
|
@@ -22,72 +22,78 @@ export const load: PageServerLoad = async (event) => { | |
"Content-Type": "application/json", | ||
"x-client-id": CF_API_KEY, | ||
"x-client-secret": CF_SECRET_KEY, | ||
"x-api-version": "2022-01-01" | ||
"x-api-version": "2022-01-01", | ||
}, | ||
body: JSON.stringify({ | ||
"order_id": (data.id).toString()+"_"+((new Date()).valueOf()/1000).toFixed(0), | ||
"order_amount": data.amount/100, | ||
"order_currency": "INR", | ||
"order_note": "Additional order info", | ||
"customer_details": { | ||
"customer_id": slugify(data.name +"="+ data.phone), | ||
"customer_name": data.name, | ||
"customer_email": data.email, | ||
"customer_phone": data.phone | ||
order_id: data.id.toString() + "_" + (new Date().valueOf() / 1000).toFixed(0), | ||
order_amount: data.amount / 100, | ||
order_currency: "INR", | ||
order_note: "Additional order info", | ||
customer_details: { | ||
customer_id: slugify(data.name + "=" + data.phone), | ||
customer_name: data.name, | ||
customer_email: data.email, | ||
customer_phone: data.phone, | ||
}, | ||
order_meta: { | ||
// TODO: | ||
return_url: | ||
"http://synergy-22-cf.vercel.app/pg/process_return?cf_id={order_id}&cf_token={order_token}", | ||
}, | ||
"order_meta": { | ||
// TODO: | ||
"return_url": "http://synergy-22-cf.vercel.app/pg/process_return?cf_id={order_id}&cf_token={order_token}" | ||
} | ||
}), | ||
}); | ||
const _data = await _req.json(); | ||
({data} = await supabaseClient.from('registrations').update({cf_id: _data.cf_order_id, cf_token: _data.order_token, cf_status: _data.order_status}).eq('id', data.id).select().single()); | ||
if(dev){console.log(data); | ||
console.log(_data);} | ||
({ data } = await supabaseClient | ||
.from("registrations") | ||
.update({ | ||
cf_id: _data.cf_order_id, | ||
cf_token: _data.order_token, | ||
cf_status: _data.order_status, | ||
}) | ||
.eq("id", data.id) | ||
.select() | ||
.single()); | ||
if (dev) { | ||
console.log(data); | ||
console.log(_data); | ||
} | ||
if (data && _data) return { db: data, pg: _data }; | ||
else throw error(404, "Registration ID not found"); | ||
}; | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
export const sample_response = { | ||
"cf_order_id": 1539553, | ||
"created_at": "2021-07-19T16:13:35+05:30", | ||
"customer_details": { | ||
"customer_id": "7112AAA812234", | ||
"customer_name": null, | ||
"customer_email": "[email protected]", | ||
"customer_phone": "9908734801" | ||
cf_order_id: 1539553, | ||
created_at: "2021-07-19T16:13:35+05:30", | ||
customer_details: { | ||
customer_id: "7112AAA812234", | ||
customer_name: null, | ||
customer_email: "[email protected]", | ||
customer_phone: "9908734801", | ||
}, | ||
"entity": "order", | ||
"order_amount": 5.01, | ||
"order_currency": "INR", | ||
"order_expiry_time": "2021-08-18T16:13:34+05:30", | ||
"order_id": "order_271vWwzSQOHe01ZVXpEcguVxQSRqr", | ||
"order_meta": { | ||
"return_url": "https://b8af79f41056.eu.ngrok.io?order_id={order_id}&order_token={order_token}", | ||
"notify_url": "https://b8af79f41056.eu.ngrok.io/webhook.php", | ||
"payment_methods": null | ||
entity: "order", | ||
order_amount: 5.01, | ||
order_currency: "INR", | ||
order_expiry_time: "2021-08-18T16:13:34+05:30", | ||
order_id: "order_271vWwzSQOHe01ZVXpEcguVxQSRqr", | ||
order_meta: { | ||
return_url: "https://b8af79f41056.eu.ngrok.io?order_id={order_id}&order_token={order_token}", | ||
notify_url: "https://b8af79f41056.eu.ngrok.io/webhook.php", | ||
payment_methods: null, | ||
}, | ||
"order_note": null, | ||
"order_status": "PAID", | ||
"order_token": "BtJEHHxOB9bFpNsaHmEL", | ||
"payment_link": "https://payments-test.cashfree.com/order/#BtJEHHxOB9bFpNsaHmEL", | ||
"payments": { | ||
"url": "https://sandbox.cashfree.com/pg/orders/order_271vWwzSQOHe01ZVXpEcguVxQSRqr/payments" | ||
order_note: null, | ||
order_status: "PAID", | ||
order_token: "BtJEHHxOB9bFpNsaHmEL", | ||
payment_link: "https://payments-test.cashfree.com/order/#BtJEHHxOB9bFpNsaHmEL", | ||
payments: { | ||
url: "https://sandbox.cashfree.com/pg/orders/order_271vWwzSQOHe01ZVXpEcguVxQSRqr/payments", | ||
}, | ||
"refunds": { | ||
"url": "https://sandbox.cashfree.com/pg/orders/order_271vWwzSQOHe01ZVXpEcguVxQSRqr/refunds" | ||
refunds: { | ||
url: "https://sandbox.cashfree.com/pg/orders/order_271vWwzSQOHe01ZVXpEcguVxQSRqr/refunds", | ||
}, | ||
"settlements": { | ||
"url": "https://sandbox.cashfree.com/pg/orders/order_271vWwzSQOHe01ZVXpEcguVxQSRqr/settlements" | ||
} | ||
} | ||
settlements: { | ||
url: "https://sandbox.cashfree.com/pg/orders/order_271vWwzSQOHe01ZVXpEcguVxQSRqr/settlements", | ||
}, | ||
}; | ||
|
||
/* | ||
{ | ||
|
@@ -139,4 +145,4 @@ export const sample_response = { | |
order_tags: null, | ||
order_splits: [] | ||
} | ||
*/ | ||
*/ |
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