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:
1 parent
a84e8987cb
commit
fb59342de4
6 files changed
+48
-13
No files matched your search
@@ -1,6 +1,8 @@
|
||||
import appStore from "@calcom/app-store";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { sendNoShowFeeChargedEmail } from "@calcom/emails";
|
||||
import { ErrorCode } from "@calcom/lib/errorCodes";
|
||||
import { ErrorWithCode } from "@calcom/lib/errors";
|
||||
import { getTranslation } from "@calcom/lib/server/i18n";
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
import type { EventTypeMetadata } from "@calcom/prisma/zod-utils";
|
||||
@@ -141,9 +143,13 @@ export const chargeCardHandler = async ({ ctx, input }: ChargeCardHandlerOptions
|
||||
|
||||
return paymentData;
|
||||
} catch (err) {
|
||||
let errorMessage = `Error processing payment with error ${err}`;
|
||||
if (err instanceof ErrorWithCode && err.code === ErrorCode.ChargeCardFailure) {
|
||||
errorMessage = err.message;
|
||||
}
|
||||
throw new TRPCError({
|
||||
code: "INTERNAL_SERVER_ERROR",
|
||||
message: `Error processing payment with error ${err}`,
|
||||
code: "BAD_REQUEST",
|
||||
message: tOrganizer(errorMessage),
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user