Skip to content

Commit 72a92d1

Browse files
committed
update store kit model
1 parent 540e117 commit 72a92d1

File tree

3 files changed

+60
-16
lines changed

3 files changed

+60
-16
lines changed

Sources/NWSharedModels/AppStoreVerifyReceipt/VerifyReceiptInput.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,17 @@ public struct VerifyReceiptInput: Equatable, Codable {
44

55
public init(
66
receiptData: Data,
7-
excludeOldTransactions: Bool? = nil,
8-
password: String
7+
excludeOldTransactions: Bool? = nil
98
) {
109
self.receiptData = receiptData
1110
self.excludeOldTransactions = excludeOldTransactions
12-
self.password = password
1311
}
1412
public let receiptData: Data
1513
public let excludeOldTransactions: Bool?
16-
public let password: String
1714

1815
enum CodingKeys: String, CodingKey {
1916
case receiptData = "receipt-data"
2017
case excludeOldTransactions = "exclude-old-transactions"
21-
case password
2218
}
2319
}
2420

Sources/NWSharedModels/ComposableStoreKit/AppleVerifyReceiptResponse.swift

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,25 @@ public struct AppleVerifyReceiptResponse: Equatable, Sendable {
66
public var receipt: Receipt
77
public var status: Int
88

9+
public init(
10+
environment: AppleVerifyReceiptResponse.Environment? = nil,
11+
isRetryable: Bool,
12+
receipt: AppleVerifyReceiptResponse.Receipt,
13+
status: Int
14+
) {
15+
self.environment = environment
16+
self.isRetryable = isRetryable
17+
self.receipt = receipt
18+
self.status = status
19+
}
20+
921
public enum Environment: String, Codable, Equatable, Sendable {
1022
case sandbox = "Sandbox"
1123
case production = "Production"
1224
}
1325

14-
public struct Receipt: Equatable, Sendable {
26+
public struct Receipt: Equatable, Sendable {
27+
1528
public var appItemId: Int
1629
public var applicationVersion: String
1730
public var bundleId: String
@@ -20,13 +33,47 @@ public struct AppleVerifyReceiptResponse: Equatable, Sendable {
2033
public var receiptCreationDate: Date
2134
public var requestDate: Date
2235

23-
public struct InApp: Equatable, Sendable {
24-
public var originalPurchaseDate: Date
25-
public var originalTransactionId: String
26-
public var productId: String
27-
public var purchaseDate: Date
28-
public var quantity: Int
29-
public var transactionId: String
36+
public init(
37+
appItemId: Int,
38+
applicationVersion: String,
39+
bundleId: String,
40+
inApp: [AppleVerifyReceiptResponse.Receipt.InApp],
41+
originalPurchaseDate: Date,
42+
receiptCreationDate: Date,
43+
requestDate: Date
44+
) {
45+
self.appItemId = appItemId
46+
self.applicationVersion = applicationVersion
47+
self.bundleId = bundleId
48+
self.inApp = inApp
49+
self.originalPurchaseDate = originalPurchaseDate
50+
self.receiptCreationDate = receiptCreationDate
51+
self.requestDate = requestDate
52+
}
53+
54+
public struct InApp: Equatable, Sendable {
55+
public var originalPurchaseDate: Date
56+
public var originalTransactionId: String
57+
public var productId: String
58+
public var purchaseDate: Date
59+
public var quantity: Int
60+
public var transactionId: String
61+
62+
public init(
63+
originalPurchaseDate: Date,
64+
originalTransactionId: String,
65+
productId: String,
66+
purchaseDate: Date,
67+
quantity: Int,
68+
transactionId: String
69+
) {
70+
self.originalPurchaseDate = originalPurchaseDate
71+
self.originalTransactionId = originalTransactionId
72+
self.productId = productId
73+
self.purchaseDate = purchaseDate
74+
self.quantity = quantity
75+
self.transactionId = transactionId
76+
}
3077
}
3178
}
3279
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import URLRouting
2+
import Foundation
23

34
public enum AppStoreRoute: Equatable {
4-
case verifyReceipt(input: VerifyReceiptInput)
5+
case verifyReceipt(Data)
56
}
67

78
public let appStoreRouter = OneOf {
89
Route(.case(AppStoreRoute.verifyReceipt)) {
9-
Path { "verify_receipt" }
1010
Method.post
11-
Body(.json(VerifyReceiptInput.self))
11+
Path { "verify-receipt" }
12+
Body()
1213
}
1314
}

0 commit comments

Comments
 (0)