1.1.10
Good to know
Please check the
version
field in thepackage.json
file for the version number
Affiliate Integration
Before updating the code, please read the Affiliate integration steps first, complete registration and obtain the Affiliate ID.
Step 1: Add the app/ToltScript.tsx
file
Please copy directly from the source repository
Step 2: Import the ToltScript
component in app/[locale]/layout.tsx
<head>
{process.env.NODE_ENV === "development" ? (
<></>
) : (
<>
<ToltScript />
</>
)}
</head>
Step 3: Modify components/home/PricingCTA.tsx
to pass the referral
parameter to checkout-session
const handleCheckout = async () => {
// ...other code...
try {
const toltReferral = (window as any).tolt_referral;
const requestBody: {
priceId: string;
couponCode?: string;
referral?: string;
} = {
priceId: stripePriceId,
};
if (toltReferral) {
requestBody.referral = toltReferral;
}
const response = await fetch("/api/stripe/checkout-session", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept-Language": (locale || DEFAULT_LOCALE) as string,
},
body: JSON.stringify(requestBody),
});
// ...other code...
} catch (error) {
// ...other code...
}
};
Step 4: Modify app/api/stripe/checkout-session/route.ts
to receive the referral
parameter and pass it to
type RequestData = {
priceId: string;
couponCode?: string;
referral?: string; // add
};
// const { priceId, couponCode } = requestData; // remove
const { priceId, couponCode, referral } = requestData; // add
const sessionParams: Stripe.Checkout.SessionCreateParams = {
// ...other code...
metadata: {
userId: userId,
planId: plan.id,
planName: plan.card_title,
priceId: priceId,
...(referral && { tolt_referral: referral }), // add
},
}
Step 5: Modify components/BuiltWithButton.tsx
to use the Nexty Affiliate link
Register for Nexty Affiliate, then modify the link in BuiltWithButton
to your created Affiliate link, so you can start earning commissions.