#arya_code
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/1369003739654127876
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
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.
- arya_unexpected, 40 minutes ago, 4 messages
- arya_code, 5 days ago, 77 messages
- arya_test-mode-switch, 5 days ago, 25 messages
hello! which doc are you using? also, can you share the request ID you're making? it should look like this: req_[random strings]
yah one min
Where I can find this?
I am getting sub,,,, type string in subscription sections
sub_1RLSdKLuluAayEgh0BGVtWdz
this support doc tells you how to find the request ID:
https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_w1TG9FsVvYFr5v
This is the req
{
"success": true,
"message": "Subscription Found",
"activePlan": "Unknown Plan",
"startDate": "5/5/2025",
"endDate": "6/5/2025",
"status": "active"
}
Getting activePlan is getting as Unknown Plan
ok, it looks like that's a request to confirm the PaymentIntent. in your original question you say you are trying to retrieve subscription details?
ok yep, i see that that is the name of the Product you're attaching to the subscription sub_1RLSdKLuluAayEgh0BGVtWdz. the API call you shared is for the Confirm a PaymentIntent call which wouldn't be expected to return information about the Subscription
you most likely want to be using Retrieve a subscription and then using expansion to get down to the Product information
Yah
expand: 'items.data.plan.product' should get it
In the backend code?
const getClientActiveSubscriptionDetails = async (req, res) => {
const clientId = req.params.clientId;
const user = req.user;
try {
const client = await ClientModel.findById(clientId);
if (!client) {
return res.status(404).json({
success: false,
message: "Client Not Found",
});
}
if (
(user.role === "agent" &&
client.agent.toString() !== user._id.toString()) ||
(user.role === "masterclient" && user._id.toString() !== clientId)
) {
return res.status(403).json({
success: false,
message: "Unauthorized Access",
});
}
const subscriptions = await stripe.subscriptions.list({
customer: client.stripeCustomerId,
status: "active",
limit: 1,
});
if (subscriptions.data.length === 0) {
return res.status(404).json({
success: false,
message: "No active subscription found for this customer.",
});
}
const subscription = subscriptions.data[0]; // Assuming customer has only one subscription
const planName =
subscription.items.data[0]?.plan.nickname || "Unknown Plan";
const startDate = new Date(
subscription.start_date * 1000
).toLocaleDateString();
const endDate = subscription.current_period_end
? new Date(subscription.current_period_end * 1000).toLocaleDateString()
: "N/A";
res.status(201).json({
success: true,
message: "Subscription Found",
activePlan: planName,
startDate: startDate,
endDate: endDate,
status: subscription.status,
});
} catch (error) {
console.log(error);
res.status(500).json({
success: false,
message: "Server down",
});
}
};
yep, in the stripe.subscriptions.list call
see this reference for an example of how to pass it
https://docs.stripe.com/expand?lang=node#multiple-levels
Thanks now getting it
On more thing
When payment is successfully done then getting redirected to https://localhost:5173/?payment_intent=pi_3RLTSpLuluAayEgh0IF0R6PR&payment_intent_client_secret=pi_3RLTSpLuluAayEgh0IF0R6PR_secret_CRINFFsENsoM5vtwDpYtoUoub&redirect_status=succeeded
Can you say why this behaviour is getting
that's just redirecting to whatever you are providing in the redirect_url, and we append extra query strings with the details of the payment so you can reference them if you need on the new page
the secure connection issue is just a problem with your setup, i won't be able to help you troubleshoot that
it is redirecting you there, it's just appending extra query string info at the end too
nope! the query strings shouldn't cause problems
i would still try to figure out why it's not working locally but again, that's something you need to figure out on your end. your local server maybe just isn't set up to handle HTTPS properly
My local is not working for https, just http
Ok