Skip to content

Commit

Permalink
Merge pull request #1012 from stripe/cjavilla/add-pending-update
Browse files Browse the repository at this point in the history
Adds PendingUpdate to Subscription
  • Loading branch information
remi-stripe authored Jan 15, 2020
2 parents 22137e1 + 0e1be11 commit 65b7737
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
21 changes: 21 additions & 0 deletions sub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -91,6 +101,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"`
Expand Down Expand Up @@ -171,6 +182,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"`
Expand Down Expand Up @@ -206,6 +226,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"`
Expand Down
1 change: 1 addition & 0 deletions subitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 65b7737

Please sign in to comment.