import axios, { AxiosError } from 'axios'; const API_URL = 'https://book.liteapi.travel/v3.0/rates/prebook/'; interface PrebookResponse { secretKey: string; transactionId: string; } export const fetchPaymentIntent = async (prebookId: string, apiKey: string): Promise => { const options = { headers: { 'accept': 'application/json', 'content-type': 'application/json', 'X-API-Key': apiKey, }, }; const data = { usePaymentSdk: true, offerId: prebookId, }; try { const response = await axios.post(API_URL, data, options); console.log('DATA 1 IS ',response.data); return response.data.data; // Assuming the secretKey is in response.data.data.secretKey } catch (error) { if (axios.isAxiosError(error)) { console.error('Error fetching payment intent :', error.response ? error.response.data : error.message); } else { console.error('Error fetching payment intent:', error); } throw error; } };