feat: refund policies for payment apps (#18428)
* feat: refund policies for payment apps * tests for payment refund --------- Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
1 parent
e722e75a6f
commit
c1dbb7cffd
23 files changed
+559
-85
No files matched your search
@@ -24,7 +24,7 @@ import type {
|
||||
WorkflowTriggerEvents,
|
||||
WorkflowMethods,
|
||||
} from "@calcom/prisma/client";
|
||||
import type { SchedulingType, SMSLockState, TimeUnit } from "@calcom/prisma/enums";
|
||||
import type { PaymentOption, SchedulingType, SMSLockState, TimeUnit } from "@calcom/prisma/enums";
|
||||
import type { BookingStatus } from "@calcom/prisma/enums";
|
||||
import type { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
import type { userMetadataType } from "@calcom/prisma/zod-utils";
|
||||
@@ -74,6 +74,21 @@ type InputWorkflow = {
|
||||
sendTo?: string;
|
||||
};
|
||||
|
||||
type InputPayment = {
|
||||
id?: number;
|
||||
uid: string;
|
||||
appId?: string | null;
|
||||
bookingId: number;
|
||||
amount: number;
|
||||
fee: number;
|
||||
currency: string;
|
||||
success: boolean;
|
||||
refunded: boolean;
|
||||
data: Record<string, any>;
|
||||
externalId: string;
|
||||
paymentOption?: PaymentOption;
|
||||
};
|
||||
|
||||
type InputWorkflowReminder = {
|
||||
id?: number;
|
||||
bookingUid: string;
|
||||
@@ -108,6 +123,7 @@ export type ScenarioData = {
|
||||
bookings?: InputBooking[];
|
||||
webhooks?: InputWebhook[];
|
||||
workflows?: InputWorkflow[];
|
||||
payment?: InputPayment[];
|
||||
};
|
||||
|
||||
type InputCredential = typeof TestData.credentials.google & {
|
||||
@@ -535,6 +551,12 @@ async function addWebhooksToDb(webhooks: any[]) {
|
||||
});
|
||||
}
|
||||
|
||||
async function addPaymentToDb(payment: InputPayment[]) {
|
||||
await prismock.payment.createMany({
|
||||
data: payment,
|
||||
});
|
||||
}
|
||||
|
||||
async function addWebhooks(webhooks: InputWebhook[]) {
|
||||
log.silly("TestData: Creating Webhooks", safeStringify(webhooks));
|
||||
|
||||
@@ -810,6 +832,7 @@ export async function createBookingScenario(data: ScenarioData) {
|
||||
await addWebhooks(data.webhooks || []);
|
||||
// addPaymentMock();
|
||||
const workflows = await addWorkflows(data.workflows || []);
|
||||
await addPaymentToDb(data.payment || []);
|
||||
|
||||
return {
|
||||
eventTypes,
|
||||
@@ -1304,6 +1327,7 @@ export function getScenarioData(
|
||||
webhooks,
|
||||
workflows,
|
||||
bookings,
|
||||
payment,
|
||||
}: {
|
||||
organizer?: ReturnType<typeof getOrganizer>;
|
||||
eventTypes: ScenarioData["eventTypes"];
|
||||
@@ -1313,6 +1337,7 @@ export function getScenarioData(
|
||||
webhooks?: ScenarioData["webhooks"];
|
||||
workflows?: ScenarioData["workflows"];
|
||||
bookings?: ScenarioData["bookings"];
|
||||
payment?: ScenarioData["payment"];
|
||||
},
|
||||
org?: { id: number | null } | undefined | null
|
||||
) {
|
||||
@@ -1373,6 +1398,7 @@ export function getScenarioData(
|
||||
webhooks,
|
||||
bookings: bookings || [],
|
||||
workflows,
|
||||
payment,
|
||||
} satisfies ScenarioData;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user