Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

custom payment page

Blue Mouse295a0e4a1d24
diff --git a/web/.env.example b/web/.env.example
index d56fecfc8..ede025e14 100644
--- a/web/.env.example
+++ b/web/.env.example
@@ -2,4 +2,5 @@ API_URL=https://api.swetrix.com/
API_STAGING_URL=http://localhost:5005/
CDN_URL=https://cdn.swetrix.com/
AIAPI_URL=https://aiapi.swetrix.com/
-REDIS_URL=redis://default:[email protected]
+
+PADDLE_CLIENT_SIDE_TOKEN=
diff --git a/web/app/root.tsx b/web/app/root.tsx
index afd393afe..f30e3418e 100644
--- a/web/app/root.tsx
+++ b/web/app/root.tsx
@@ -14,6 +14,7 @@ import {
} from '@remix-run/react'
import { store } from 'redux/store'
import { isBrowser, CONTACT_EMAIL, LS_THEME_SETTING, isSelfhosted, I18N_CACHE_BREAKER } from 'redux/constants'
+import { ExternalScripts } from 'remix-utils/external-scripts'
import { getCookie, generateCookieString } from 'utils/cookie'
import { ExclamationTriangleIcon, ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'
import { Provider } from 'react-redux'
@@ -191,6 +192,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
CDN_URL: process.env.CDN_URL,
SELFHOSTED: process.env.SELFHOSTED,
STAGING: process.env.STAGING,
+ PADDLE_CLIENT_SIDE_TOKEN: process.env.PADDLE_CLIENT_SIDE_TOKEN,
}
const init = storeThemeToCookie
@@ -267,6 +269,7 @@ export default function App() {
<AppWrapper ssrTheme={theme} ssrAuthenticated={isAuthed} />
</Provider>
<ScrollRestoration />
+ <ExternalScripts />
<Scripts />
<LiveReload />
</body>
diff --git a/web/app/routes/pay.tsx b/web/app/routes/pay.tsx
new file mode 100644
index 000000000..f1f3c8854
--- /dev/null
+++ b/web/app/routes/pay.tsx
@@ -0,0 +1,50 @@
+import { useEffect } from 'react'
+import type { SitemapFunction } from 'remix-sitemap'
+import { ExternalScriptsHandle } from 'remix-utils/external-scripts'
+
+export const sitemap: SitemapFunction = () => ({
+ priority: 0.9,
+})
+
+export let handle: ExternalScriptsHandle = {
+ scripts: [
+ {
+ src: 'https://cdn.paddle.com/paddle/v2/paddle.js',
+ preload: true, // use it to render a <link rel="preload"> for this script
+ },
+ ],
+}
+
+export default function Index() {
+ useEffect(() => {
+ if (!window.REMIX_ENV?.PADDLE_CLIENT_SIDE_TOKEN) {
+ return
+ }
+
+ const initializePaddle = () => {
+ if (window.Paddle) {
+ window.Paddle.Initialize({
+ token: window.REMIX_ENV?.PADDLE_CLIENT_SIDE_TOKEN,
+ })
+ return true
+ }
+ return false
+ }
+
+ const interval = setInterval(() => {
+ if (initializePaddle()) {
+ clearInterval(interval)
+ }
+ }, 500)
+
+ return () => clearInterval(interval)
+ }, [])
+
+ return (
+ <div className='min-h-page bg-gray-50 dark:bg-slate-900'>
+ <div className='mx-auto w-11/12 px-4 pb-16 pt-12 sm:px-6 md:w-4/5 lg:px-8'>
+ <h1 className='text-4xl font-bold tracking-tight text-gray-900 dark:text-gray-50'>Swetrix Payment</h1>
+ </div>
+ </div>
+ )
+}