diff --git a/advertise.html b/advertise.html index f1e91c03..433f63ad 100644 --- a/advertise.html +++ b/advertise.html @@ -81,8 +81,8 @@

Payment received, thanks. - We review every ad and usually put it live within two business - days. To change anything, email + We review every ad and put it live within 24 hours. To change + anything, email

Go live

- We review every ad by hand and usually put it live within two - business days. Need a new logo or link later? Just email us. + We review every ad by hand and put it live within 24 hours. Need + a new logo or link later? Just email us.

diff --git a/api/ad-checkout.js b/api/ad-checkout.js index d4de19b1..8f28b823 100644 --- a/api/ad-checkout.js +++ b/api/ad-checkout.js @@ -1,9 +1,19 @@ -const DODO_API = 'https://test.dodopayments.com'; - -const PRODUCTS = new Map([ - ['top', 'pdt_0Nqt0672sYJEtrkIb2K6m'], - ['second', 'pdt_0Nqt069LgdQFPo1tFS1yF'], -]); +const MODES = { + live: { + api: 'https://live.dodopayments.com', + products: new Map([ + ['top', 'pdt_0Nqv9McKI1iCBXb7z4DB7'], + ['second', 'pdt_0Nqv9OYDLwWZsu1hzpZ0c'], + ]), + }, + test: { + api: 'https://test.dodopayments.com', + products: new Map([ + ['top', 'pdt_0Nqt0672sYJEtrkIb2K6m'], + ['second', 'pdt_0Nqt069LgdQFPo1tFS1yF'], + ]), + }, +}; const FIELDS = [ { @@ -36,11 +46,11 @@ function redirect(location) { }); } -async function createCheckout(productId, page) { - const response = await fetch(`${DODO_API}/checkouts`, { +async function createCheckout(key, api, productId, page) { + const response = await fetch(`${api}/checkouts`, { method: 'POST', headers: { - Authorization: `Bearer ${process.env.DODO_PAYMENTS_API_KEY}`, + Authorization: `Bearer ${key}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ @@ -60,7 +70,7 @@ async function createCheckout(productId, page) { typeof checkout_url !== 'string' || !checkout_url.startsWith('https://') ) { - throw new Error(`Dodo returned no checkout URL: ${body}`); + throw new Error('Dodo returned no checkout URL'); } return checkout_url; } @@ -68,11 +78,13 @@ async function createCheckout(productId, page) { export async function GET(request) { const url = new URL(request.url); const page = `${url.origin}/advertise`; - const productId = PRODUCTS.get(url.searchParams.get('row')); + const key = process.env.DODO_PAYMENTS_API_KEY ?? ''; + const mode = key.startsWith('dodo_live_') ? MODES.live : MODES.test; + const productId = mode.products.get(url.searchParams.get('row')); if (!productId) return redirect(`${page}#pricing`); try { - return redirect(await createCheckout(productId, page)); + return redirect(await createCheckout(key, mode.api, productId, page)); } catch (error) { console.error(error); return redirect(`${page}?checkout=failed`); diff --git a/index.html b/index.html index 34b4d73f..cb4a5b92 100644 --- a/index.html +++ b/index.html @@ -348,6 +348,7 @@ + {{#if showAds}}
- - Acme Invoices + + NVIDIA - - Globex Mail + + Vercel - - Initech Notes + + Your logo here + + Your logo here + + - - Hooli Sign + + DigitalOcean - - - Umbrella VPN - - - - Stark Backup + + + Your logo here Your logo here -

- Ads are plain logos and links. No tracking pixels, no scripts, no - pop-ups. -

+ {{/if}}
Version {{appVersion}}

- - DigitalOcean Referral Badge -
diff --git a/vite.config.ts b/vite.config.ts index a39a8d9c..ea9c9dc0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -685,6 +685,11 @@ export default defineConfig(({ command }) => { (command === 'serve' || process.env.INCLUDE_DOCS === 'true') ? '/docs/' : 'https://www.bentopdf.com/docs'; + const showAds = + command === 'serve' || + ['bentopdf.com', 'www.bentopdf.com'].includes( + process.env.VERCEL_PROJECT_PRODUCTION_URL ?? '' + ); if (USE_CDN) { console.log('[Vite] Using CDN for WASM files (with local fallback)'); @@ -709,6 +714,7 @@ export default defineConfig(({ command }) => { brandLogo: process.env.VITE_BRAND_LOGO || '', footerText: process.env.VITE_FOOTER_TEXT || '', appVersion: process.env.npm_package_version || 'Unknown', + showAds, }, }), languageRouterPlugin(), @@ -804,7 +810,9 @@ export default defineConfig(({ command }) => { licensing: resolve(__dirname, 'licensing.html'), kura: resolve(__dirname, 'kura.html'), 'hyper-compress': resolve(__dirname, 'hyper-compress.html'), - advertise: resolve(__dirname, 'advertise.html'), + ...(showAds + ? { advertise: resolve(__dirname, 'advertise.html') } + : {}), ...Object.fromEntries( fs .readdirSync(resolve(__dirname, 'blog'))