From 7887e872006b735513884c60010b534d8ef6a7be Mon Sep 17 00:00:00 2001 From: aswincosq Date: Sun, 13 Apr 2025 22:43:31 +0000 Subject: [PATCH 1/2] Fixed function (#19) Reviewed-on: https://git.cosqnet.com/cosqnet/fitlien-services/pulls/19 Co-authored-by: aswincosq Co-committed-by: aswincosq --- functions/src/index.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/functions/src/index.ts b/functions/src/index.ts index ca519f6..31300e9 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -402,15 +402,14 @@ export const createCashfreeOrder = onRequest({ return; } - const isTest = true; const hashKey = `hash_${Date.now()}_${uid.substring(0, 1)}_${orderId}`; - const apiUrl = isTest - ? 'https://sandbox.cashfree.com/pg/orders' - : 'https://api.cashfree.com/pg/orders'; + + let apiUrl = process.env.CASHFREE_URL; + try { const cashfreeResponse = await axios.post( - apiUrl, + apiUrl!, { order_id: orderId, hash_key: hashKey, @@ -506,14 +505,11 @@ export const verifyCashfreePayment = onRequest({ const clientId = process.env.CASHFREE_CLIENT_ID; const clientSecret = process.env.CASHFREE_CLIENT_SECRET; - const isTest = process.env.CASHFREE_ENVIRONMENT !== 'production'; - const apiUrl = isTest - ? `https://sandbox.cashfree.com/pg/orders/${orderId}` - : `https://api.cashfree.com/pg/orders/${orderId}`; + const apiUrl = process.env.CASHFREE_URL; const cashfreeResponse = await axios.get( - apiUrl, + apiUrl!, { headers: { 'x-api-version': '2022-09-01', From 564677d6c29aff9db60e2cbfae0f01403e531e49 Mon Sep 17 00:00:00 2001 From: Benoy Bose Date: Mon, 14 Apr 2025 04:52:58 +0530 Subject: [PATCH 2/2] Update .env.example --- functions/.env.example | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/.env.example b/functions/.env.example index 7eb924a..481d163 100644 --- a/functions/.env.example +++ b/functions/.env.example @@ -9,3 +9,4 @@ CASHFREE_CLIENT_ID=#{CASHFREE_CLIENT_ID}# CASHFREE_CLIENT_SECRET=#{CASHFREE_CLIENT_SECRET}# GOOGLE_MAPS_API_KEY=#{GOOGLE_MAPS_API_KEY}# FITLIENHOST=#{FITLIENHOST}# +CASHFREE_URL=#{CASHFREE_URL}#