fix: Show the Stripe payment error message and change the status to 400 for charge card issues (#22463)

* fix: show stripe payment error message

* Update PaymentService.ts

* Update chargeCard.handler.ts

* Update chargeCard.handler.ts

* Update PaymentService.ts

* update

* update
This commit is contained in:
Anik Dhabal Babu authored and GitHub committed 2025-07-16 09:45:49 +00:00
1 parent a84e8987cb
commit fb59342de4
6 files changed
+48 -13

No files matched your search

@@ -21,15 +21,17 @@ export const ChargeCardDialog = (props: IRescheduleDialog) => {
const { t } = useLocale();
const utils = trpc.useUtils();
const { isOpenDialog, setIsOpenDialog, bookingId } = props;
const [chargeError, setChargeError] = useState(false);
const [chargeError, setChargeError] = useState<string | null>(null);
const chargeCardMutation = trpc.viewer.payments.chargeCard.useMutation({
onSuccess: () => {
utils.viewer.bookings.invalidate();
setIsOpenDialog(false);
setChargeError(null);
showToast("Charge successful", "success");
},
onError: () => {
setChargeError(true);
onError: (error) => {
setChargeError(error.message || t("error_charging_card"));
},
});
@@ -52,7 +54,7 @@ export const ChargeCardDialog = (props: IRescheduleDialog) => {
{chargeError && (
<div className="mt-4 flex text-red-500">
<Icon name="triangle-alert" className="mr-2 h-5 w-5 " aria-hidden="true" />
<p className="text-sm">{t("error_charging_card")}</p>
<p className="text-sm">{chargeError}</p>
</div>
)}
@@ -60,12 +62,13 @@ export const ChargeCardDialog = (props: IRescheduleDialog) => {
<DialogClose />
<Button
data-testid="send_request"
disabled={chargeCardMutation.isPending || chargeError}
onClick={() =>
disabled={chargeCardMutation.isPending}
onClick={() => {
setChargeError(null);
chargeCardMutation.mutate({
bookingId,
})
}>
});
}}>
{t("charge_attendee", currencyStringParams)}
</Button>
</DialogFooter>