Update index.ts

This commit is contained in:
Benoy Bose 2025-04-14 19:01:14 +05:30
parent 07bb778244
commit 1b5eb33859

View File

@ -534,32 +534,34 @@ 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-client-id': `${clientId}`,
'x-client-secret': `${clientSecret}`,
'x-api-version': '2025-01-01', 'x-api-version': '2025-01-01',
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, };
body: `{ console.log(`Header: ${JSON.stringify(requestHeqaders)}`);
"link_id": "${linkId}", const requestBody = {
"link_amount": ${amount}, "link_id": linkId,
"link_amount": amount,
"link_currency": "INR", "link_currency": "INR",
"link_purpose": "${productInfo}", "link_purpose": productInfo,
"customer_details": { "customer_details": {
"customer_phone": "${customerPhone}", "customer_phone": customerPhone,
"customer_email": "${customerEmail}", "customer_email": customerEmail,
"customer_name": "${customerName}"}, "customer_name": customerName,
},
"link_partial_payments": false, "link_partial_payments": false,
"link_notify": { "link_notify": {
"send_sms": true, "send_sms": true,
"send_email": true "send_email": true
} }
}`
}; };
console.log(`Options ${JSON.stringify(options)}`); console.log(`Body: ${JSON.stringify(requestBody)}`);
const cashfreeResponse = await axios.post(apiUrl!, options); 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,