feat(payment): enhance payment configuration to include active gateways and update CORS settings
This commit is contained in:
@@ -2,11 +2,25 @@ import { useQuery } from '@tanstack/react-query';
|
||||
import { api } from '../lib/api';
|
||||
import type { ApiResponse } from '../lib/api';
|
||||
|
||||
export interface PaymentGatewayInfo {
|
||||
name: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
interface PaymentConfig {
|
||||
test_mode: boolean;
|
||||
appointment_fee_rials: number;
|
||||
gateways: PaymentGatewayInfo[];
|
||||
}
|
||||
|
||||
export function usePaymentConfig() {
|
||||
const { data } = useQuery<ApiResponse<{ test_mode: boolean }>>({
|
||||
const { data } = useQuery<ApiResponse<PaymentConfig>>({
|
||||
queryKey: ['payment-config'],
|
||||
queryFn: () => api.get('/api/v1/payment/config'),
|
||||
staleTime: 5 * 60 * 1000,
|
||||
});
|
||||
return { isTestMode: data?.data?.test_mode ?? false };
|
||||
return {
|
||||
isTestMode: data?.data?.test_mode ?? false,
|
||||
gateways: data?.data?.gateways ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user