#Tousif Ali
1 messages · Page 1 of 1 (latest)
You can update the item price in the phases of Subscription Schedule: https://stripe.com/docs/api/subscription_schedules/update#update_subscription_schedule-phases-items-price
Can you share the request ID (req_xxx) where you faced the error? Here’s how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
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,
],
],
]
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?
Stripe\Exception\InvalidRequestException with message 'Invalid integer:
The error message was trimmed
I do no have access to my client account.
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
It's fine! Let me search it
Oh! That's great!
Let me take a look
Found the request ID: https://dashboard.stripe.com/logs/req_XGMxJumaufi2zd
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",
},
}
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?
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?
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.
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
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,
],
]
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
actually we need to increase the price, this is what we need to achiece.
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
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?
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
Are you going to update the subscription price immediately, or do you plan to update the price in the next cycle or future date?
next cycle
currenlty what they are using let them use it, once it finished, then it should use new pricing.
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.
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?
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?
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
OK. So basically you are doing the following
- Change phase 2's iteration to 1
- Change phase 3's price to the new price
Is my understanding correct?
I simply need to change price (we have increase our subscription price)
- pahse 2's iteration remains the same
that is 2
can we call here?
I can only support you through chat.
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
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?
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
OK, then why do you need so many phases if the prices are the same?
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.
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.
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.
https://stripe.com/docs/api/coupons/create#create_coupon-duration_in_months you can use duration_in_months to set how many mouth the discount should be applied to (i.e., 2 in your case)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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?
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.
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
??
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
I dont want to change iteration
But you are changing the price, am I right or did I miss anything
yes
Then you can't have 2 iterations with different price
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.
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.
do I need to also add expired phases in array (but not change any value of it as its expired)?
You mean past phases? there's no need to include them
ok, it mean what ever I am adding in a phases array it will replaced by the old array in stripe?
what do you mean by old array in stripe ?
I mean what ever I passed in update schedule subscription API, will it be replace my old configuration (phases)?
yes you are right
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
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
Yes it's tricky, and that's why in the beginning I suggest using the coupon's duration_in_months instead of schedules.
@brittle island we can continue to discuss here? what is your your latest follow up question?
is there any way we can know from retrive schedule subscription that where user is currently standing if we have used iteration in phases?
Hi! I'm taking over this thread.
What do you mean by "where user is currently standing"?
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
The Subscription Schedule will create a Subscription object. So you can check the subscription to check the current phase.
And there also this on the subscription schedule object: https://stripe.com/docs/api/subscription_schedules/object#subscription_schedule_object-current_phase