UNPKG

shora-ai-payment-sdk

Version:

The first open-source payment SDK designed specifically for AI agents and chatbots - ACP Compatible

28 lines (27 loc) 1.04 kB
import axios from 'axios'; export function createAxiosInstance(baseURL, apiKey) { const client = axios.create({ baseURL, timeout: 30000 }); if (apiKey) { if (apiKey.startsWith('sk_') || apiKey.startsWith('Bearer ')) { client.defaults.headers.common['Authorization'] = `Bearer ${apiKey.replace('Bearer ', '')}`; } else { client.defaults.headers.common['X-API-Key'] = apiKey; client.defaults.headers.common['Authorization'] = `Bearer ${apiKey}`; } } client.interceptors.response.use((r) => { const headers = r.headers || {}; const dep = headers['deprecation'] || headers['Deprecation']; const sunset = headers['sunset'] || headers['Sunset']; const link = headers['link'] || headers['Link']; if (dep === 'true' || sunset) { console.warn(`[Shora-SDK] Deprecation warning: sunset=${sunset} link=${link}`); } return r; }, (e) => Promise.reject(e)); return client; }