mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* chore: migrate payments page * migrate page to WithLayout HOC, replace new ssrInit * fix type error * fix * revert version changes * fix --------- Co-authored-by: Benny Joo <[email protected]>
22 lines
658 B
TypeScript
22 lines
658 B
TypeScript
import type { Payment } from "@calcom/prisma/client";
|
|
|
|
function hasStringProp<T extends string>(x: unknown, key: T): x is { [key in T]: string } {
|
|
return !!x && typeof x === "object" && key in x;
|
|
}
|
|
|
|
export function getClientSecretFromPayment(
|
|
payment: Omit<Partial<Payment>, "data"> & { data: Record<string, unknown> }
|
|
) {
|
|
if (
|
|
payment.paymentOption === "HOLD" &&
|
|
hasStringProp(payment.data, "setupIntent") &&
|
|
hasStringProp(payment.data.setupIntent, "client_secret")
|
|
) {
|
|
return payment.data.setupIntent.client_secret;
|
|
}
|
|
if (hasStringProp(payment.data, "client_secret")) {
|
|
return payment.data.client_secret;
|
|
}
|
|
return "";
|
|
}
|