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