97 lines
2.7 KiB
TypeScript
97 lines
2.7 KiB
TypeScript
import { apiClient } from '@/shared/api/client'
|
|
import type { ApiResponse } from '@/shared/types/types'
|
|
|
|
export interface ConfigTestPayment {
|
|
id: number
|
|
tenant_id: number
|
|
payment_config_id: number
|
|
config_name: string
|
|
provider: string
|
|
merchant_id: string
|
|
pay_way: string
|
|
environment: string
|
|
config_status: string
|
|
test_no: string
|
|
third_order_id: string
|
|
provider_order_id: string
|
|
amount_cent: number
|
|
status: string
|
|
td_code?: string
|
|
jspay_url?: string
|
|
jspay_info?: string
|
|
error_message: string
|
|
raw_request?: Record<string, unknown> | null
|
|
raw_response?: Record<string, unknown> | null
|
|
create_request?: Record<string, unknown> | null
|
|
create_response?: Record<string, unknown> | null
|
|
query_request?: Record<string, unknown> | null
|
|
query_response?: Record<string, unknown> | null
|
|
notify_request?: Record<string, unknown> | null
|
|
notify_result?: Record<string, unknown> | null
|
|
notify_ack?: string
|
|
query_count: number
|
|
last_queried_at?: string
|
|
paid_at?: string
|
|
notified_at?: string
|
|
created_at: string
|
|
updated_at: string
|
|
}
|
|
|
|
export interface ConfigTestPaymentList {
|
|
items: ConfigTestPayment[]
|
|
total: number
|
|
page: number
|
|
page_size: number
|
|
}
|
|
|
|
export interface ConfigTestPaymentQuery {
|
|
payment_config_id?: number
|
|
provider?: string
|
|
pay_way?: string
|
|
status?: string
|
|
test_no?: string
|
|
page?: number
|
|
page_size?: number
|
|
}
|
|
|
|
export async function createConfigTestPayment(configId: number, amountCent: number) {
|
|
const { data } = await apiClient.post<ApiResponse<ConfigTestPayment>>(
|
|
`/admin/payment-configs/${configId}/test-orders`,
|
|
{ amount_cent: amountCent }
|
|
)
|
|
return data.data
|
|
}
|
|
|
|
export async function fetchConfigTestPayments(query: ConfigTestPaymentQuery = {}) {
|
|
const params = Object.fromEntries(
|
|
Object.entries(query).filter(([, value]) => value !== '' && value !== undefined)
|
|
)
|
|
const { data } = await apiClient.get<ApiResponse<ConfigTestPaymentList>>(
|
|
'/admin/payment-config-test-orders',
|
|
{ params }
|
|
)
|
|
const result = data.data
|
|
return {
|
|
items: Array.isArray(result?.items) ? result.items : [],
|
|
total: Number(result?.total ?? 0),
|
|
page: Number(result?.page ?? query.page ?? 1),
|
|
page_size: Number(result?.page_size ?? query.page_size ?? 20),
|
|
}
|
|
}
|
|
|
|
export async function fetchConfigTestPayment(id: number) {
|
|
const { data } = await apiClient.get<ApiResponse<ConfigTestPayment>>(
|
|
`/admin/payment-config-test-orders/${id}`
|
|
)
|
|
return data.data
|
|
}
|
|
|
|
export async function refreshConfigTestPayment(id: number, silent = false) {
|
|
const { data } = await apiClient.post<ApiResponse<ConfigTestPayment>>(
|
|
`/admin/payment-config-test-orders/${id}/refresh`,
|
|
undefined,
|
|
{ silent }
|
|
)
|
|
return data.data
|
|
}
|