#Tousif Ali

1 messages · Page 1 of 1 (latest)

astral oxideBOT
tepid tapir
brittle island
#

I dont have access to my client stripe account.

#

let me try to regenerate the issue on my test account.

#

@tepid tapir I have already follow above doc but nothing helps

#

here the param I am passing

#

[
"phases" => [
[
"items" => [
[
"plan" => "price_1MhW51D896OoIByocF99hrkJ",
"price" => "price_1MhW51D896OoIByocF99hrkJ",
"quantity" => 1,
],
],
"start_date" => 1668212720,
"end_date" => 1670804720,
"trial_end" => 1670804720,
],
[
"items" => [
[
"plan" => "price_1MhW51D896OoIByocF99hrkJ",
"price" => "price_1MhW51D896OoIByocF99hrkJ",
"quantity" => 1,
],
],
"start_date" => 1670804720,
"end_date" => 1676161520,
"trial_end" => null,
],
[
"items" => [
[
"plan" => "price_1MhW51D896OoIByocF99hrkJ",
"price" => "price_1MhW51D896OoIByocF99hrkJ",
"quantity" => 1,
],
],
"start_date" => 1676161520,
"end_date" => 1678580720,
"trial_end" => null,
],
],
]

tepid tapir
#

I'd need your request ID to understand where and how the error occurred, so that I can investigate further

#

What's the full error message?

brittle island
#

Stripe\Exception\InvalidRequestException with message 'Invalid integer:

tepid tapir
#

The error message was trimmed

brittle island
#

I do no have access to my client account.

tepid tapir
#

When did you make the request above? I can try to find the request in our system with above information if the time range is given

brittle island
#

just now

#

if you want I can do it again.

tepid tapir
#

It's fine! Let me search it

brittle island
#

I can also provide you sub_shc id

#

sub_sched_1M37XAD896OoIByorAuSHXNE

tepid tapir
#

Oh! That's great!

#

Let me take a look

#

phases[1][trial_end] should be an integer, but it is set as empty value. If it's not needed, can you remove phases[1][trial_end] from the request?

#

This is the full error message:

{
  error: {
    code: "parameter_invalid_integer",
    doc_url: "https://stripe.com/docs/error-codes/parameter-invalid-integer",
    message: "Invalid integer: ",
    param: "phases[1][trial_end]",
    request_log_url: "https://dashboard.stripe.com/logs/req_dwITBGDOregB0q?t=1678076439",
    type: "invalid_request_error",
  },
}
brittle island
#

ok they are not a trial

#

should I remove it if its null.

#

@tepid tapir now getting this

#

Stripe\Exception\InvalidRequestException with message 'You can not update a phase that has already ended. Trying to update phase 0.'

#

Now my question is, should I just add phase with their keys

#

like there are 3 phases

#

and their indexes are 0, 1, 2

#

0 might be expired so do I simply add current and new phases with mentioning their specific index?

tepid tapir
#

The phase[0] start_date and end_date was in the past:

  • start_date: 1668212720 - 2022-11-20 00:25:20 UTC
  • end_date: 1670804720 - 2022-12-12 00:25:20 UTC
#

Subscription schedule can only schedule phases in the future!

#

Can you use Retrieve Subscription Schedule API to retrieve this schedule to get the phases and update from there?

brittle island
#

I already did that

#

This is phase[1]
Start date: 2022-12-12 00:25:20
End date: 2023-02-12 00:25:20

#

This is phase[2]
Start date: 2023-02-12 00:25:20
End date: 2023-03-12 00:25:20

#

Question: Can I edit phase[2] price ?

#

as its running now.

tepid tapir
#

Can you share the response where you retrieve Subscription Schedule? We don't log response for GET request, so I can't see the details

brittle island
#

