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

Commit 865ff91

Browse files
committed
docs: update readme
1 parent 49e30cf commit 865ff91

File tree

1 file changed

+80
-36
lines changed

1 file changed

+80
-36
lines changed

README.md

Lines changed: 80 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,24 @@ Visit [**openiap.dev**](https://openiap.dev) for complete documentation, guides,
2222

2323
-**StoreKit 2** support with full iOS 15+ compatibility
2424
-**Cross-platform** support (iOS, macOS, tvOS, watchOS)
25+
-**Thread-safe** operations with MainActor isolation
2526
-**Unified API** following OpenIAP specification
2627
-**Product management** with intelligent caching
2728
-**Purchase handling** with automatic transaction verification
28-
-**Subscription management** and renewal tracking
29+
-**Subscription management** with cancel/reactivate support
2930
-**Receipt validation** and transaction security
3031
-**Event-driven** purchase observation
3132
-**Swift Package Manager** and **CocoaPods** support
3233

3334
## 📋 Requirements
3435

3536
| Platform | Minimum Version |
36-
|----------|-----------------|
37-
| iOS | 15.0+ |
38-
| macOS | 14.0+ |
39-
| tvOS | 15.0+ |
40-
| watchOS | 8.0+ |
41-
| Swift | 5.9+ |
37+
| -------- | --------------- |
38+
| iOS | 15.0+ |
39+
| macOS | 14.0+ |
40+
| tvOS | 15.0+ |
41+
| watchOS | 8.0+ |
42+
| Swift | 5.9+ |
4243

4344
## 📦 Installation
4445

@@ -53,6 +54,7 @@ dependencies: [
5354
```
5455

5556
Or through Xcode:
57+
5658
1. **File****Add Package Dependencies**
5759
2. Enter: `https://github.com/hyodotdev/openiap-apple.git`
5860
3. Select version and add to your target
@@ -78,7 +80,7 @@ pod install
7880
```swift
7981
import OpenIAP
8082

81-
// Initialize the IAP connection
83+
// Initialize the IAP connection (thread-safe with MainActor isolation)
8284
try await OpenIapModule.shared.initConnection()
8385
```
8486

@@ -126,10 +128,11 @@ OpenIapModule.shared.addPurchaseErrorListener { error in
126128
The repository includes a complete **SwiftUI example app** demonstrating all OpenIAP features:
127129

128130
- **Product catalog** with real-time pricing
129-
- **Purchase flow** with loading states and error handling
130-
- **Subscription management** with renewal tracking
131+
- **Purchase flow** with loading states and error handling
132+
- **Subscription management** with renewal tracking, cancel/reactivate support
131133
- **Purchase history** and transaction details
132134
- **Event logging** for debugging and monitoring
135+
- **Sandbox debug tools** integrated into My Purchases section
133136

134137
Run the example:
135138

@@ -157,45 +160,96 @@ swift test
157160
3. Use test card: `4242 4242 4242 4242`
158161
4. Monitor purchase events in the Example app logs
159162

163+
### Server-Side Validation
164+
165+
OpenIAP provides comprehensive transaction verification with server-side receipt validation examples:
166+
167+
```swift
168+
// Transaction finishing with validation
169+
let transaction = try await OpenIapModule.shared.requestPurchase(
170+
sku: "dev.hyo.premium",
171+
andDangerouslyFinishTransactionAutomatically: false // Validate server-side first
172+
)
173+
174+
// Validate on your server using jwsRepresentation
175+
// Then finish the transaction manually
176+
try await transaction.finish()
177+
```
178+
160179
## 📚 Data Models
161180

162181
### OpenIapProduct
163182

164183
```swift
165184
struct OpenIapProduct {
185+
// Common properties
166186
let id: String
167-
let productType: ProductType
168-
let localizedTitle: String
169-
let localizedDescription: String
170-
let price: Decimal
171-
let localizedPrice: String
172-
let currencyCode: String?
173-
let countryCode: String?
174-
let subscriptionPeriod: SubscriptionPeriod?
175-
let introductoryPrice: IntroductoryOffer?
187+
let title: String
188+
let description: String
189+
let type: String // "inapp" or "subs"
190+
let displayPrice: String
191+
let currency: String
192+
let price: Double?
176193
let platform: String
194+
195+
// iOS-specific properties
196+
let displayNameIOS: String
197+
let typeIOS: ProductTypeIOS
198+
let subscriptionInfoIOS: SubscriptionInfo?
199+
let discountsIOS: [Discount]?
200+
let isFamilyShareableIOS: Bool
201+
}
202+
203+
enum ProductTypeIOS {
204+
case consumable
205+
case nonConsumable
206+
case autoRenewableSubscription
207+
case nonRenewingSubscription
208+
209+
var isSubs: Bool { /* returns true for autoRenewableSubscription */ }
177210
}
178211
```
179212

180213
### OpenIapPurchase
181214

182215
```swift
183216
struct OpenIapPurchase {
217+
// Common properties
184218
let id: String // Transaction ID
185219
let productId: String
186-
let transactionId: String
187-
let purchaseTime: Date
220+
let transactionDate: Double // Unix timestamp in milliseconds
221+
let transactionReceipt: String
188222
let purchaseState: PurchaseState
189-
let acknowledgementState: AcknowledgementState
190223
let isAutoRenewing: Bool
191224
let quantity: Int
192-
193-
// iOS-specific StoreKit 2 properties
225+
let platform: String
226+
227+
// iOS-specific properties
228+
let appAccountToken: String?
194229
let environmentIOS: String?
195230
let storefrontCountryCodeIOS: String?
196-
let jwsRepresentation: String?
231+
let productTypeIOS: String?
232+
let subscriptionGroupIdIOS: String?
233+
let transactionReasonIOS: String? // "PURCHASE" | "RENEWAL"
234+
let offerIOS: PurchaseOffer?
197235
// ... additional properties
198236
}
237+
238+
enum PurchaseState {
239+
case pending, purchased, failed, restored, deferred, unknown
240+
}
241+
```
242+
243+
### DiscountOffer
244+
245+
```swift
246+
struct DiscountOffer {
247+
let identifier: String
248+
let keyIdentifier: String
249+
let nonce: String
250+
let signature: String
251+
let timestamp: String
252+
}
199253
```
200254

201255
## ⚡ Error Handling
@@ -214,16 +268,6 @@ enum OpenIapError: LocalizedError {
214268
}
215269
```
216270

217-
## 🔗 OpenIAP Ecosystem
218-
219-
| Platform | Repository | Status |
220-
|----------|------------|---------|
221-
| **Specification** | [openiap.dev](https://github.com/hyodotdev/openiap.dev) | ✅ Active |
222-
| **Apple** | [openiap-apple](https://github.com/hyodotdev/openiap-apple) | ✅ Active |
223-
| **React Native** | Coming Soon | 🚧 Planned |
224-
| **Flutter** | Coming Soon | 🚧 Planned |
225-
| **Unity** | Coming Soon | 🚧 Planned |
226-
227271
## 🤝 Contributing
228272

229273
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
@@ -243,4 +287,4 @@ This project is licensed under the **MIT License** - see the [LICENSE](LICENSE)
243287

244288
<div align="center">
245289
<strong>Built with ❤️ for the OpenIAP community</strong>
246-
</div>
290+
</div>

0 commit comments

Comments
 (0)