#sadegh-akbari_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1339183430155636830
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi there!
hi
you need to check your browser console or backend server log to get a full error message.
full error is this => message
:
"We're sorry, but we're unable to serve your request."
this error return from stripe
i using stripe in my nextjs backend
try {
const { priceId } = await req.json();
const customer = await stripe.customers.create();
// Create a subscription
const subscription = await stripe.subscriptions.create({
customer: customer.id,
items: [{ price: priceId }],
payment_behavior: "default_incomplete",
// payment_behavior: "error_if_incomplete",
expand: ["latest_invoice", "latest_invoice.payment_intent"],
// trial_period_days: 3,
});
const latestInvoice = subscription.latest_invoice as Stripe.Invoice;
const clientSecret = latestInvoice.payment_intent
? (latestInvoice.payment_intent as Stripe.PaymentIntent).client_secret
: null;
return NextResponse.json({
subscriptionDetails: subscription,
subscriptionId: subscription.id,
clientSecret,
});
} catch (error) {
return NextResponse.json(
{ message: error instanceof Error ? error.message : "Something went wrong" },
{ status: 400 }
);
}
}```
in localhost worked correctly but in production given this error
"We're sorry, but we're unable to serve your request."
can you share more details? you made an API request and this was returned by Stripe? which API request you amde exactly?
that error comes from your backend. so can you check your backend logs to check the exact issue?
this error return in my catch, catch returned stripe error
import Stripe from "stripe";
const stripe = new Stripe(process.env.NEXT_PUBLIC_STRIPE_SECRET_KEY as string, {
apiVersion: "2024-04-10" as any,
});
export async function POST(req: Request) {
try {
const { priceId } = await req.json();
const customer = await stripe.customers.create();
// Create a subscription
const subscription = await stripe.subscriptions.create({
customer: customer.id,
items: [{ price: priceId }],
payment_behavior: "default_incomplete",
// payment_behavior: "error_if_incomplete",
expand: ["latest_invoice", "latest_invoice.payment_intent"],
// trial_period_days: 3,
});
const latestInvoice = subscription.latest_invoice as Stripe.Invoice;
const clientSecret = latestInvoice.payment_intent
? (latestInvoice.payment_intent as Stripe.PaymentIntent).client_secret
: null;
return NextResponse.json({
subscriptionDetails: subscription,
subscriptionId: subscription.id,
clientSecret,
});
} catch (error) {
return NextResponse.json(
{ message: error instanceof Error ? error.message : "Something went wrong" },
{ status: 400 }
);
}
}
please see up code
please share the exact line that is returning the error. I don't need your full code.
// Create a subscription
const subscription = await stripe.subscriptions.create({
customer: customer.id,
items: [{ price: priceId }],
payment_behavior: "default_incomplete",
expand: ["latest_invoice", "latest_invoice.payment_intent"],
});```
so that API call returns an error from Stripe? if so, can you share the request ID (req_xxx)? you can find it here https://dashboard.stripe.com/test/logs
please wait
i using live api key
i must get this https://dashboard.stripe.com/test/logs?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
???
I don't understand your question. if you are in live mode, then share a livemode request.
ok please wait ๐
Where did you find that? That doesn't exist according to our systems
see this photo
In any case, the reason for the failed request is due to your location. We cannot serve requests from your country