Skip to content

Commit

Permalink
ran formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
DevParapalli committed Oct 20, 2022
1 parent e254c4e commit 30e946e
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 81 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# SynergyWebsiteCashfree
# SynergyWebsiteCashfree
3 changes: 1 addition & 2 deletions src/lib/data/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const events = [
},
];


/* {
id: "events-3",
name: "CoderCut v6.3",
Expand Down Expand Up @@ -89,4 +88,4 @@ export const events = [
icon: "dashicons:code-standards",
date: "2021-09-01",
players: 2,
}, */
}, */
36 changes: 18 additions & 18 deletions src/lib/types.ts
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;
}
6 changes: 3 additions & 3 deletions src/lib/util.ts
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, "-");
}
112 changes: 59 additions & 53 deletions src/routes/(app)/pg/[id]/pay/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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':""
Expand All @@ -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",
},
};

/*
{
Expand Down Expand Up @@ -139,4 +145,4 @@ export const sample_response = {
order_tags: null,
order_splits: []
}
*/
*/
5 changes: 2 additions & 3 deletions src/routes/(app)/pg/process_return/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const GET: RequestHandler = async ({ url }) => {
"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",
},
});
console.log(await res.clone().json(), res.clone().status, cf_token);
Expand All @@ -34,8 +34,7 @@ export const GET: RequestHandler = async ({ url }) => {
console.log(_data, _error);
if (_data && !_error && _data.cf_status === "PAID") {
throw redirect(307, "/success/" + _data.id);
}
else {
} else {
throw error(500, "Payment failed");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/(app)/success/[regis_id]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const load: PageLoad = async ({ params }) => {
.eq("id", params.regis_id)
.limit(1)
.single();

if (db_1) return { db: db_1, event: events.find((e) => e.id === db_1.event) };
else throw error(404, "Registration ID not found");
};
Expand Down

0 comments on commit 30e946e

Please sign in to comment.