Files
calendar/apps/web/playwright/fixtures/payments.ts
T
2f628a17df feat/payment-service-6438-cal-767 (#6677)
* WIP paymentService

* Changes for payment Service

* Fix for stripe payment flow

* Remove logs/comments

* Refactored refund for stripe app

* Move stripe handlePayment to own lib

* Move stripe delete payments to paymentService

* lint fix

* Change handleRefundError as generic function

* remove log

* remove logs

* remove logs

* Return stripe default export to lib/server

* Fixing types

* Fix types

* Upgrades typescript

* Update yarn lock

* Typings

* Hotfix: ping,riverside,whereby and around not showing up in list (#6712)

* Hotfix: ping,riverside,whereby and around not showing up in list (#6712) (#6713)

* Adds deployment settings to DB (#6706)

* WIP

* Adds DeploymentTheme

* Add missing migrations

* Adds client extensions for deployment

* Cleanup

* Revert "lint fix"

This reverts commit e1a2e4a357e58e6673c47399888ae2e00d1351a6.

* Add validation

* Revert changes removed in force push

* Removing abstract class and just leaving interface implementation

* Fix types for handlePayments

* Fix payment test appStore import

* Fix stripe metadata in event type

* Move migration to separate PR

* Revert "Move migration to separate PR"

This reverts commit 48aa64e0724a522d3cc2fefaaaee5792ee9cd9e6.

* Update packages/prisma/migrations/20230125175109_remove_type_from_payment_and_add_app_relationship/migration.sql

Co-authored-by: Omar López <zomars@me.com>

---------

Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
2023-02-08 13:36:22 -07:00

64 lines
1.9 KiB
TypeScript

import type { Page } from "@playwright/test";
import type { Payment } from "@prisma/client";
import { v4 as uuidv4 } from "uuid";
import { prisma } from "@calcom/prisma";
type PaymentFixture = ReturnType<typeof createPaymentFixture>;
// creates a user fixture instance and stores the collection
export const createPaymentsFixture = (page: Page) => {
const store = { payments: [], page } as { payments: PaymentFixture[]; page: typeof page };
return {
create: async (
bookingId: number,
{ success = false, refunded = false }: { success?: boolean; refunded?: boolean } = {}
) => {
const payment = await prisma.payment.create({
data: {
uid: uuidv4(),
amount: 20000,
fee: 160,
currency: "usd",
success,
refunded,
app: {
connect: {
slug: "stripe",
},
},
data: {},
externalId: "DEMO_PAYMENT_FROM_DB_" + Date.now(),
booking: {
connect: {
id: bookingId,
},
},
},
});
const paymentFixture = createPaymentFixture(payment, store.page!);
store.payments.push(paymentFixture);
return paymentFixture;
},
get: () => store.payments,
delete: async (id: number) => {
await prisma.payment.delete({
where: { id },
});
store.payments = store.payments.filter((b) => b.id !== id);
},
};
};
// creates the single user fixture
const createPaymentFixture = (payment: Payment, page: Page) => {
const store = { payment, page };
// self is a reflective method that return the Prisma object that references this fixture.
return {
id: store.payment.id,
self: async () => (await prisma.payment.findUnique({ where: { id: store.payment.id } }))!,
delete: async () => (await prisma.payment.delete({ where: { id: store.payment.id } }))!,
};
};