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:
@@ -259,6 +259,10 @@ async function migrate() {
|
||||
id TEXT PRIMARY KEY,
|
||||
tpago_enabled INTEGER NOT NULL DEFAULT 0,
|
||||
tpago_link TEXT,
|
||||
tpago_link_2 TEXT,
|
||||
tpago_link_3 TEXT,
|
||||
tpago_link_4 TEXT,
|
||||
tpago_link_5 TEXT,
|
||||
tpago_instructions TEXT,
|
||||
tpago_instructions_es TEXT,
|
||||
bank_transfer_enabled INTEGER NOT NULL DEFAULT 0,
|
||||
@@ -283,6 +287,13 @@ async function migrate() {
|
||||
await (db as any).run(sql`ALTER TABLE payment_options ADD COLUMN allow_duplicate_bookings INTEGER NOT NULL DEFAULT 0`);
|
||||
} catch (e) { /* column may already exist */ }
|
||||
|
||||
// Add per-quantity TPago link columns to payment_options if they don't exist
|
||||
for (const col of ['tpago_link_2', 'tpago_link_3', 'tpago_link_4', 'tpago_link_5']) {
|
||||
try {
|
||||
await (db as any).run(sql.raw(`ALTER TABLE payment_options ADD COLUMN ${col} TEXT`));
|
||||
} catch (e) { /* column may already exist */ }
|
||||
}
|
||||
|
||||
// Event payment overrides table
|
||||
await (db as any).run(sql`
|
||||
CREATE TABLE IF NOT EXISTS event_payment_overrides (
|
||||
@@ -290,6 +301,10 @@ async function migrate() {
|
||||
event_id TEXT NOT NULL REFERENCES events(id),
|
||||
tpago_enabled INTEGER,
|
||||
tpago_link TEXT,
|
||||
tpago_link_2 TEXT,
|
||||
tpago_link_3 TEXT,
|
||||
tpago_link_4 TEXT,
|
||||
tpago_link_5 TEXT,
|
||||
tpago_instructions TEXT,
|
||||
tpago_instructions_es TEXT,
|
||||
bank_transfer_enabled INTEGER,
|
||||
@@ -309,6 +324,13 @@ async function migrate() {
|
||||
)
|
||||
`);
|
||||
|
||||
// Add per-quantity TPago link columns to event_payment_overrides if they don't exist
|
||||
for (const col of ['tpago_link_2', 'tpago_link_3', 'tpago_link_4', 'tpago_link_5']) {
|
||||
try {
|
||||
await (db as any).run(sql.raw(`ALTER TABLE event_payment_overrides ADD COLUMN ${col} TEXT`));
|
||||
} catch (e) { /* column may already exist */ }
|
||||
}
|
||||
|
||||
await (db as any).run(sql`
|
||||
CREATE TABLE IF NOT EXISTS contacts (
|
||||
id TEXT PRIMARY KEY,
|
||||
@@ -702,6 +724,10 @@ async function migrate() {
|
||||
id UUID PRIMARY KEY,
|
||||
tpago_enabled INTEGER NOT NULL DEFAULT 0,
|
||||
tpago_link VARCHAR(500),
|
||||
tpago_link_2 VARCHAR(500),
|
||||
tpago_link_3 VARCHAR(500),
|
||||
tpago_link_4 VARCHAR(500),
|
||||
tpago_link_5 VARCHAR(500),
|
||||
tpago_instructions TEXT,
|
||||
tpago_instructions_es TEXT,
|
||||
bank_transfer_enabled INTEGER NOT NULL DEFAULT 0,
|
||||
@@ -726,12 +752,23 @@ async function migrate() {
|
||||
await (db as any).execute(sql`ALTER TABLE payment_options ADD COLUMN allow_duplicate_bookings INTEGER NOT NULL DEFAULT 0`);
|
||||
} catch (e) { /* column may already exist */ }
|
||||
|
||||
// Add per-quantity TPago link columns to payment_options if they don't exist
|
||||
for (const col of ['tpago_link_2', 'tpago_link_3', 'tpago_link_4', 'tpago_link_5']) {
|
||||
try {
|
||||
await (db as any).execute(sql.raw(`ALTER TABLE payment_options ADD COLUMN ${col} VARCHAR(500)`));
|
||||
} catch (e) { /* column may already exist */ }
|
||||
}
|
||||
|
||||
await (db as any).execute(sql`
|
||||
CREATE TABLE IF NOT EXISTS event_payment_overrides (
|
||||
id UUID PRIMARY KEY,
|
||||
event_id UUID NOT NULL REFERENCES events(id),
|
||||
tpago_enabled INTEGER,
|
||||
tpago_link VARCHAR(500),
|
||||
tpago_link_2 VARCHAR(500),
|
||||
tpago_link_3 VARCHAR(500),
|
||||
tpago_link_4 VARCHAR(500),
|
||||
tpago_link_5 VARCHAR(500),
|
||||
tpago_instructions TEXT,
|
||||
tpago_instructions_es TEXT,
|
||||
bank_transfer_enabled INTEGER,
|
||||
@@ -751,6 +788,13 @@ async function migrate() {
|
||||
)
|
||||
`);
|
||||
|
||||
// Add per-quantity TPago link columns to event_payment_overrides if they don't exist
|
||||
for (const col of ['tpago_link_2', 'tpago_link_3', 'tpago_link_4', 'tpago_link_5']) {
|
||||
try {
|
||||
await (db as any).execute(sql.raw(`ALTER TABLE event_payment_overrides ADD COLUMN ${col} VARCHAR(500)`));
|
||||
} catch (e) { /* column may already exist */ }
|
||||
}
|
||||
|
||||
await (db as any).execute(sql`
|
||||
CREATE TABLE IF NOT EXISTS contacts (
|
||||
id UUID PRIMARY KEY,
|
||||
|
||||
Reference in New Issue
Block a user