#Pål

1 messages · Page 1 of 1 (latest)

celest owlBOT
ionic needle
gloomy mantle
#

For phase 0, do I need to copy all the fields from SubscriptionSchedulePhase to SubscriptionSchedulePhaseParams or will it merge fields from the new phase 0?

#

A snippet

    params := stripe.SubscriptionScheduleParams{
        Params: stripe.Params{
            Context: ctx,
        },
        Phases: []*stripe.SubscriptionSchedulePhaseParams{
            {
                // Should I manually map these fields to the existing phase 0?
                AddInvoiceItems:       []*stripe.SubscriptionSchedulePhaseAddInvoiceItemParams{},
                ApplicationFeePercent: new(float64),
                AutomaticTax:          &stripe.SubscriptionSchedulePhaseAutomaticTaxParams{},
                BillingCycleAnchor:    new(string),
                BillingThresholds:     &stripe.SubscriptionBillingThresholdsParams{},
                CollectionMethod:      new(string),
                Coupon:                new(string),
                Currency:              new(string),
                DefaultPaymentMethod:  new(string),
                DefaultTaxRates:       []*string{},
                Description:           new(string),
                EndDate:               new(int64),
                EndDateNow:            new(bool),
                InvoiceSettings:       &stripe.SubscriptionSchedulePhaseInvoiceSettingsParams{},
                Items:                 []*stripe.SubscriptionSchedulePhaseItemParams{},
                Iterations:            new(int64),
                Metadata:              map[string]string{},
                OnBehalfOf:            new(string),
                ProrationBehavior:     new(string),
                StartDate:             new(int64),
            },
            {
                AutomaticTax: &stripe.SubscriptionSchedulePhaseAutomaticTaxParams{
                    Enabled: stripe.Bool(true),
                },
                Items: []*stripe.SubscriptionSchedulePhaseItemParams{
                    {
                        Price: &priceID,
                    },
                },
            },
        },
    }

ionic needle
#

You can copy the phase 0 and set in the update subscription schedule api if everything keeps the same

celest owlBOT
gloomy mantle
#

Yes, that makes sense. The only issue is that these are two different types (SubscriptionSchedulePhase and SubscriptionSchedulePhaseParams). Copying fields one by one seems error-prone.

sleek lichen
#

Not understanding the issue

gloomy mantle
#

Use case:
I have a lot of subscriptions. I want to add a phase for each subscription starting at the end of the current period.

To do this I'm using the update schedule API (https://stripe.com/docs/api/subscription_schedules/update). How do I best add a second phase, leaving the first phase unchanged?

sleek lichen
#

You need to pass in all existing phases when updating a Sub Schedule, otherwise their omission is taken as a request to remove them

gloomy mantle
#

I can raise a feature request in the SDK repo if this is not supported

sleek lichen
#

I'm not very familiar with Go, but can you not 'cast' types. So you'd pass your existing phase as the SubscriptionSchedulePhaseParams type?

#

You could approach it that way in TS for example

gloomy mantle
#

I can't cast the type, no. This issue is specific to the go SDK. I'll create a feature request in the SDK repo 😉

sleek lichen
#

Yeah that sounds like a good next step. Sorry I couldn't be more help

gloomy mantle
#

No problem, I still learned something. Thanks for your help!