#arya_code

1 messages ¡ Page 1 of 1 (latest)

ornate flickerBOT
#

👋 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.

weary lance
#

hello! which doc are you using? also, can you share the request ID you're making? it should look like this: req_[random strings]

feral path
#

yah one min

#

Where I can find this?

#

I am getting sub,,,, type string in subscription sections

#

sub_1RLSdKLuluAayEgh0BGVtWdz

weary lance
feral path
#

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

weary lance
#

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?

feral path
#

It should be like Testing

#

Testing 1*

weary lance
#

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

feral path
#

Yah

weary lance
#

expand: 'items.data.plan.product' should get it

feral path
#

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",
});
}
};

weary lance
#

yep, in the stripe.subscriptions.list call

feral path
#

Thanks now getting it

#

On more thing

#

Can you say why this behaviour is getting

weary lance
#

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

feral path
#

According to this, I should be redirected to localhost://5173

#

?

weary lance
#

it is redirecting you there, it's just appending extra query string info at the end too

feral path
#

Ohh

#

means I hope it will not affected in the live project?

weary lance
#

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

feral path
#

My local is not working for https, just http

weary lance
#

yep, that would do it

#

redirecting to HTTP should help for now

feral path
#

Ok