Skip to content

Commit d2e4d25

Browse files
committed
Add support for additional purchase options
1 parent 022d35d commit d2e4d25

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

RELEASE_NOTES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ StoreKitPlus will use semver after 1.0.
55
Until then, deprecated features may be removed in any minor version, and breaking changes introduced.
66

77

8+
9+
## 0.7
10+
11+
### ✨ Features
12+
13+
* `StoreService` now lets you pass in optional purchase options.
14+
15+
16+
817
## 0.6
918

1019
This version removes deprecated code and adjusts some service terminology.

Sources/StoreKitPlus/Services/StandardStoreService.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,18 @@ open class StandardStoreService: StoreService {
6969
open func getProducts() async throws -> [Product] {
7070
try await Product.products(for: productIds)
7171
}
72-
72+
7373
@discardableResult
7474
open func purchase(
7575
_ product: Product
76+
) async throws -> (Product.PurchaseResult, Transaction?) {
77+
try await purchase(product, options: [])
78+
}
79+
80+
@discardableResult
81+
open func purchase(
82+
_ product: Product,
83+
options: Set<Product.PurchaseOption>
7684
) async throws -> (Product.PurchaseResult, Transaction?) {
7785
#if os(visionOS)
7886
throw StoreServiceError.unsupportedPlatform("This purchase operation is not supported in visionOS: Use @Environment(\\.purchase) instead.")

Sources/StoreKitPlus/Services/StoreService.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,24 @@ public protocol StoreService {
2424
func getValidProductTransations() async throws -> [Transaction]
2525

2626
/// Purchase a certain product.
27+
///
28+
/// - Parameters:
29+
/// - product: The product to purchase.
2730
@discardableResult
2831
func purchase(
2932
_ product: Product
3033
) async throws -> (Product.PurchaseResult, Transaction?)
34+
35+
/// Purchase a certain product.
36+
///
37+
/// - Parameters:
38+
/// - product: The product to purchase.
39+
/// - options: Additional purchase options.
40+
@discardableResult
41+
func purchase(
42+
_ product: Product,
43+
options: Set<Product.PurchaseOption>
44+
) async throws -> (Product.PurchaseResult, Transaction?)
3145

3246
/// Sync StoreKit products and purchases to a context.
3347
func syncStoreData(

0 commit comments

Comments
 (0)