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