updated payment
This commit is contained in:
1 parent
61a0995ea4
commit
cc3c718861
4 files changed
+243
-53
No files matched your search
@@ -88,14 +88,25 @@ export function usePayIntlPayment() {
|
||||
const { t } = useTranslation();
|
||||
return useMutation({
|
||||
mutationFn: ({ id, payload }: { id: string; payload: PayPayload }) => intlPaymentApi.pay(id, payload),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.lists() });
|
||||
toast.success(t("intlPayment.payStarted", "Bank töleg sahypasy açyldy"));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useCheckIntlPaymentStatus() {
|
||||
const qc = useQueryClient();
|
||||
const { t } = useTranslation();
|
||||
return useMutation({
|
||||
mutationFn: (id: string) => intlPaymentApi.status(id),
|
||||
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;
|
||||
}
|
||||
qc.invalidateQueries({ queryKey: INTL_PAYMENT_KEYS.detail(String(data.orderId)) });
|
||||
if (data.paid) {
|
||||
toast.success(t("intlPayment.paySuccess", "Töleg üstünlikli amala aşyryldy"));
|
||||
} else {
|
||||
toast.error(t("intlPayment.payFailed", "Töleg amala aşyrylmady"));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user