#cho_code

1 messages ยท Page 1 of 1 (latest)

small siloBOT
median thicketBOT
#

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.

small siloBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1255622653432168491

๐Ÿ“ Have more to share? Add details, code, screenshots, videos, etc. below.

cerulean bridge
#

Hello

unreal drift
#

hello

#

I'm trying to programmatically change renewal date of subscription.

cerulean bridge
#

Yeah if the schedule was released then when you retrieve the Sub subscription.schedule should be null

#

Have you tested and you are seeing otherwise?

unreal drift
#

I have this subscription: sub_1PDwmCDyFtOu3ZuTt7G1HBvc

#

See that's what I thought, but I has been some time so I doubted myself

#

Was there an update that caused a change to subscription scheedules

cerulean bridge
#

Yeah that schedule is still active until the next month

unreal drift
#

I'm revising my code and this bug suddenly started appearing

#

StripeInvalidRequestError: You can not update a phase that has already ended. Trying to update phase 0.

#

This error wasn't present with the same code, shall I provide the snippet?

cerulean bridge
#

No one sec

#

I see the erroring request

#

Looking

unreal drift
#

My system correctly identifies the current phase as '1'

cerulean bridge
#

Yeah so the Subscription Schedule had a phase 0 that ended on June 21 and those requests are made afterward

#

Are you retreiving the current state of the schedule before performing any updates?

unreal drift
#

yes, I am

#

however I am mapping both phases when I update it

cerulean bridge
#

You can't just pass in the same parameters from the original creation

unreal drift
#

is that incorrect?

cerulean bridge
#

It has to be current

unreal drift
#

how can I send a code block here

small siloBOT
#

๐Ÿง‘โ€๐Ÿ’ป How to format code on Discord

Inline code: wrap in single backticks (`)

This:

The variable `foo` contains the value `bar`.

Will turn into this:

The variable foo contains the value bar.

Code blocks: wrap in three backticks (```)

Also, you can specify the language after the first three backticks to get syntax highlighting.

This:

```javascript
function foo() {
return 'bar';
}
```

Will turn into this:

function foo() {
  return 'bar';
}```

Notes about **code blocks**:
- Specifying the language is optional (e.g., you can omit `javascript` in the example above)
  - If you don't specify the language you won't get syntax highlighting
- When you're inside a code block (after you type \`\`\`) the `Return`/`Enter` key will add a new line instead of sending your message
  - Once you end the code block `Return`/`Enter` works normally again

You can [read more about message formatting on Discord's website.](https://support.discord.com/hc/en-us/articles/210298617)
unreal drift
#
                    (
                        phase: Stripe.SubscriptionScheduleUpdateParams.Phase,
                        index: number
                    ) => {
                        return {
                            items: phase.items.map((item: any) => {
                                return {
                                    price: item.price,
                                    quantity: item.quantity,
                                };
                            }),
                            currency: phase.currency,
                            description: phase.description,
                            iterations: phase.iterations,
                            ...(index === 1
                                ? {
                                      end_date: new_end_date_epoch,
                                      trial_end: new_end_date_epoch,
                                      proration_behavior: 'none',
                                  }
                                : {
                                      end_date: phase.end_date,
                                      start_date: phase.start_date,
                                  }),
                            // Add any other properties from the phase object as needed
                        };
                    }
                );```
#

oof the tabbing isn't good

#

I did run into the issue of not being able to just map that 1st phase 1:1

cerulean bridge
#

Ah yeah you can't do that

unreal drift
#

D:

cerulean bridge
#

That will map all of the phases

unreal drift
#

right

cerulean bridge
#

And then only map those that are that phase and after when making an update

unreal drift
#

OHHH

#

okay this is omega simple for my use case

#

our schedules only have up to 2 phases and then releases

#

So I would only map index 1

#

which is the same as returning not mapping

cerulean bridge
#

๐Ÿ‘

unreal drift
#

okay it worked

#

I just needed to set the start date to the start date of phase 1 and return just the single map

small siloBOT
unreal drift
#

ty ty