From 1c3b28ea6d1202ba8b713bc8b02e31e9e65f2ec1 Mon Sep 17 00:00:00 2001 From: Andrew <8133022+andrew804@users.noreply.github.com> Date: Fri, 26 Apr 2024 15:09:14 +0100 Subject: [PATCH 1/4] Added ConnectApplication --- .../Connect/Application/Application.swift | 26 +++++++++++++++++++ .../Core Resources/Events/Event.swift | 3 +++ 2 files changed, 29 insertions(+) create mode 100644 Sources/StripeKit/Connect/Application/Application.swift diff --git a/Sources/StripeKit/Connect/Application/Application.swift b/Sources/StripeKit/Connect/Application/Application.swift new file mode 100644 index 00000000..6687b4fa --- /dev/null +++ b/Sources/StripeKit/Connect/Application/Application.swift @@ -0,0 +1,26 @@ +// +// Application.swift +// +// +// Created by Andrew Morris on 26/04/2024. +// + +import Foundation + +/// The [Application Object](https://stripe.com/docs/api/application/object) +public struct ConnectApplication: Codable { + /// Unique identifier for the object. + public var id: String + /// The name of the application. + public var name: String? + /// String representing the object’s type. Objects of the same type share the same value. + public var object: String + + public init(id: String, + name: String? = nil, + object: String) { + self.id = id + self.name = name + self.object = object + } +} diff --git a/Sources/StripeKit/Core Resources/Events/Event.swift b/Sources/StripeKit/Core Resources/Events/Event.swift index 4bb79bb4..dec095ab 100644 --- a/Sources/StripeKit/Core Resources/Events/Event.swift +++ b/Sources/StripeKit/Core Resources/Events/Event.swift @@ -67,6 +67,7 @@ public struct EventData: Codable { public enum EventObject: Codable { case account(ConnectAccount) + case application(ConnectApplication) case card(Card) case cashBalance(CashBalance) case bankAccount(BankAccount) @@ -125,6 +126,8 @@ public enum EventObject: Codable { switch object { case "account": self = try .account(ConnectAccount(from: decoder)) + case "application": + self = try .application(ConnectApplication(from: decoder)) case "application_fee": self = try .applicationFee(ApplicationFee(from: decoder)) case "card": From df8e7ab31f7642c844b1b28890bca8ef7522c677 Mon Sep 17 00:00:00 2001 From: Andrew <8133022+andrew804@users.noreply.github.com> Date: Sun, 16 Jun 2024 12:49:51 +0100 Subject: [PATCH 2/4] Corrected applicationFeePercent type --- .../Subscription Schedule/SubscriptionSchedule.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/StripeKit/Billing/Subscription Schedule/SubscriptionSchedule.swift b/Sources/StripeKit/Billing/Subscription Schedule/SubscriptionSchedule.swift index 68d81338..6fb6787b 100644 --- a/Sources/StripeKit/Billing/Subscription Schedule/SubscriptionSchedule.swift +++ b/Sources/StripeKit/Billing/Subscription Schedule/SubscriptionSchedule.swift @@ -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. @@ -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, @@ -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. @@ -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, From 0bf0cfb4aba62e081cad667501b3da2030ce9248 Mon Sep 17 00:00:00 2001 From: Andrew <8133022+andrew804@users.noreply.github.com> Date: Sun, 16 Jun 2024 12:50:09 +0100 Subject: [PATCH 3/4] Corrected fromSubscription type --- .../Subscription Schedule/SubscriptionScheduleRoutes.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/StripeKit/Billing/Subscription Schedule/SubscriptionScheduleRoutes.swift b/Sources/StripeKit/Billing/Subscription Schedule/SubscriptionScheduleRoutes.swift index f95867af..51ca0677 100644 --- a/Sources/StripeKit/Billing/Subscription Schedule/SubscriptionScheduleRoutes.swift +++ b/Sources/StripeKit/Billing/Subscription Schedule/SubscriptionScheduleRoutes.swift @@ -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. @@ -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] = [:] From 851e22728d53ba7d60792c3572fd9f8c955a185f Mon Sep 17 00:00:00 2001 From: Andrew <8133022+andrew804@users.noreply.github.com> Date: Sun, 16 Jun 2024 12:50:20 +0100 Subject: [PATCH 4/4] Added alwaysInvoice case --- .../Billing/Subscription Schedule/SubscriptionSchedule.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/StripeKit/Billing/Subscription Schedule/SubscriptionSchedule.swift b/Sources/StripeKit/Billing/Subscription Schedule/SubscriptionSchedule.swift index 6fb6787b..9a68bf29 100644 --- a/Sources/StripeKit/Billing/Subscription Schedule/SubscriptionSchedule.swift +++ b/Sources/StripeKit/Billing/Subscription Schedule/SubscriptionSchedule.swift @@ -366,6 +366,7 @@ public enum SubscriptionScheduleStatus: String, Codable { public enum SubscriptionSchedulePhaseProrationBehavior: String, Codable { case createProrations = "create_prorations" + case alwaysInvoice = "always_invoice" case none }