This is phase array
[
[
"add_invoice_items" => [],
"application_fee_percent" => null,
"billing_cycle_anchor" => null,
"billing_thresholds" => null,
"collection_method" => null,
"coupon" => null,
"currency" => "usd",
"default_payment_method" => null,
"default_tax_rates" => [],
"description" => null,
"end_date" => 1670804720,
"invoice_settings" => null,
"items" => [
[
"billing_thresholds" => null,
"metadata" => [],
"plan" => "price_1J8EDWD896OoIByotRnDqEEf",
"price" => "price_1J8EDWD896OoIByotRnDqEEf",
"quantity" => 1,
"tax_rates" => [],
],
],
"metadata" => [],
"on_behalf_of" => null,
"proration_behavior" => "create_prorations",
"start_date" => 1668212720,
"transfer_data" => null,
"trial" => true,
"trial_end" => 1670804720,
],

#

[
"add_invoice_items" => [],
"application_fee_percent" => null,
"billing_cycle_anchor" => null,
"billing_thresholds" => null,
"collection_method" => null,
"coupon" => "GyA9xqBL",
"currency" => "usd",
"default_payment_method" => null,
"default_tax_rates" => [],
"description" => null,
"end_date" => 1676161520,
"invoice_settings" => null,
"items" => [
[
"billing_thresholds" => null,
"metadata" => [],
"plan" => "price_1J8EDWD896OoIByotRnDqEEf",
"price" => "price_1J8EDWD896OoIByotRnDqEEf",
"quantity" => 1,
"tax_rates" => [],
],
],
"metadata" => [],
"on_behalf_of" => null,
"proration_behavior" => "create_prorations",
"start_date" => 1670804720,
"transfer_data" => null,
"trial_end" => null,
],
[
"add_invoice_items" => [],
"application_fee_percent" => null,
"billing_cycle_anchor" => null,
"billing_thresholds" => null,
"collection_method" => null,
"coupon" => null,
"currency" => "usd",
"default_payment_method" => null,
"default_tax_rates" => [],
"description" => null,
"end_date" => 1678580720,
"invoice_settings" => null,
"items" => [
[
"billing_thresholds" => null,
"metadata" => [],
"plan" => "price_1J8EDWD896OoIByotRnDqEEf",
"price" => "price_1J8EDWD896OoIByotRnDqEEf",
"quantity" => 1,
"tax_rates" => [],
],
],
"metadata" => [],
"on_behalf_of" => null,
"proration_behavior" => "create_prorations",
"start_date" => 1676161520,
"transfer_data" => null,
"trial_end" => null,
],
]

tepid tapir
#

In your phase[0], you were trying to update from price_1J8EDWD896OoIByotRnDqEEf to price_1MhW51D896OoIByocF99hrkJ. Since this phase[0] is past, you shouldn't make any changes to it

brittle island
#

actually we need to increase the price, this is what we need to achiece.

tepid tapir
#

You can only make changes to current and future phases

#

You shouldn't update anything in phase[0]. Because you updated the price in the phase[0], so You can not update a phase that has already ended. Trying to update phase 0." was returned

brittle island
#

ok so you mean only phase[2]

#

this is the only phase that is currently running

#

should I simply add one array to phase.

#

how stripe will know I am targeting last phase?

tepid tapir
#

You can only update phase[2] since phase[0] and phase[1] has ended

#

should I simply add one array to phase.
It depends on your use case whether you want to update the price in current phase or next phase. If it's next phase, then you add new array to the phase. If it's to update current subscription, then you should update the existing phase

#

how stripe will know I am targeting last phase?
It will look for the phase that you make the changes

brittle island
#

but how do I need to mention array key of that phase

#

?

tepid tapir
#

Are you going to update the subscription price immediately, or do you plan to update the price in the next cycle or future date?

brittle island
#

next cycle

#

currenlty what they are using let them use it, once it finished, then it should use new pricing.

tepid tapir
#

For next cycle, then you can new phase to phases array. Only when you're trying to update an existing cycle, then you have to look for the specific phase to update.

brittle island
#

Do have to include all phases?

#

and only change phase for the future occurence or it last phase is currently running then add new one?

golden niche
#

Hi @brittle island I'm taking over this thread

#

It's a long thread, is your latest question about updating existing phases or creating a new phase?

brittle island
#

both

#

here is what I need

#

I need to increase subscription price

#

if last phase is currently running then let it complete and increase the price after cycle completed

#

Second phase has 2 iteration so I can simply update 2nd phase and 3rd phase so that if second phase is in its first iteration then second iteration will be charge with new price and 3rd phase will also charge with new price

golden niche
#

OK. So basically you are doing the following

  1. Change phase 2's iteration to 1
  2. Change phase 3's price to the new price
    Is my understanding correct?
brittle island
#

I simply need to change price (we have increase our subscription price)

#
  1. pahse 2's iteration remains the same
#

that is 2

#

