Added cors createCashfreeOrder (#7)

Reviewed-on: #7
Co-authored-by: DhanshCOSQ <dhanshas@cosq.net>
Co-committed-by: DhanshCOSQ <dhanshas@cosq.net>
This commit is contained in:
Dhansh A S 2025-04-07 14:36:46 +00:00 committed by Benoy Bose
parent 688619bd45
commit 7d37e295fe
3 changed files with 90 additions and 81 deletions

View File

@ -10,6 +10,7 @@
"dependencies": {
"@types/node-fetch": "^2.6.12",
"axios": "^1.8.4",
"cors": "^2.8.5",
"firebase-admin": "^12.6.0",
"firebase-functions": "^6.0.1",
"form-data": "^4.0.1",

View File

@ -17,6 +17,7 @@
"dependencies": {
"@types/node-fetch": "^2.6.12",
"axios": "^1.8.4",
"cors": "^2.8.5",
"firebase-admin": "^12.6.0",
"firebase-functions": "^6.0.1",
"form-data": "^4.0.1",

View File

@ -8,6 +8,7 @@ import * as os from 'os';
import * as path from 'path';
import * as fs from 'fs';
import * as https from 'https';
import cors from 'cors';
import axios from "axios";
import { getStorage } from 'firebase-admin/storage';
const formData = require('form-data');
@ -19,6 +20,9 @@ const twilio = require('twilio');
if (!admin.apps.length) {
admin.initializeApp();
}
const corsHandler = cors({ origin: true });
export const sendEmailWithAttachment = onRequest({
region: '#{SERVICES_RGN}#'
}, async (request: Request, response: express.Response) => {
@ -245,6 +249,8 @@ export const notifyInvitation = onDocumentCreated({
export const createCashfreeOrder = onRequest({
region: '#{SERVICES_RGN}#'
}, async (request: Request, response: express.Response) => {
return corsHandler(request, response, async () => {
try {
const authHeader = request.headers.authorization;
if (!authHeader || !authHeader.startsWith('Bearer ')) {
@ -331,6 +337,7 @@ export const createCashfreeOrder = onRequest({
details: error.response?.data || error.message
});
}
});
});
export const verifyCashfreePayment = onRequest({