Compare commits
	
		
			6 Commits
		
	
	
		
			9bd4a06dd9
			...
			0e60f34500
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 0e60f34500 | |||
| 66ba3b88ab | |||
| e8cec7e0f4 | |||
| e2d87fa095 | |||
| 1b5eb33859 | |||
| 07bb778244 | 
| @ -11,3 +11,4 @@ GOOGLE_MAPS_API_KEY=#{GOOGLE_MAPS_API_KEY}# | |||||||
| FITLIENHOST=#{FITLIENHOST}# | FITLIENHOST=#{FITLIENHOST}# | ||||||
| CASHFREE_URL=#{CASHFREE_URL}# | CASHFREE_URL=#{CASHFREE_URL}# | ||||||
| CASHFREE_LINK_URL=#{CASHFREE_LINK_URL}# | CASHFREE_LINK_URL=#{CASHFREE_LINK_URL}# | ||||||
|  | CASHFREE_LINK_NOTIFY_URL=#{CASHFREE_LINK_NOTIFY_URL}# | ||||||
|  | |||||||
| @ -524,6 +524,7 @@ export const createCashfreeLink = onRequest({ | |||||||
|         const clientId = process.env.CASHFREE_CLIENT_ID; |         const clientId = process.env.CASHFREE_CLIENT_ID; | ||||||
|         const clientSecret = process.env.CASHFREE_CLIENT_SECRET; |         const clientSecret = process.env.CASHFREE_CLIENT_SECRET; | ||||||
|         let apiUrl = process.env.CASHFREE_LINK_URL; |         let apiUrl = process.env.CASHFREE_LINK_URL; | ||||||
|  |         console.log(`API URL: ${apiUrl}`); | ||||||
| 
 | 
 | ||||||
|         if (!clientId || !clientSecret) { |         if (!clientId || !clientSecret) { | ||||||
|           logger.error('Cashfree credentials not configured'); |           logger.error('Cashfree credentials not configured'); | ||||||
| @ -533,46 +534,43 @@ export const createCashfreeLink = onRequest({ | |||||||
| 
 | 
 | ||||||
|         const linkId = uuidv4(); |         const linkId = uuidv4(); | ||||||
|         try { |         try { | ||||||
|           const options = { |           const requestHeqaders = { | ||||||
|             method: 'POST', |             'x-client-id': clientId, | ||||||
|             headers: { |             'x-client-secret': clientSecret, | ||||||
|             'x-api-version': '2025-01-01', |             'x-api-version': '2025-01-01', | ||||||
|               'x-client-id': `${process.env.CASHFREE_CLIENT_ID}`, |  | ||||||
|               'x-client-secret': `${process.env.CASHFREE_CLIENT_SECRET}`, |  | ||||||
|             'Content-Type': 'application/json' |             'Content-Type': 'application/json' | ||||||
|             }, |           }; | ||||||
|             body: `{
 |           console.log(`Header: ${JSON.stringify(requestHeqaders)}`); | ||||||
|                       "customer_details": { |           const requestBody = { | ||||||
|                             "customer_email": "${customerEmail}", |             "link_id": linkId, | ||||||
|                             "customer_name": "${customerName}", |             "link_amount": amount, | ||||||
|                             "customer_phone": "${customerPhone}" |  | ||||||
|                       }, |  | ||||||
|                       "link_amount": ${amount}, |  | ||||||
|                       "link_auto_reminders": true, |  | ||||||
|             "link_currency": "INR", |             "link_currency": "INR", | ||||||
|                       "link_expiry_time": "${expirationString}", |             "link_purpose": productInfo, | ||||||
|                       "link_id": "${linkId}", |             "customer_details": { | ||||||
|                       "link_meta": { |               "customer_phone": customerPhone, | ||||||
|                         "notify_url": "https://ee08e626ecd88c61c85f5c69c0418cb5.m.pipedream.net", |               "customer_email": customerEmail, | ||||||
|                         "return_url": "https://www.cashfree.com/devstudio/thankyou", |               "customer_name": customerName, | ||||||
|                         "upi_intent": false |  | ||||||
|                       }, |  | ||||||
|                       "link_notes": { |  | ||||||
|                         "userId": "${userId}", |  | ||||||
|                         "gymId": "${gymId}", |  | ||||||
|                         "orderId": "${orderId}", |  | ||||||
|                         "requestUserId": "${uid}" |  | ||||||
|                       }, |  | ||||||
|                       "link_notify": { |  | ||||||
|                         "send_email": true, |  | ||||||
|                         "send_sms": true |  | ||||||
|             }, |             }, | ||||||
|             "link_partial_payments": false, |             "link_partial_payments": false, | ||||||
|                       "link_purpose": "${productInfo}", |             "link_notify": { | ||||||
|                       "order_splits": [] |               "send_sms": true, | ||||||
|                   }` |               "send_email": true | ||||||
|  |             }, | ||||||
|  |             "link_expiry_time": expirationString, | ||||||
|  |             "link_notes": { | ||||||
|  |               "order_id": orderId, | ||||||
|  |               "gym_id": gymId, | ||||||
|  |               "user_id": userId | ||||||
|  |             }, | ||||||
|  |             "link_meta": { | ||||||
|  |               "notify_url": process.env.CASHFREE_LINK_NOTIFY_URL | ||||||
|  |             } | ||||||
|           }; |           }; | ||||||
|           const cashfreeResponse = await axios.post(apiUrl!, options); |           console.log(`Body: ${JSON.stringify(requestBody)}`); | ||||||
|  |           const cashfreeResponse = await axios.post(apiUrl!, requestBody, { | ||||||
|  |             headers: requestHeqaders | ||||||
|  |           }); | ||||||
|  | 
 | ||||||
|           try { |           try { | ||||||
|             await admin.firestore().collection('payment_links').doc(orderId).set({ |             await admin.firestore().collection('payment_links').doc(orderId).set({ | ||||||
|               requestUserId: uid, |               requestUserId: uid, | ||||||
| @ -594,7 +592,8 @@ export const createCashfreeLink = onRequest({ | |||||||
|             linkId: linkId, |             linkId: linkId, | ||||||
|             linkUrl: cashfreeResponse.data.link_url, |             linkUrl: cashfreeResponse.data.link_url, | ||||||
|             linkExpiryTime: cashfreeResponse.data.link_expiry_time, |             linkExpiryTime: cashfreeResponse.data.link_expiry_time, | ||||||
|             linkStatus: cashfreeResponse.data.link_status |             linkStatus: cashfreeResponse.data.link_status, | ||||||
|  |             linkQRCode: cashfreeResponse.data.link_qrcode | ||||||
|           }); |           }); | ||||||
| 
 | 
 | ||||||
|         } catch (axiosError: any) { |         } catch (axiosError: any) { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user