Add per-quantity TPago payment links for multi-ticket checkout.
Each ticket quantity (1-5) can have its own TPago link so checkout, emails, and admin config use the correct fixed-amount URL.
This commit is contained in:
@@ -559,6 +559,7 @@ export interface Event {
|
||||
export interface Ticket {
|
||||
id: string;
|
||||
bookingId?: string; // Groups multiple tickets from same booking
|
||||
bookingTicketCount?: number; // Total tickets in the booking (for per-quantity payment links)
|
||||
userId: string;
|
||||
eventId: string;
|
||||
attendeeFirstName: string;
|
||||
@@ -673,6 +674,10 @@ export interface PaymentWithDetails extends Payment {
|
||||
export interface PaymentOptionsConfig {
|
||||
tpagoEnabled: boolean;
|
||||
tpagoLink?: string | null;
|
||||
tpagoLink2?: string | null;
|
||||
tpagoLink3?: string | null;
|
||||
tpagoLink4?: string | null;
|
||||
tpagoLink5?: string | null;
|
||||
tpagoInstructions?: string | null;
|
||||
tpagoInstructionsEs?: string | null;
|
||||
bankTransferEnabled: boolean;
|
||||
|
||||
@@ -165,3 +165,31 @@ export function formatPrice(price: number, currency: string = 'PYG'): string {
|
||||
export function formatCurrency(amount: number, currency: string = 'PYG'): string {
|
||||
return formatPrice(amount, currency);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Payment helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
type TpagoLinkConfig = {
|
||||
tpagoLink?: string | null;
|
||||
tpagoLink2?: string | null;
|
||||
tpagoLink3?: string | null;
|
||||
tpagoLink4?: string | null;
|
||||
tpagoLink5?: string | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Select the TPago payment link that matches the number of tickets being
|
||||
* purchased (1-5). Each link has a fixed amount baked in, so the quantity
|
||||
* determines which one to use. Falls back to the base (1-ticket) link when a
|
||||
* specific quantity link isn't configured.
|
||||
*/
|
||||
export function getTpagoLink(
|
||||
config: TpagoLinkConfig | null | undefined,
|
||||
ticketCount: number
|
||||
): string | null {
|
||||
if (!config) return null;
|
||||
const count = Math.min(Math.max(1, Math.floor(ticketCount || 1)), 5);
|
||||
const key = (count <= 1 ? 'tpagoLink' : `tpagoLink${count}`) as keyof TpagoLinkConfig;
|
||||
return config[key] || config.tpagoLink || null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user