Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit 4ba7c2a

Browse files
committed
Bump version to 1.1.0
1 parent d137434 commit 4ba7c2a

File tree

14 files changed

+325
-269
lines changed

14 files changed

+325
-269
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"hyodotdev",
44
"netrc",
55
"openiap",
6+
"skus",
67
"swiftpm",
78
"tvos",
89
"watchos",

Example/OpenIapExample/Screens/AvailablePurchasesScreen.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct AvailablePurchasesScreen: View {
5252
}
5353
}
5454

55-
private var uniqueActivePurchases: [IapPurchase] {
55+
private var uniqueActivePurchases: [OpenIapPurchase] {
5656
let allActivePurchases = store.purchases.filter { purchase in
5757
// Show unconsumed consumables and active subscriptions
5858
purchase.purchaseState == .purchased && (
@@ -65,7 +65,7 @@ struct AvailablePurchasesScreen: View {
6565
}
6666

6767
// Group by productId and take only the latest purchase for each subscription
68-
var uniquePurchases: [IapPurchase] = []
68+
var uniquePurchases: [OpenIapPurchase] = []
6969
var seenSubscriptions: Set<String> = []
7070

7171
for purchase in allActivePurchases.sorted(by: { $0.purchaseTime > $1.purchaseTime }) {
@@ -140,7 +140,7 @@ struct AvailablePurchasesScreen: View {
140140

141141
// MARK: - Active Purchase Card (For Available Purchases)
142142
struct ActivePurchaseCard: View {
143-
let purchase: IapPurchase
143+
let purchase: OpenIapPurchase
144144
let onConsume: () -> Void
145145

146146
private var isSubscription: Bool {
@@ -209,7 +209,7 @@ struct ActivePurchaseCard: View {
209209

210210
// MARK: - Purchase History Card
211211
struct PurchaseHistoryCard: View {
212-
let purchase: IapPurchase
212+
let purchase: OpenIapPurchase
213213

214214
private var statusColor: Color {
215215
switch purchase.purchaseState {
@@ -285,7 +285,7 @@ struct PurchaseHistoryCard: View {
285285

286286
// MARK: - Original Purchase Card (Deprecated)
287287
struct PurchaseCard: View {
288-
let purchase: IapPurchase
288+
let purchase: OpenIapPurchase
289289
let onConsume: () -> Void
290290

291291
private var isSubscription: Bool {

Example/OpenIapExample/Screens/PurchaseFlowScreen.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct PurchaseFlowScreen: View {
6262
}
6363

6464
struct ProductCard: View {
65-
let product: IapProductData
65+
let product: OpenIapProductData
6666
let isLoading: Bool
6767
let onPurchase: () -> Void
6868

@@ -412,7 +412,7 @@ struct HeaderCardView: View {
412412
struct ProductsContentView: View {
413413
@ObservedObject var store: StoreViewModel
414414

415-
var consumableProducts: [IapProductData] {
415+
var consumableProducts: [OpenIapProductData] {
416416
store.products.filter { product in
417417
// Filter out premium subscription products
418418
!product.id.contains("premium") && product.type == "inapp"

Example/OpenIapExample/Screens/SubscriptionFlowScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ struct SubscriptionFlowScreen: View {
122122
}
123123

124124
struct SubscriptionCard: View {
125-
let product: IapProductData
125+
let product: OpenIapProductData
126126
let isSubscribed: Bool
127127
let isLoading: Bool
128128
let onSubscribe: () -> Void

Example/OpenIapExample/ViewModels/StoreViewModel.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import OpenIAP
44
@MainActor
55
@available(iOS 15.0, *)
66
class StoreViewModel: ObservableObject {
7-
@Published var products: [IapProductData] = []
8-
@Published var purchases: [IapPurchase] = []
7+
@Published var products: [OpenIapProductData] = []
8+
@Published var purchases: [OpenIapPurchase] = []
99
@Published var isLoading = false
1010
@Published var showError = false
1111
@Published var errorMessage = ""
1212
@Published var purchasingProductIds: Set<String> = []
1313
@Published var showPurchaseSuccess = false
14-
@Published var lastPurchasedProduct: IapProductData?
14+
@Published var lastPurchasedProduct: OpenIapProductData?
1515
@Published var isConnectionInitialized = false
1616

17-
private let iapModule = IapModule.shared
17+
private let iapModule = OpenIapModule.shared
1818

1919
init() {
2020
setupStoreKit()
@@ -109,7 +109,7 @@ class StoreViewModel: ObservableObject {
109109
isLoading = false
110110
}
111111

112-
func purchaseProduct(_ product: IapProductData) {
112+
func purchaseProduct(_ product: OpenIapProductData) {
113113
// Start loading state for this specific product
114114
purchasingProductIds.insert(product.id)
115115

@@ -133,7 +133,7 @@ class StoreViewModel: ObservableObject {
133133
} else {
134134
print("❌ Purchase failed")
135135
await MainActor.run {
136-
handlePurchaseError(IapError.purchaseFailed(reason: "Unknown error"), productId: product.id)
136+
handlePurchaseError(OpenIapError.purchaseFailed(reason: "Unknown error"), productId: product.id)
137137
}
138138
}
139139
} catch {
@@ -145,7 +145,7 @@ class StoreViewModel: ObservableObject {
145145
}
146146
}
147147

148-
func finishPurchase(_ purchase: IapPurchase) async {
148+
func finishPurchase(_ purchase: OpenIapPurchase) async {
149149
do {
150150
// In iOS, there's no distinction between consumable and non-consumable for finishing transactions
151151
// The product type is determined by App Store Connect configuration

Example/OpenIapExample/ViewModels/TransactionObserver.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import OpenIAP
44
@MainActor
55
@available(iOS 15.0, *)
66
class TransactionObserver: ObservableObject {
7-
@Published var latestPurchase: IapPurchase?
7+
@Published var latestPurchase: OpenIapPurchase?
88
@Published var errorMessage: String?
99
@Published var isPending = false
1010

11-
private let iapModule = IapModule.shared
11+
private let iapModule = OpenIapModule.shared
1212

1313
init() {
1414
setupListeners()
@@ -36,14 +36,14 @@ class TransactionObserver: ObservableObject {
3636
}
3737
}
3838

39-
private func handlePurchaseUpdated(_ purchase: IapPurchase) {
39+
private func handlePurchaseUpdated(_ purchase: OpenIapPurchase) {
4040
print("✅ Purchase successful: \(purchase.productId)")
4141
latestPurchase = purchase
4242
isPending = false
4343
errorMessage = nil
4444
}
4545

46-
private func handlePurchaseError(_ error: IapError) {
46+
private func handlePurchaseError(_ error: OpenIapError) {
4747
print("❌ Purchase failed: \(error)")
4848
errorMessage = error.localizedDescription
4949
isPending = false

Sources/Models/AppTransaction.swift

Lines changed: 15 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import StoreKit
33

44
@available(iOS 16.0, macOS 13.0, *)
5-
public struct IapAppTransaction: Codable {
5+
public struct OpenIapAppTransaction: Codable {
66
public let bundleId: String
77
public let appVersion: String
88
public let originalAppVersion: String
@@ -21,7 +21,7 @@ public struct IapAppTransaction: Codable {
2121
}
2222

2323
@available(iOS 16.0, macOS 13.0, *)
24-
extension IapAppTransaction {
24+
extension OpenIapAppTransaction {
2525
init(from appTransaction: AppTransaction) {
2626
self.bundleId = appTransaction.bundleID
2727
self.appVersion = appTransaction.appVersion
@@ -50,12 +50,12 @@ extension IapAppTransaction {
5050
}
5151
}
5252

53-
public struct IapSubscriptionStatus: Codable {
53+
public struct OpenIapSubscriptionStatus: Codable {
5454
public let state: String
55-
public let renewalInfo: IapRenewalInfo?
55+
public let renewalInfo: OpenIapRenewalInfo?
5656
}
5757

58-
public struct IapRenewalInfo: Codable {
58+
public struct OpenIapRenewalInfo: Codable {
5959
public let autoRenewStatus: Bool
6060
public let autoRenewPreference: String?
6161
public let expirationReason: Int?
@@ -64,16 +64,16 @@ public struct IapRenewalInfo: Codable {
6464
public let gracePeriodExpirationDate: Date?
6565
}
6666

67-
public struct IapValidationResult: Codable {
67+
public struct OpenIapValidationResult: Codable {
6868
public let isValid: Bool
6969
public let receiptData: String
7070
public let jwsRepresentation: String
71-
public let latestTransaction: IapPurchase?
71+
public let latestTransaction: OpenIapPurchase?
7272
}
7373

7474
// MARK: - Product and Transaction serialization models
7575

76-
public struct IapProductData: Codable {
76+
public struct OpenIapProductData: Codable {
7777
public let id: String
7878
public let title: String
7979
public let description: String
@@ -95,67 +95,26 @@ public struct IapProductData: Codable {
9595
}
9696
}
9797

98-
public struct IapTransactionData: Codable {
99-
public let id: String
100-
public let productId: String
101-
public let transactionId: String
102-
public let transactionDate: Double
103-
public let transactionReceipt: String
104-
public let platform: String
105-
public let quantityIOS: Int
106-
public let originalTransactionDateIOS: Double
107-
public let originalTransactionIdentifierIOS: String
108-
public let appAccountToken: String?
109-
public let productTypeIOS: String
110-
public let isUpgradedIOS: Bool
111-
public let ownershipTypeIOS: String
112-
public let revocationDateIOS: Double?
113-
public let revocationReasonIOS: Int?
114-
public let expirationDateIOS: Double?
115-
public let jwsRepresentationIOS: String?
116-
public let purchaseToken: String?
117-
public let environmentIOS: String?
118-
119-
public init(id: String, productId: String, transactionId: String, transactionDate: Double, transactionReceipt: String, platform: String = "ios", quantityIOS: Int, originalTransactionDateIOS: Double, originalTransactionIdentifierIOS: String, appAccountToken: String?, productTypeIOS: String, isUpgradedIOS: Bool, ownershipTypeIOS: String, revocationDateIOS: Double?, revocationReasonIOS: Int?, expirationDateIOS: Double?, jwsRepresentationIOS: String?, purchaseToken: String?, environmentIOS: String?) {
120-
self.id = id
121-
self.productId = productId
122-
self.transactionId = transactionId
123-
self.transactionDate = transactionDate
124-
self.transactionReceipt = transactionReceipt
125-
self.platform = platform
126-
self.quantityIOS = quantityIOS
127-
self.originalTransactionDateIOS = originalTransactionDateIOS
128-
self.originalTransactionIdentifierIOS = originalTransactionIdentifierIOS
129-
self.appAccountToken = appAccountToken
130-
self.productTypeIOS = productTypeIOS
131-
self.isUpgradedIOS = isUpgradedIOS
132-
self.ownershipTypeIOS = ownershipTypeIOS
133-
self.revocationDateIOS = revocationDateIOS
134-
self.revocationReasonIOS = revocationReasonIOS
135-
self.expirationDateIOS = expirationDateIOS
136-
self.jwsRepresentationIOS = jwsRepresentationIOS
137-
self.purchaseToken = purchaseToken
138-
self.environmentIOS = environmentIOS
139-
}
140-
}
98+
// IapTransactionData is deprecated - use OpenIapPurchase instead
99+
// This type has been merged into OpenIapPurchase for better API consistency
141100

142-
public struct IapPromotedProduct: Codable {
101+
public struct OpenIapPromotedProduct: Codable {
143102
public let productIdentifier: String
144103
public let localizedTitle: String
145104
public let localizedDescription: String
146105
public let price: Double
147-
public let priceLocale: IapPriceLocale
106+
public let priceLocale: OpenIapPriceLocale
148107
}
149108

150-
public struct IapPriceLocale: Codable {
109+
public struct OpenIapPriceLocale: Codable {
151110
public let currencyCode: String
152111
public let currencySymbol: String
153112
public let countryCode: String
154113
}
155114

156-
public struct IapReceiptValidation: Codable {
115+
public struct OpenIapReceiptValidation: Codable {
157116
public let isValid: Bool
158117
public let receiptData: String
159118
public let jwsRepresentation: String
160-
public let latestTransaction: IapTransactionData?
119+
public let latestTransaction: OpenIapPurchase?
161120
}

Sources/Models/Product.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22
import StoreKit
33

4-
public struct IapProduct: Codable, Equatable {
4+
public struct OpenIapProduct: Codable, Equatable {
55
public let productId: String
66
public let productType: ProductType
77
public let localizedTitle: String
@@ -68,7 +68,7 @@ public struct IapProduct: Codable, Equatable {
6868
}
6969

7070
@available(iOS 15.0, macOS 12.0, *)
71-
extension IapProduct {
71+
extension OpenIapProduct {
7272
init(from product: Product) async {
7373
self.productId = product.id
7474
self.localizedTitle = product.displayName
@@ -135,7 +135,7 @@ extension IapProduct {
135135

136136
@available(iOS 15.0, macOS 12.0, *)
137137
extension Product.SubscriptionPeriod.Unit {
138-
func toPeriodUnit() -> IapProduct.SubscriptionPeriod.PeriodUnit {
138+
func toPeriodUnit() -> OpenIapProduct.SubscriptionPeriod.PeriodUnit {
139139
switch self {
140140
case .day:
141141
return .day
@@ -153,7 +153,7 @@ extension Product.SubscriptionPeriod.Unit {
153153

154154
@available(iOS 15.0, macOS 12.0, *)
155155
extension Product.SubscriptionOffer.PaymentMode {
156-
func toPaymentMode() -> IapProduct.IntroductoryOffer.PaymentMode {
156+
func toPaymentMode() -> OpenIapProduct.IntroductoryOffer.PaymentMode {
157157
switch self {
158158
case .payAsYouGo:
159159
return .payAsYouGo

0 commit comments

Comments
 (0)