Files
calendar/packages/lib/server/repository/PrismaBookingPaymentRepository.ts
T
7b2f811bfe feat: BTCPay Server App (#21197)
* app initialization

* btcpay-calcom payment

* include logo and images

* resolve comments

* include USD and webhook cleaning

* currency display

* fix type error

* payment service create error

* type error fix

* icon update

* bot feedback update

* Remove console

* Remove currency suffix in price

* fix coderRabbit comment

* resolve extra comments

* Use repositories and declarative installation ocode for app

* use PrismaBookingPaymentRepository as well as fix UI view

* Avoid fetching booking just for title which is already passed to create fn in handlePayment

* fix type issues

* return 200 if payment is already processed

---------

Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Omar López <zomars@me.com>
2025-07-29 16:08:19 +00:00

49 lines
1.2 KiB
TypeScript

import type { PrismaClient } from "@calcom/prisma";
import prisma from "@calcom/prisma";
import type {
IBookingPaymentRepository,
BookingPaymentWithCredentials,
CreatePaymentData,
} from "./BookingPaymentRepository.interface";
export class PrismaBookingPaymentRepository implements IBookingPaymentRepository {
constructor(private readonly prismaClient: PrismaClient = prisma) {}
async findByExternalIdIncludeBookingUserCredentials(
externalId: string,
credentialType: string
): Promise<BookingPaymentWithCredentials | null> {
return await this.prismaClient.payment.findFirst({
where: {
externalId,
},
select: {
id: true,
amount: true,
success: true,
bookingId: true,
booking: {
select: {
user: {
select: {
credentials: {
where: { type: credentialType },
select: { key: true },
},
},
},
},
},
},
});
}
async createPaymentRecord(data: CreatePaymentData) {
const createdPayment = await this.prismaClient.payment.create({
data,
});
return createdPayment;
}
}