Custom Registration Component
Build a custom React component that calls your backend API after payment to handle user registration and account setup.
The Problem
How It Works
Example
import { tracker } from "@tracker";
import { useVariable } from "@variables";
import { useFunnelRouter } from "@primitives";
import { useState } from "react";
export default function RegisterAndOpenApp() {
const funnelRouter = useFunnelRouter();
// Zellify variables (available after payment)
const [email] = useVariable("email");
const [stripeCustomerId] = useVariable("_stripeCustomerId");
const [stripeCheckoutSessionId] = useVariable("_stripeCheckoutSessionId");
// Session identifier (same as app_user_id in payment metadata)
const appUserId = tracker.sessionId;
const [loading, setLoading] = useState(false);
const handleRegister = async () => {
setLoading(true);
// 1. Call your backend to create the user account
const res = await fetch("https://api.yourapp.com/register", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
app_user_id: appUserId,
email: email,
stripe_customer_id: stripeCustomerId,
stripe_checkout_session_id: stripeCheckoutSessionId,
}),
});
const { token } = await res.json();
// 2. Redirect to your app with credentials
const params = new URLSearchParams({
token: token,
user_id: appUserId,
});
funnelRouter.openExternal(`https://yourapp.onelink.me/abc?${params}`);
};
return (
<button onClick={handleRegister} disabled={loading}>
{loading ? "Setting up..." : "Open App"}
</button>
);
}What Zellify Provides
Import
What it provides
What You Need to Set Up
1. Build your backend endpoint
2. Create the custom component in Zellify
3. Handle the redirect
The Linking Key
Related
Last updated

