#goodluckh_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/1265359953967845468
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello
Have you referred to these docs already?
https://docs.stripe.com/billing/subscriptions/trials#resume-a-paused-subscription
Hi, it sounds like my set up already:
const stripe = new Stripe((args.context.env as any).STRIPE_SECRET_KEY);
const session = await stripe.checkout.sessions.retrieve(sessionId);
if (!session.setup_intent) {
return new Response("Error: Missing setup_intent", { status: 400 });
}
const setupIntent = await stripe.setupIntents.retrieve(
session.setup_intent as string
);
if (!setupIntent.metadata?.subscription_id) {
return new Response("Error: Missing subscription_id", { status: 400 });
}
const subscription = await stripe.subscriptions.update(
setupIntent.metadata.subscription_id,
{
default_payment_method: setupIntent.payment_method as string,
collection_method: "charge_automatically",
}
);
if (subscription.status === "paused") {
await stripe.subscriptions.resume(subscription.id),
{
billing_cycle_anchor: "now",
};
}
// Retrieve the latest invoice for the subscription
const latestInvoice = await stripe.invoices.retrieve(
subscription.latest_invoice as string
);
// Attempt to pay the latest invoice if it is open
if (latestInvoice.status === "open") {
await stripe.invoices.pay(latestInvoice.id);
}
Can you share the test invoice ID it generated?
in_1Pfm1BLw4lMVnwxib7vAUWUT
i mean there are a couple
the paid one on top is the one i manually clicked on "resume subscription" in Stripe's dashboard
It looks like your call to resume the subscripiton is voiding the invoice that gets generated.
yea it appears to be so
I don't see any calls to pay the invoice, you mentioned you're calling the /pay endpoint correct?