Skip to content

Commit

Permalink
Send correct platform value for App Store purchase options (#747)
Browse files Browse the repository at this point in the history
* For App Store purchase flow use proper platform when sendind purchase options

* Also send correct plaform value for empty options object
  • Loading branch information
miasma13 authored Mar 25, 2024
1 parent 918c7ef commit 5fb0b91
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Sources/Subscription/Flows/AppStore/AppStorePurchaseFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@ public final class AppStorePurchaseFlow {

let features = SubscriptionFeatureName.allCases.map { SubscriptionFeature(name: $0.rawValue) }

return .success(SubscriptionOptions(platform: SubscriptionPlatformName.macos.rawValue,
let platform: SubscriptionPlatformName

#if os(iOS)
platform = .ios
#else
platform = .macos
#endif

return .success(SubscriptionOptions(platform: platform.rawValue,
options: options,
features: features))
}
Expand Down
9 changes: 8 additions & 1 deletion Sources/Subscription/Flows/PurchaseFlow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ public struct SubscriptionOptions: Encodable {
let features: [SubscriptionFeature]
public static var empty: SubscriptionOptions {
let features = SubscriptionFeatureName.allCases.map { SubscriptionFeature(name: $0.rawValue) }
return SubscriptionOptions(platform: "macos", options: [], features: features)
let platform: SubscriptionPlatformName
#if os(iOS)
platform = .ios
#else
platform = .macos
#endif
return SubscriptionOptions(platform: platform.rawValue, options: [], features: features)
}
}

Expand Down Expand Up @@ -55,6 +61,7 @@ public enum SubscriptionFeatureName: String, CaseIterable {
}

public enum SubscriptionPlatformName: String {
case ios
case macos
case stripe
}
Expand Down

0 comments on commit 5fb0b91

Please sign in to comment.