#meteograms_docs

1 messages ยท Page 1 of 1 (latest)

clever skiffBOT
#

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

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

manic raptorBOT
thorn geyser
#

Hi there ๐Ÿ‘‹ do you have the ID of the Subscription Schedule that you're referring to that you can share?

regal knoll
#

To be clear, I expected my phases to be something like the docs, i.e. reflecting the current phase:

"phases": [
    {
      ...
      "end_date": 1714693634,
      ...
      "items": [
        {
          ...
          "price": "{{OLD_PRICE_ID}}",
          ...
        }
      ],
      ...
      "start_date": 1712101634,
      ...
    }
  ]
thorn geyser
#

What are you seeing instead?

regal knoll
#

sub_sched_1PP3r8HkIcPWRyQ1iADgMLgG

#
    {
      add_invoice_items: [],
      application_fee_percent: null,
      automatic_tax: [Object],
      billing_cycle_anchor: null,
      billing_thresholds: null,
      collection_method: null,
      coupon: null,
      currency: 'gbp',
      default_payment_method: null,
      default_tax_rates: [],
      description: null,
      discounts: [],
      end_date: 1719749565,
      invoice_settings: null,
      items: [Array],
      metadata: {},
      on_behalf_of: null,
      proration_behavior: 'create_prorations',
      start_date: 1717157565,
      transfer_data: null,
      trial_end: null
    }
  ]```
thorn geyser
#

end_data is there and populated, start_date is there and populated, items appears to be there but it's not obvious from what you shared how big the array it's holding is.

What are you expecting to see that you aren't?

regal knoll
#

The id is: sub_sched_1PP3r8HkIcPWRyQ1iADgMLgG

#

Sorry, I see now that I should be looking in the items. But...

#

I was hoping I could just take the existing phases array (one entry), and push another entry to it (with new price), and update.

#

But I get: StripeInvalidRequestError: 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.

thorn geyser
#

When you update the Subscription Schedule, you should pass in an array for phases that contains the existing phases as well as the one(s) you want to add.

#

I'm not sure why that guide doesn't show it that way, I'll flag that to our teams. Nevermind, it is showing that the existing phase needs to be passed back in along with the new phase.

regal knoll
#

Yep, but collection_method is null so I can't?

thorn geyser
#

So you can omit that parameter

regal knoll
#

So I have to start editing the existing phase by taking stuff out that is causing an error?

#

The schedule does contain a default_settings.collection_method: 'charge_automatically'

thorn geyser
#

Yes

regal knoll
#

So maybe anything that is null in the phase would normally be taken from default_settings?

thorn geyser
#

Yes, the phase level settings are there to let you override the default settings set at the Subscription Schedule level on a phase-by-phase basis.

regal knoll
#

Why can't the API just use the default for any null passed in the phase? So we can just read the existing phases, and add a new phase without having to faff around at all?

thorn geyser
#

Because that isn't how our API is designed. If you look at the request log for the request encountering the error, you'll see that we're being passed an empty string. Within our API, an empty string is typically how you indicate you want to unset a field. I totally agree it's something we could make easier, and will be sure to file feedback with our teams that you'd be interested in seeing us do that in the future.

regal knoll
#

And it's not possible just to add a new phase (to start after the current phase finishes) , without touching the existing phase? to migrate to the new "meters" based price ID, all I want to do is specify the following... I don't want to amend the existing phase:

      {
        items: [
          {
            price: '{{NEW_PRICE_ID}}',
          },
        ],
      },

(the above example being from the docs)

thorn geyser
#

Correct

regal knoll
#

So for the existing phase (first item in my phases array) can I just extract start_date, end_date, items from the first item in the existing phases from the schedule and pass that, on the basis that everything else would be left alone?

thorn geyser
#

I believe so as the only other field that seems to be populated in the existing phases entry is proration_behavior, but that's set to a default value. Doing so also aligns with what is shown in the documentation you shared, but let me know if that doesn't seem to work as expected.

regal knoll
#

What about taking it further, and just passing an empty {} for the first phase... i.e. "don't touch anything"

thorn geyser
#

I don't think that will do what you want, and expect you'll see either an error or undesired behavior if you try to test that approach.

regal knoll
#

OK thanks.

thorn geyser
#

Any time!