added bank payment api

This commit is contained in:
Jelaletdin12
2026-09-21 16:23:15 +05:00
parent 03779995ba
commit 18e7c03e76
3 changed files with 18 additions and 3 deletions

View File

@@ -25,6 +25,12 @@ export interface PayPayload {
paymentPeriod: string; // "YYYY-MM-DD"
}
export interface PayResponse {
paymentId?: number;
formUrl?: string;
[key: string]: unknown;
}
/** Kabul ediji + Upgradyý resminamalar (15 sany) — hem UI hem Payload ortak */
export interface IntlPaymentDocs {
doc_sberbank_account: string | null;
@@ -382,7 +388,9 @@ export const intlPaymentApi = {
return data;
},
async pay(id: string, payload: PayPayload): Promise<void> {
await apiClient.post(`/visa-master-payment-orders/${id}/pay`, payload);
async pay(id: string, payload: PayPayload): Promise<PayResponse> {
const res = await apiClient.post<any>(`/visa-master-payment-orders/${id}/pay`, payload);
const data = res.data?.data ?? res.data;
return data as PayResponse;
},
};

View File

@@ -88,9 +88,15 @@ export function usePayIntlPayment() {
const { t } = useTranslation();
return useMutation({
mutationFn: ({ id, payload }: { id: string; payload: PayPayload }) => intlPaymentApi.pay(id, payload),
onSuccess: () => {
onSuccess: (data) => {
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() });
toast.success(t("intlPayment.paySuccess", "Töleg üstünlikli amala aşyryldy"));
if (data?.formUrl) {
const newWindow = window.open(data.formUrl, "_blank");
if (!newWindow || newWindow.closed || typeof newWindow.closed === "undefined") {
window.location.href = data.formUrl;
}
}
},
});
}