From 1ff06acb5cdcdc833e4dc061a3d34f78b9e268fa Mon Sep 17 00:00:00 2001 From: CJ Avilla Date: Fri, 10 Jan 2020 11:50:01 -0800 Subject: [PATCH 1/2] Adds PendingUpdate to Subscription --- invoice.go | 1 + sub.go | 11 +++++++++++ subitem.go | 1 + 3 files changed, 13 insertions(+) diff --git a/invoice.go b/invoice.go index b1946784a5..8b37393700 100644 --- a/invoice.go +++ b/invoice.go @@ -119,6 +119,7 @@ type InvoiceParams struct { SubscriptionItems []*SubscriptionItemsParams `form:"subscription_items"` SubscriptionPlan *string `form:"subscription_plan"` SubscriptionProrate *bool `form:"subscription_prorate"` + SubscriptionProrationBehavior *string `form:"subscription_proration_behavior"` SubscriptionProrationDate *int64 `form:"subscription_proration_date"` SubscriptionQuantity *int64 `form:"subscription_quantity"` SubscriptionTrialEnd *int64 `form:"subscription_trial_end"` diff --git a/sub.go b/sub.go index 36783cac39..981c535f44 100644 --- a/sub.go +++ b/sub.go @@ -91,6 +91,7 @@ type SubscriptionParams struct { PendingInvoiceItemInterval *SubscriptionPendingInvoiceItemIntervalParams `form:"pending_invoice_item_interval"` Plan *string `form:"plan"` Prorate *bool `form:"prorate"` + ProrationBehavior *string `form:"proration_behavior"` ProrationDate *int64 `form:"proration_date"` Quantity *int64 `form:"quantity"` TrialEnd *int64 `form:"trial_end"` @@ -171,6 +172,15 @@ type SubscriptionPendingInvoiceItemInterval struct { IntervalCount int64 `json:"interval_count"` } +// SubscriptionPendingUpdate represents deferred changes that will be applied when latest invoice is paid. +type SubscriptionPendingUpdate struct { + BillingCycleAnchor int64 `json:"billing_cycle_anchor"` + ExpiresAt int64 `json:"expires_at"` + SubscriptionItems []*SubscriptionItem `json:"subscription_items"` + TrialEnd int64 `json:"trial_end"` + TrialFromPlan bool `json:"trial_from_plan"` +} + // SubscriptionTransferData represents the information for the transfer_data associated with a subscription. type SubscriptionTransferData struct { Destination *Account `json:"destination"` @@ -206,6 +216,7 @@ type Subscription struct { OnBehalfOf *Account `json:"on_behalf_of"` PendingInvoiceItemInterval SubscriptionPendingInvoiceItemInterval `json:"pending_invoice_item_interval"` PendingSetupIntent *SetupIntent `json:"pending_setup_intent"` + PendingUpdate *SubscriptionPendingUpdate `json:"pending_update"` Plan *Plan `json:"plan"` Quantity int64 `json:"quantity"` Schedule *SubscriptionSchedule `json:"schedule"` diff --git a/subitem.go b/subitem.go index 5e0b41546d..bb6f1d7f35 100644 --- a/subitem.go +++ b/subitem.go @@ -11,6 +11,7 @@ type SubscriptionItemParams struct { Plan *string `form:"plan"` Prorate *bool `form:"prorate"` ProrationDate *int64 `form:"proration_date"` + ProrationBehavior *string `form:"proration_behavior"` Quantity *int64 `form:"quantity"` Subscription *string `form:"subscription"` TaxRates []*string `form:"tax_rates"` From 0e1be11b1458a32f92b97e06d812445f7b2cf8fe Mon Sep 17 00:00:00 2001 From: CJ Avilla Date: Mon, 13 Jan 2020 09:13:31 -0800 Subject: [PATCH 2/2] Add values for SubscriptionProrationBehavior --- sub.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sub.go b/sub.go index 981c535f44..5212fa072f 100644 --- a/sub.go +++ b/sub.go @@ -41,6 +41,16 @@ const ( SubscriptionPaymentBehaviorPendingIfIncomplete SubscriptionPaymentBehavior = "pending_if_incomplete" ) +// SubscriptionProrationBehavior determines how to handle prorations when billing cycles change. +type SubscriptionProrationBehavior string + +// List of values that SubscriptionProrationBehavior can take. +const ( + SubscriptionProrationBehaviorAlwaysInvoice SubscriptionProrationBehavior = "always_invoice" + SubscriptionProrationBehaviorCreateProrations SubscriptionProrationBehavior = "create_prorations" + SubscriptionProrationBehaviorNone SubscriptionProrationBehavior = "none" +) + // SubscriptionPendingInvoiceItemIntervalInterval controls the interval at which pending invoice // items should be invoiced. type SubscriptionPendingInvoiceItemIntervalInterval string