feat: похуйу
This commit is contained in:
46
src/features/payment/api/paymentApi.ts
Normal file
46
src/features/payment/api/paymentApi.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { getCsrfToken } from '@shared/api/csrf'
|
||||
|
||||
const PAYMENT_API_URL = 'https://app.payment.elcsa.ru'
|
||||
|
||||
export interface PaymentConfig {
|
||||
status_code: number
|
||||
usdt_exchange_rate: string
|
||||
gas_fee: string
|
||||
service_fee_rate: string
|
||||
one_usdt_service_fee: string
|
||||
one_usdt_total_price: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface PaymentQuote {
|
||||
status_code: number
|
||||
usdt_amount: string
|
||||
usdt_exchange_rate: string
|
||||
gas_fee: string
|
||||
service_fee: string
|
||||
total_price: string
|
||||
service_fee_rate: string
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export async function getPaymentConfig(): Promise<PaymentConfig> {
|
||||
const csrf = await getCsrfToken()
|
||||
const res = await fetch(`${PAYMENT_API_URL}/config`, {
|
||||
credentials: 'include',
|
||||
headers: { 'X-CSRF-Token': csrf },
|
||||
})
|
||||
const data = await res.json()
|
||||
if (!res.ok) throw data
|
||||
return data
|
||||
}
|
||||
|
||||
export async function getPaymentQuote(usdtAmount: number): Promise<PaymentQuote> {
|
||||
const csrf = await getCsrfToken()
|
||||
const res = await fetch(`${PAYMENT_API_URL}/payment/quote?usdt_amount=${usdtAmount}`, {
|
||||
credentials: 'include',
|
||||
headers: { 'X-CSRF-Token': csrf },
|
||||
})
|
||||
const data = await res.json()
|
||||
if (!res.ok) throw data
|
||||
return data
|
||||
}
|
||||
Reference in New Issue
Block a user