can we call here?

golden niche
#

I can only support you through chat.

brittle island
#

ok no problem

#

phase[0] -> 1 iteration and its trial
phase[1] -> 2 iteration
phase[2] -> 1 iteration

#

I simply want to change price id

golden niche
#

Let me clarify the price change here.

OK let's focus on the 2 iterations of phase[1] here, are these 2 iterations using the same price, or different?

brittle island
#

if any of phases or iteration is currently running then let it complete it cycle and then from next phase or iteration charge them with new price

#

all phases are using same price id

golden niche
#

OK, then why do you need so many phases if the prices are the same?

brittle island
#

phase[0] -> I need trial -> 1st month
phase[1] -> 2 iteration (here I need to give 50% discount on2nd and 3rd month)
phase[2] -> 1 iteration (here I need to charge users full price from 4th month and on wards)

Hope I this make sense.

#

phase[1] I am using coupon to give user 50% discount.

golden niche
#

One sec, so there's price change at all? you are basically using coupon to give discount to your customer?

#

If you want to achieve what you described earlier (trail -> discount -> full price), you can do it by simply applying a coupon, there's no need to use subscription schedule at all.

brittle island
#

but now I already used that and people are using it.

#

and this looks easier to me then using normal subscription and add coupon. Dont know how to add coupon on second and third month.

golden niche
brittle island
#

if add coupon to subscription

#

its simply ignore 1 month because of its nature which is trial

#

and it will be used for 2nd and 3rd month and then coupon will expire, right?

golden niche
#

Hmm. Maybe it should be 3. Even the first month is on trial, Stripe will still generate a $0 invoice. I'll suggest you to use test clock to test it out first.

brittle island
#

yes test clock feature is awesome, and when I was implemented this schedule feature you do not have test clock to test

#

Now come back to schedule subscription again

#

I cannot change the code now, its already been implemented. Please guide how to update price id in phases

#

??

golden niche
#

Sure, so you want to do

1. Change phase 2's iteration to 1
2. Insert a new phase here for i iteration
3. Change phase 3 (now Phase 4)'s price to the new price
brittle island
#

I dont want to change iteration

golden niche
#

But you are changing the price, am I right or did I miss anything

brittle island
#

yes

golden niche
#

Then you can't have 2 iterations with different price

brittle island
#

but can I simply change phase[2] price id and what ever iteration is remaining it will apply new price on that

#

it a very challenging task as this is not the only schedule subscription I have to update, we have tons of that.

golden niche
#

This is just my suggestion, you can use your own approach, just make sure you test it out with test clocks before rolling out to production.

brittle island
#

do I need to also add expired phases in array (but not change any value of it as its expired)?

golden niche
#

You mean past phases? there's no need to include them

brittle island
#

ok, it mean what ever I am adding in a phases array it will replaced by the old array in stripe?

golden niche
#

what do you mean by old array in stripe ?

brittle island
#

I mean what ever I passed in update schedule subscription API, will it be replace my old configuration (phases)?

golden niche
#

yes you are right

brittle island
#

but phase[1] is big issue how can I calculate how many phases need to add as phase[1] is big complicated

#

how can I check phase[1] first iteration is finished, so that I can only add one phase with new price id

golden niche
#

The schedule doesn't provide this info and you need to calculate it by yourself.

For instance, you can get the current_phase.start_date, and add one month to it and check it against with the current time. https://stripe.com/docs/api/subscription_schedules/object?lang=curl#subscription_schedule_object-current_phase-start_date

brittle island
#

I have already looked at that docs

#

but its tricky to calculate phase[1] iteration is ended or not

#

as it only shows start and end date

golden niche
#

Yes it's tricky, and that's why in the beginning I suggest using the coupon's duration_in_months instead of schedules.

cursive cape
#

@brittle island we can continue to discuss here? what is your your latest follow up question?

brittle island
#

is there any way we can know from retrive schedule subscription that where user is currently standing if we have used iteration in phases?

ripe olive
#

Hi! I'm taking over this thread.

#

What do you mean by "where user is currently standing"?

brittle island
#

let say one phase has 2 iteration

#

when I use retrive schedule subscription it did not tell me that when each iteration starts and end

#

it simply tell us when this phase will starts and ends

ripe olive
#

The Subscription Schedule will create a Subscription object. So you can check the subscription to check the current phase.