Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zomars/cal 884 paid events not sending the link #7318

Merged
merged 6 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
WIP
  • Loading branch information
zomars committed Feb 24, 2023
commit f61c9356183ffe467c4974a8841cefcb4608abf7
4 changes: 2 additions & 2 deletions packages/app-store/stripepayment/lib/PaymentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class PaymentService implements IAbstractPaymentService {
amount: payment.amount,
currency: this.credentials.default_currency,
payment_method_types: ["card"],
application_fee_amount: paymentFee,
// application_fee_amount: paymentFee,
};

const paymentIntent = await this.stripe.paymentIntents.create(params, {
Expand Down Expand Up @@ -89,7 +89,7 @@ export class PaymentService implements IAbstractPaymentService {
stripe_publishable_key: this.credentials.stripe_publishable_key,
stripeAccount: this.credentials.stripe_user_id,
}) as unknown as Prisma.InputJsonValue,
fee: paymentFee,
fee: 0,
zomars marked this conversation as resolved.
Show resolved Hide resolved
refunded: false,
success: false,
},
Expand Down
33 changes: 19 additions & 14 deletions packages/features/ee/payments/api/webhook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { BookingStatus, Prisma } from "@prisma/client";
import { BookingStatus } from "@prisma/client";
import type { Prisma } from "@prisma/client";
import { buffer } from "micro";
import type { NextApiRequest, NextApiResponse } from "next";
import Stripe from "stripe";
import type Stripe from "stripe";

import stripe from "@calcom/app-store/stripepayment/lib/server";
import EventManager from "@calcom/core/EventManager";
Expand All @@ -20,6 +21,18 @@ export const config = {
},
};

async function getEventType(id: number) {
return prisma.eventType.findUnique({
where: {
id,
},
select: {
recurringEvent: true,
requiresConfirmation: true,
},
});
}

async function handlePaymentSuccess(event: Stripe.Event) {
const paymentIntent = event.data.object as Stripe.PaymentIntent;
const payment = await prisma.payment.findFirst({
Expand Down Expand Up @@ -63,22 +76,14 @@ async function handlePaymentSuccess(event: Stripe.Event) {
},
});

console.log("booking", JSON.stringify(booking));
zomars marked this conversation as resolved.
Show resolved Hide resolved

if (!booking) throw new HttpCode({ statusCode: 204, message: "No booking found" });

const eventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
recurringEvent: true,
requiresConfirmation: true,
});
const eventTypeData = Prisma.validator<Prisma.EventTypeArgs>()({ select: eventTypeSelect });
type EventTypeRaw = Prisma.EventTypeGetPayload<typeof eventTypeData>;
type EventTypeRaw = Awaited<ReturnType<typeof getEventType>>;
let eventTypeRaw: EventTypeRaw | null = null;
if (booking.eventTypeId) {
eventTypeRaw = await prisma.eventType.findUnique({
where: {
id: booking.eventTypeId,
},
select: eventTypeSelect,
});
eventTypeRaw = await getEventType(booking.eventTypeId);
}

const { user } = booking;
Expand Down