reservation-front/src/services/ipgApi.ts
2026-06-24 22:47:43 +03:30

31 lines
781 B
TypeScript

import axios from 'axios'
import { attachAuthInterceptors } from '../utils/authInterceptor'
const IPG_BASE_URL = import.meta.env.VITE_IPG_BASE_URL || 'https://ipg-staging.addwin.ir'
const ipgApi = axios.create({
baseURL: IPG_BASE_URL,
headers: { 'Content-Type': 'application/json' },
})
attachAuthInterceptors(ipgApi)
export interface CreateChargePayload {
amount: number
callback_url: string
}
export interface ChargeResponse {
uuid: string
}
export async function createCharge(payload: CreateChargePayload): Promise<ChargeResponse> {
const { data } = await ipgApi.post<ChargeResponse>('/api/charge_create/', payload)
return data
}
export function chargePageUrl(uuid: string): string {
return `${IPG_BASE_URL}/page/charge/${uuid}/`
}
export default ipgApi