#beast_schedule-taxrate

1 messages ยท Page 1 of 1 (latest)

dry mortarBOT
limber solsticeBOT
#

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.

dry mortarBOT
#

๐Ÿ‘‹ 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/1242145144010969189

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

umbral kelp
#

Hello ๐Ÿ‘‹

Unfortunately the description field for the Price object is used for within the organization. It is not user facing.

umbral kelp
#

In that case I think you would need to create different products so that the product description shows up on each invoice line item

golden mortar
#

Got it I see

#

no worries - thank you!

umbral kelp
#

Yeah I had to test a few things to see if I could get Price decriptions or metadata to show up on Invoices but they don't

golden mortar
#

Ah no worries

#

thank you for trying ๐Ÿ™‚

#

Another question I have is:

I'm currently using a subscription schedule to make changes to my subscription. One thing I need to do is update the phases. To comply with Stripe's guidelines, I cannot modify any phases that have been past. So, when updating the phases for a schedule, I need to pass in the old phases first and then the new phases. However, when I try to do this I get the error

'You passed an empty string for 'phases[0][collection_method]'. We assume empty values are an attempt to unset a parameter; however 'phases[0][collection_method]' cannot be unset. You should remove 'phases[0][collection_method]' from your request or supply a non-empty value.'

Which makes sense as I'm not supposed to be updating the subscription schedule with all these requires params. So I'm guessing I need to manually construct each old phase, how can I do this? What are the necessary params I should be passing in. Mine currently looks like this right now:

const newPhases = [];

    // Initialize with old phases first
    for (var i = 0; i < currentPhase; i++) {
        const phase = subscriptionSchedule.phases[i];
        newPhases.push({
            items: phase.items.map((item: any) => {
                return {
                    price: item.price,
                    quantity: item.quantity,
                };
            }),
            currency: phase.currency,
            description: phase.description,
            start_date: phase.start_date,
            end_date: phase.end_date,
        })
    }
umbral kelp
#

Okay you don't actually need to pass any phase that is earlier than the current phase.

#

However, when I integrate Subscription Schedules, I find the easiest approach to updating phases is to copy the phases property from the Subscription Schedule itself, modify the array of phases, and pass it back. That way I only make changes to the phases I want to update while retaining all the details from existing phases I didn't want to change.

golden mortar
#

I see

#

That's what I think I'm doing though?

#

const newPhases: any[] = [];

    const existingPhase = subscriptionSchedule.phases[currentPhase];
    console.log('new phases', newPhases);

    // Case 1: Update product before subscription renews, so modify the current phase and next phase
    if (epochStartTime < existingPhase.end_date) {
        console.log('reached?');
        // Phase before the change
        newPhases.push({
            items: existingPhase.items.map((item: any) => {
                return {
                    price: item.price,
                    quantity: item.quantity,
                };
            }),
            start_date: existingPhase.start_date,
            end_date: epochStartTime,
            proration_behavior: 'none',
        });
    } else {
        newPhases.push({ ...existingPhase, end_date: epochStartTime });
    }

    // Phase after the change
    newPhases.push({
        items: [
            {
                price: new_price_id,
                quantity: 1,
            },
        ],
        start_date: epochStartTime,
        end_date: epochEndTime,
        proration_behavior: 'none',
        billing_cycle_anchor: 'phase_start',
    });
umbral kelp
#

No. Sub Schedules replace the entire phases array with what you provide

golden mortar
#

so does that mean the phases[0].start_date in the updated subscription schedule should always be the current time?

#

Actually that's not true for all cases ^

umbral kelp
#

What I meant is something like

sub_sched = stripe.SubscriptionSchedules.retrieve('sub_sched_XXXX')
my_phases = sub_sched.phases
# Append new phase to the array of phases here
golden mortar
#

but I can't just append it. Because I want my code to essentially override any existing updates that are supposed to take place with my current update

#

idk why it's throwing an error when I'm setting phases to this:

