"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const uuid = require("uuid");
const index = require("./i18n-Bs8xJzoY.cjs");
class PaymentService {
  async create(payment, bookingId) {
    try {
      const booking = await index.prisma.booking.findUnique({
        select: {
          uid: true,
          title: true
        },
        where: {
          id: bookingId
        }
      });
      if (booking === null) {
        throw new Error("Booking not found");
      }
      const uid = uuid.v4();
      console.log("CREATE payment");
      const paymentData = await index.prisma.payment.create({
        data: {
          uid,
          app: {
            connect: {
              slug: "mock-payment-app"
            }
          },
          booking: {
            connect: {
              id: bookingId
            }
          },
          amount: payment.amount,
          externalId: uid,
          currency: payment.currency,
          data: {},
          fee: 0,
          refunded: false,
          success: false
        }
      });
      return paymentData;
    } catch (error) {
      console.error(error);
      throw new Error("Payment could not be created");
    }
  }
  async update() {
    throw new Error("Method not implemented.");
  }
  async refund() {
    throw new Error("Method not implemented.");
  }
  async collectCard(payment, bookingId, _bookerEmail, paymentOption) {
    try {
      const booking = await index.prisma.booking.findUnique({
        select: {
          uid: true,
          title: true
        },
        where: {
          id: bookingId
        }
      });
      if (booking === null) {
        throw new Error("Booking not found");
      }
      const uid = uuid.v4();
      const paymentData = await index.prisma.payment.create({
        data: {
          uid,
          app: {
            connect: {
              slug: "paypal"
            }
          },
          booking: {
            connect: {
              id: bookingId
            }
          },
          amount: payment.amount,
          currency: payment.currency,
          data: {},
          fee: 0,
          refunded: false,
          success: false,
          paymentOption,
          externalId: ""
        }
      });
      if (!paymentData) {
        throw new Error();
      }
      return paymentData;
    } catch (error) {
      console.error(error);
      throw new Error("Payment could not be created");
    }
  }
  chargeCard() {
    throw new Error("Method not implemented.");
  }
  getPaymentPaidStatus() {
    throw new Error("Method not implemented.");
  }
  getPaymentDetails() {
    throw new Error("Method not implemented.");
  }
  afterPayment() {
    return Promise.resolve();
  }
  deletePayment() {
    return Promise.resolve(false);
  }
  isSetupAlready() {
    return true;
  }
}
exports.PaymentService = PaymentService;
