From 81d8628a870a7bef38be3b71ad6e0fe67a5af01d Mon Sep 17 00:00:00 2001 From: Peer Richelsen Date: Mon, 24 Apr 2023 19:21:24 +0200 Subject: [PATCH] remove application_fee_amount (#8496) * Clean up linting * Type fix --------- Co-authored-by: gitstart-calcom Co-authored-by: GitStart-Cal.com <121884634+gitstart-calcom@users.noreply.github.com> Co-authored-by: Joe Au-Yeung Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> --- .../app-store/stripepayment/lib/PaymentService.ts | 15 ++++----------- packages/trpc/server/routers/viewer/payments.tsx | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/app-store/stripepayment/lib/PaymentService.ts b/packages/app-store/stripepayment/lib/PaymentService.ts index a5098ad4b9..ee18a9a8e7 100644 --- a/packages/app-store/stripepayment/lib/PaymentService.ts +++ b/packages/app-store/stripepayment/lib/PaymentService.ts @@ -62,9 +62,7 @@ export class PaymentService implements IAbstractPaymentService { }); // Parse keys with zod - const { client_id, payment_fee_fixed, payment_fee_percentage } = stripeAppKeysSchema.parse( - stripeAppKeys?.keys - ); + const { payment_fee_fixed, payment_fee_percentage } = stripeAppKeysSchema.parse(stripeAppKeys?.keys); const paymentFee = Math.round(payment.amount * payment_fee_percentage + payment_fee_fixed); const customer = await retrieveOrCreateStripeCustomerByEmail( @@ -76,7 +74,6 @@ export class PaymentService implements IAbstractPaymentService { amount: payment.amount, currency: this.credentials.default_currency, payment_method_types: ["card"], - application_fee_amount: paymentFee, customer: customer.id, }; @@ -143,9 +140,7 @@ export class PaymentService implements IAbstractPaymentService { }); // Parse keys with zod - const { client_id, payment_fee_fixed, payment_fee_percentage } = stripeAppKeysSchema.parse( - stripeAppKeys?.keys - ); + const { payment_fee_fixed, payment_fee_percentage } = stripeAppKeysSchema.parse(stripeAppKeys?.keys); const paymentFee = Math.round(payment.amount * payment_fee_percentage + payment_fee_fixed); const customer = await retrieveOrCreateStripeCustomerByEmail( @@ -200,7 +195,7 @@ export class PaymentService implements IAbstractPaymentService { return paymentData; } - async chargeCard(payment: Payment, bookingId: Booking["id"]): Promise { + async chargeCard(payment: Payment): Promise { try { const stripeAppKeys = await prisma?.app.findFirst({ select: { @@ -216,9 +211,7 @@ export class PaymentService implements IAbstractPaymentService { const setupIntent = paymentObject.setupIntent; // Parse keys with zod - const { client_id, payment_fee_fixed, payment_fee_percentage } = stripeAppKeysSchema.parse( - stripeAppKeys?.keys - ); + const { payment_fee_fixed, payment_fee_percentage } = stripeAppKeysSchema.parse(stripeAppKeys?.keys); const paymentFee = Math.round(payment.amount * payment_fee_percentage + payment_fee_fixed); diff --git a/packages/trpc/server/routers/viewer/payments.tsx b/packages/trpc/server/routers/viewer/payments.tsx index 58e0902545..a044a5c53a 100644 --- a/packages/trpc/server/routers/viewer/payments.tsx +++ b/packages/trpc/server/routers/viewer/payments.tsx @@ -106,7 +106,7 @@ export const paymentsRouter = router({ const paymentInstance = new PaymentService(paymentCredential); try { - const paymentData = await paymentInstance.chargeCard(booking.payment[0], booking.id); + const paymentData = await paymentInstance.chargeCard(booking.payment[0]); if (!paymentData) { throw new TRPCError({ code: "NOT_FOUND", message: `Could not generate payment data` });