#sajid_api

1 messages ¡ Page 1 of 1 (latest)

elfin oracleBOT
#

👋 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/1290476849146892349

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

arctic grove
#

Hi there, are you asking about how to get the end_date of the first phase of schedule?

fallen roost
#

I am asking to get the end date of upcoming invoice or (start date of next iteration you may say).

arctic grove
fallen roost
#

I am implementing it. please be with me. I might need more help. dont close the thread.

fallen roost
#

When we switch the phase does subscription id change?

#

that is attached with subscription schedule

arctic grove
#

No, the ID stays the same

fallen roost
#

Can you please check when I update my subscription ends after one month.

#

req_gv0Rx2LyItSrDW

#

This is my request id of update. Please confirm is it updated correctly.

arctic grove
#

Hmm, so you want to automatically cancel the subscription one month later?

fallen roost
#

No, I want it to continue. but it ends after one month when i test it on simulation.

#

// Create the next phase starting at nextInvoiceDate
const nextPhase = {
start_date: nextInvoiceDate,
items: items,
iterations: 1, // One iteration for this phase (next invoice only)
};

// Create remaining phases with proper iterations
const remainingIterations = {
  items: prevItems,
  iterations: 9,  // Specify remaining iterations
  collection_method: "charge_automatically", // Default method for remaining iterations
  proration_behavior: 'create_prorations', // Ensure proration behavior is set
};
arctic grove
#

To clarify, you want the subscription to continue, but you found it cancelled during test?

fallen roost
#

yes it show ended on (the date of very next month when next phase should start)

arctic grove
#

What's the subscription ID?

fallen roost
#

sub_1Q4uxXF6Gkk6c638fj59KBZm

arctic grove
#

Ok, that's because the invoices weren't paid successfully, and the subscriptoin is therefore automatically cancelled

fallen roost
#

but I dont want it to cancel. it should added upto next invoices if not paid.

#

Because I am creating it for the tenant who has rented a property from a landlord. so this scuedule is for rent.

arctic grove
fallen roost
#

ok i got it.

#

and i want when the invoice created it shoudl become the open to pay. I have implemeneted webhook for that purpose. is it correct:

const handleInvoiceCreated = async (event) => {

const invoiceId = event.data.object.id;
const invoice = await stripe.invoices.retrieve(invoiceId);

// Ensure the invoice is not in 'paid', 'void', or 'uncollectible' state
if (invoice.status === 'open' || invoice.status === 'draft') {
// If the invoice is already open or in draft, you can proceed with updating it.
const updatedInvoice = await stripe.invoices.update(invoiceId, {
auto_advance: true, // Auto-advances the invoice to 'open' if it's in draft
});
}