#beninagata
1 messages · Page 1 of 1 (latest)
Hello beninagata, we'll be with you shortly! Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
• beninagata, 13 hours ago, 6 messages
The value of success_url and cancel_url is not a valid URL. It should be something like https://...
import { auth, currentUser } from "@clerk/nextjs";
import { NextResponse } from "next/server";
import prismadb from "@/lib/prismadb";
import { stripe } from "@/lib/stripe";
import { absoluteUrl } from "@/lib/utils";
const settingsUrl = absoluteUrl("/settings");
export async function GET(){
try {
const { userId } = auth();
const user = await currentUser();
if(!userId || !user){
return new NextResponse("Unauthorized", {status: 401});
}
const userSubscription = await prismadb.userSubscription.findUnique({
where: {
userId
}
});
if( userSubscription && userSubscription.stripeCustomerId){
const stripeSession = await stripe.billingPortal.sessions.create({
customer: userSubscription.stripeCustomerId,
return_url: settingsUrl,
});
return new NextResponse(JSON.stringify({url: stripeSession.url}));
}
const stripeSession = await stripe.checkout.sessions.create({
success_url: settingsUrl,
cancel_url: settingsUrl,
payment_method_types: ["card"],
mode: "subscription",
billing_address_collection: "auto",
customer_email:user.emailAddresses[0].emailAddress,
line_items:[
{
price_data:{
currency: "MYR",
product_data:{
name: "Genius Pro",
description: "Unlimited AI Generation"
},
unit_amount: 2000,
recurring:{
interval: "month"
}
},
quantity: 1,
}
],
metadata:{
userId,
},
});
return new NextResponse(JSON.stringify({url: stripeSession.url}));
} catch (error){
console.log("[STRIPE_ERROR]", error);
return new NextResponse("Internal error", {status: 500});
}
}
the /settings change to https.//settings?
No! success_url and cancel_url should be a valid URL on your server. It should be something like https://{your-domain}/{path}
No problem! Happy to help 😄
still not working
What is not working? Did you set to proper HTTPS URL?
Can you share the request ID (req_xxx)? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
yup
Please share the request ID (req_xxx) of the error