reposted with update b/c im still facing the same error
I have my paywall in production (with a custom domain not using localhost) that uses a login redirect to go through but i don’t know how to properly continue the login flow and log the user in after calling the continue state
i get redirected right now to a /continue route after the redirection to /continue that isn’t an error page but there is a network error and i get redirected to an empty page of my site with the footer at the bottom
here is how my user is redirected to the /continue route and the continue action
checkout.tsx:
import React from 'react';
import { useAuth0 } from '@auth0/auth0-react';
import Stripe from 'stripe';
import queryString from 'query-string';
import jwt, { JwtPayload } from 'jsonwebtoken'; // Import the JWT library
const stripe = new Stripe('rk_test_51NOmOvHwLkK28gsPFWpd2flfcAWf9f2yvMTpB7D3m2s0rAFc21CIEPwtRS9Uz0NqfieZ5MY7xcAYgCuNCIzbzrYE004d5XPiyV', {
apiVersion: '2022-11-15',
});
const Checkout = () => {
const sessionToken = ***********************
const { user } = useAuth0();
//const [customerId, setCustomerId] = useState(null);
//const customerId = user?.app_metadata?.stripe_customer_id;
//console.log(customerId)
const priceId = '**********'
const successUrl = 'https://www.**************.com/continue'
const cancelUrl = 'https://www.*****************.com/about'
async function createCheckoutSession() {
// Parse the URL to get state and redirect_uri
const parsedUrl = queryString.parse(window.location.search);
const sessionToken = parsedUrl.session_token;
const customerId = parsedUrl.customerId;
const redirectUri = parsedUrl.redirect_uri;
// Check if the state and redirectUri exist
if (sessionToken && redirectUri) {
// Create the checkout session with state in the success_url
const session = await stripe.checkout.sessions.create({
customer: user?.app_metadata?.stripe_customer_id,
payment_method_types: ['card'],
line_items: [{ price: priceId, quantity: 1 }],
mode: 'subscription',
success_url: `${redirectUri}?session_token=${sessionToken}`,
cancel_url: cancelUrl,
});
if (session.url) {
window.location.href = session.url; // Redirect to Stripe checkout page
}
};
}
return (
<div>
<br></br><br></br><br></br>
{/* Render your component's content */}
<button onClick={createCheckoutSession}>Checkout for our ECOmium Plan!</button>
</div>
);
};
export default Checkout;
I’ve even taken feedback b4 to remove everything from the continue function to continue the login but nothing still happens
exports.onContinuePostLogin = async (event, api) => {
/*
try {
let decodedToken;
decodedToken = api.redirect.validateToken({
secret: event.secrets.NEW_STATE,
tokenParameterName: 'session_token',
});
} catch (error) {
// console.log(error.message);
return api.access.deny('Error occurred during redirect.');
}
*/
};
is there any reason this could be going wrong?