[
{
add_invoice_items: [],
application_fee_percent: null,
billing_cycle_anchor: 'phase_start',
billing_thresholds: null,
collection_method: null,
coupon: null,
currency: 'usd',
default_payment_method: null,
default_tax_rates: [],
description: null,
discounts: [],
end_date: 1721493940,
invoice_settings: null,
items: [ [Object] ],
metadata: {},
on_behalf_of: null,
proration_behavior: 'none',
start_date: 1718464324,
transfer_data: null,
trial_end: null
},
{
items: [ [Object] ],
start_date: 1721493940,
end_date: 1724085940,
proration_behavior: 'none',
billing_cycle_anchor: 'phase_start'
}
]

#

phases[0] here is what is currently on the schedule, as you've said, so Idk why I'm getting the "You passed an empty string for 'phases[0][collection_method]'. We assume empty values are an attempt to unset a parameter;" error. Unless I actually need to unset collection_method

umbral kelp
#

You are passing null there.

golden mortar
#

yes but I thought that's what you said to do: you said copy phrases from the subscription schedule. This is the phases I get back from the subscriptionSchedule

"phases": [
{
"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,
"discounts": [],
"end_date": 1718464324,
"invoice_settings": null,
"items": [
{
"billing_thresholds": null,
"discounts": [],
"metadata": {},
"plan": "price_1Om7LwDyFtOu3ZuTGzqgOVvt",
"price": "price_1Om7LwDyFtOu3ZuTGzqgOVvt",
"quantity": 1,
"tax_rates": []
}
],
"metadata": {},
"on_behalf_of": null,
"proration_behavior": "none",
"start_date": 1716217898,
"transfer_data": null,
"trial_end": null
},
{
"add_invoice_items": [],
"application_fee_percent": null,
"billing_cycle_anchor": "phase_start",
"billing_thresholds": null,
"collection_method": null,
"coupon": null,
"currency": "usd",
"default_payment_method": null,
"default_tax_rates": [],
"description": null,
"discounts": [],
"end_date": 1721056324,
"invoice_settings": null,
"items": [
{
"billing_thresholds": null,
"discounts": [],
"metadata": {},
"plan": "price_1Om8TjDyFtOu3ZuTns8m2lM9",
"price": "price_1Om8TjDyFtOu3ZuTns8m2lM9",
"quantity": 1,
"tax_rates": []
}
],

so it's null here.

#

Unless I need to actually unset this

umbral kelp
#

How are you creating your subscription schedules?

golden mortar
#

like the code that I use to create it?

limber solsticeBOT
umbral kelp
#

I'm trying to understand how you are creating subscription schedules that have no collection method.

golden mortar
#

Got it

#

So would sharing the code help?

umbral kelp
#

Just the Schedule ID would be fine

golden mortar
#

sub_1PIXsDDyFtOu3ZuTx8Ysi2vD

coarse quarry
#

beast_schedule-taxrate

golden mortar
#

subscription in test mode ^

#

whoops sorry

coarse quarry
#

Flagging I am taking over but Discord is busy so it'll take me a while to catch up on this

golden mortar
#

schedule id is: sub_sched_1PIXsDDyFtOu3ZuT8y71R1Kw

#

cool, hope you're having a good day koopajah

coarse quarry
#

Better now that I'm caught up on the thread ๐Ÿ˜‚

#

Okay so look at the API Request https://dashboard.stripe.com/test/logs/req_krVYIoxWNwums6 which is from your own code.
You are clearly passing phases: { 0: { application_fee_percent: "", billing_cycle_anchor: "", billing_thresholds: "", collection_method: "", coupon: "", from your own code with doesn't really make sense

#

So yeah the problem is your code. You can't just extract the phases array and add to it. That will never work. The phases array you get in your code is the response that our API returns to you. It has different properties/shapes than the parameters you are going to send us.

So you have to reconstruct the full phases array as if you were creating the SubscriptionSchedule for the first time

golden mortar
#

Got it

#

that makes much more sense now

#

Okay let me try that and lyk how it goes