Skip to content

Commit

Permalink
Subscription schedule fixes (#264)
Browse files Browse the repository at this point in the history
* Added ConnectApplication

* Corrected applicationFeePercent type

* Corrected fromSubscription type

* Added alwaysInvoice case

---------

Co-authored-by: Andrew <[email protected]>
Co-authored-by: Andrew Edwards <[email protected]>
  • Loading branch information
3 people authored Jul 17, 2024
1 parent 5bca59d commit 4af10ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public struct SubscriptionScheduleCurrentPhase: Codable {

public struct SubscriptionScheduleDefaultSettings: Codable {
/// A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner’s Stripe account during this phase of the schedule.
public var applicationFeePercent: String?
public var applicationFeePercent: Float?
/// Default settings for automatic tax computation.
public var automaticTax: SubscriptionScheduleDefaultSettingsAutomaticTax?
/// Possible values are `phase_start` or `automatic`. If `phase_start` then billing cycle anchor of the subscription is set to the start of the phase when entering the phase. If `automatic` then the billing cycle anchor is automatically modified as needed when entering the phase. For more information, see the billing cycle documentation.
Expand All @@ -119,7 +119,7 @@ public struct SubscriptionScheduleDefaultSettings: Codable {
/// The account (if any) the subscription’s payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription’s invoices.
public var transferData: SubscriptionScheduleTransferData?

public init(applicationFeePercent: String? = nil,
public init(applicationFeePercent: Float? = nil,
automaticTax: SubscriptionScheduleDefaultSettingsAutomaticTax? = nil,
billingCycleAnchor: SubscriptionScheduleBillingCycleAnchor? = nil,
billingThresholds: SubscriptionScheduleDefaultSettingsBillingThresholds? = nil,
Expand Down Expand Up @@ -198,7 +198,7 @@ public struct SubscriptionSchedulePhase: Codable {
/// A list of prices and quantities that will generate invoice items appended to the first invoice for this phase.
public var addInvoiceItems: [SubscriptionSchedulePhaseAddInvoiceItem]?
/// A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner’s Stripe account during this phase of the schedule.
public var applicationFeePercent: String?
public var applicationFeePercent: Float?
/// Automatic tax settings for this phase.
public var automaticTax: SubscriptionSchedulePhaseAutomaticTax?
/// Possible values are `phase_start` or `automatic`. If `phase_start` then billing cycle anchor of the subscription is set to the start of the phase when entering the phase. If automatic then the billing cycle anchor is automatically modified as needed when entering the phase. For more information, see the billing cycle documentation.
Expand Down Expand Up @@ -237,7 +237,7 @@ public struct SubscriptionSchedulePhase: Codable {
public var trialEnd: Date?

public init(addInvoiceItems: [SubscriptionSchedulePhaseAddInvoiceItem]? = nil,
applicationFeePercent: String? = nil,
applicationFeePercent: Float? = nil,
automaticTax: SubscriptionSchedulePhaseAutomaticTax? = nil,
billingCycleAnchor: SubscriptionScheduleBillingCycleAnchor? = nil,
billingThresholds: SubscriptionScheduleDefaultSettingsBillingThresholds? = nil,
Expand Down Expand Up @@ -366,6 +366,7 @@ public enum SubscriptionScheduleStatus: String, Codable {

public enum SubscriptionSchedulePhaseProrationBehavior: String, Codable {
case createProrations = "create_prorations"
case alwaysInvoice = "always_invoice"
case none
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public protocol SubscriptionScheduleRoutes: StripeAPIRoute {
startDate: Date?,
defaultSettings: [String: Any]?,
endBehavior: SubscriptionScheduleEndBehavior?,
fromSubscription: Bool?,
fromSubscription: String?,
expand: [String]?) async throws -> SubscriptionSchedule

/// Retrieves the details of an existing subscription schedule. You only need to supply the unique subscription schedule identifier that was returned upon subscription schedule creation.
Expand Down Expand Up @@ -97,7 +97,7 @@ public struct StripeSubscriptionScheduleRoutes: SubscriptionScheduleRoutes {
startDate: Date? = nil,
defaultSettings: [String: Any]? = nil,
endBehavior: SubscriptionScheduleEndBehavior? = nil,
fromSubscription: Bool? = nil,
fromSubscription: String? = nil,
expand: [String]? = nil) async throws -> SubscriptionSchedule {
var body: [String: Any] = [:]

Expand Down

0 comments on commit 4af10ac

Please sign in to comment.