1
1
package appstore
2
2
3
- import "github.com/golang-jwt/jwt/v4"
3
+ import (
4
+ "github.com/golang-jwt/jwt/v4"
5
+ )
4
6
5
7
// OrderLookupResponse https://developer.apple.com/documentation/appstoreserverapi/orderlookupresponse
6
8
type OrderLookupResponse struct {
7
9
Status int `json:"status"`
8
10
SignedTransactions []string `json:"signedTransactions"`
9
11
}
10
12
11
- // TransactionInfoResponse https://developer.apple.com/documentation/appstoreserverapi/transactioninforesponse
12
- type TransactionInfoResponse struct {
13
- SignedTransactionInfo string `json:"signedTransactionInfo"`
14
- }
13
+ type Environment string
14
+
15
+ // Environment https://developer.apple.com/documentation/appstoreserverapi/environment
16
+ const (
17
+ Sandbox Environment = "Sandbox"
18
+ Production Environment = "Production"
19
+ )
15
20
16
21
// HistoryResponse https://developer.apple.com/documentation/appstoreserverapi/historyresponse
17
22
type HistoryResponse struct {
18
- AppAppleId int `json:"appAppleId"`
19
- BundleId string `json:"bundleId"`
20
- Environment string `json:"environment"`
21
- HasMore bool `json:"hasMore"`
22
- Revision string `json:"revision"`
23
- SignedTransactions []string `json:"signedTransactions"`
23
+ AppAppleId int64 `json:"appAppleId"`
24
+ BundleId string `json:"bundleId"`
25
+ Environment Environment `json:"environment"`
26
+ HasMore bool `json:"hasMore"`
27
+ Revision string `json:"revision"`
28
+ SignedTransactions []string `json:"signedTransactions"`
29
+ }
30
+
31
+ // TransactionInfoResponse https://developer.apple.com/documentation/appstoreserverapi/transactioninforesponse
32
+ type TransactionInfoResponse struct {
33
+ SignedTransactionInfo string `json:"signedTransactionInfo"`
24
34
}
25
35
26
- // RefundLookupResponse https://developer.apple.com/documentation/appstoreserverapi/refundlookupresponse
36
+ // RefundLookupResponse same as the RefundHistoryResponse https://developer.apple.com/documentation/appstoreserverapi/refundhistoryresponse
27
37
type RefundLookupResponse struct {
28
38
HasMore bool `json:"hasMore"`
29
39
Revision string `json:"revision"`
@@ -32,8 +42,8 @@ type RefundLookupResponse struct {
32
42
33
43
// StatusResponse https://developer.apple.com/documentation/appstoreserverapi/get_all_subscription_statuses
34
44
type StatusResponse struct {
35
- Environment string `json:"environment"`
36
- AppAppleId int `json:"appAppleId"`
45
+ Environment Environment `json:"environment"`
46
+ AppAppleId int64 `json:"appAppleId"`
37
47
BundleId string `json:"bundleId"`
38
48
Data []SubscriptionGroupIdentifierItem `json:"data"`
39
49
}
@@ -45,27 +55,51 @@ type SubscriptionGroupIdentifierItem struct {
45
55
46
56
type LastTransactionsItem struct {
47
57
OriginalTransactionId string `json:"originalTransactionId"`
48
- Status int `json:"status"`
58
+ Status int32 `json:"status"`
49
59
SignedRenewalInfo string `json:"signedRenewalInfo"`
50
60
SignedTransactionInfo string `json:"signedTransactionInfo"`
51
61
}
52
62
63
+ // MassExtendRenewalDateRequest https://developer.apple.com/documentation/appstoreserverapi/massextendrenewaldaterequest
64
+ type MassExtendRenewalDateRequest struct {
65
+ RequestIdentifier string `json:"requestIdentifier"`
66
+ ExtendByDays int32 `json:"extendByDays"`
67
+ ExtendReasonCode int32 `json:"extendReasonCode"`
68
+ ProductId string `json:"productId"`
69
+ StorefrontCountryCodes []string `json:"storefrontCountryCodes"`
70
+ }
71
+
53
72
// ConsumptionRequestBody https://developer.apple.com/documentation/appstoreserverapi/consumptionrequest
54
73
type ConsumptionRequestBody struct {
55
- AccountTenure int `json:"accountTenure"`
74
+ AccountTenure int32 `json:"accountTenure"`
56
75
AppAccountToken string `json:"appAccountToken"`
57
- ConsumptionStatus int `json:"consumptionStatus"`
76
+ ConsumptionStatus int32 `json:"consumptionStatus"`
58
77
CustomerConsented bool `json:"customerConsented"`
59
- DeliveryStatus int `json:"deliveryStatus"`
60
- LifetimeDollarsPurchased int `json:"lifetimeDollarsPurchased"`
61
- LifetimeDollarsRefunded int `json:"lifetimeDollarsRefunded"`
62
- Platform int `json:"platform"`
63
- PlayTime int `json:"playTime"`
78
+ DeliveryStatus int32 `json:"deliveryStatus"`
79
+ LifetimeDollarsPurchased int32 `json:"lifetimeDollarsPurchased"`
80
+ LifetimeDollarsRefunded int32 `json:"lifetimeDollarsRefunded"`
81
+ Platform int32 `json:"platform"`
82
+ PlayTime int32 `json:"playTime"`
64
83
SampleContentProvided bool `json:"sampleContentProvided"`
65
- UserStatus int `json:"userStatus"`
84
+ UserStatus int32 `json:"userStatus"`
66
85
}
67
86
87
+ // JWSRenewalInfoDecodedPayload https://developer.apple.com/documentation/appstoreserverapi/jwsrenewalinfodecodedpayload
68
88
type JWSRenewalInfoDecodedPayload struct {
89
+ AutoRenewProductId string `json:"autoRenewProductId"`
90
+ AutoRenewStatus int32 `json:"autoRenewStatus"`
91
+ Environment Environment `json:"environment"`
92
+ ExpirationIntent int32 `json:"expirationIntent"`
93
+ GracePeriodExpiresDate int64 `json:"gracePeriodExpiresDate"`
94
+ IsInBillingRetryPeriod bool `json:"isInBillingRetryPeriod"`
95
+ OfferIdentifier string `json:"offerIdentifier"`
96
+ OfferType string `json:"offerType"`
97
+ OriginalTransactionId string `json:"originalTransactionId"`
98
+ PriceIncreaseStatus int32 `json:"priceIncreaseStatus"`
99
+ ProductId string `json:"productId"`
100
+ RecentSubscriptionStartDate int64 `json:"recentSubscriptionStartDate"`
101
+ RenewalDate int64 `json:"renewalDate"`
102
+ SignedDate int64 `json:"signedDate"`
69
103
}
70
104
71
105
// JWSDecodedHeader https://developer.apple.com/documentation/appstoreserverapi/jwsdecodedheader
@@ -75,27 +109,50 @@ type JWSDecodedHeader struct {
75
109
X5C []string `json:"x5c,omitempty"`
76
110
}
77
111
112
+ // TransactionReason indicates the cause of a purchase transaction,
113
+ // https://developer.apple.com/documentation/appstoreservernotifications/transactionreason
114
+ type TransactionReason string
115
+
116
+ const (
117
+ TransactionReasonPurchase = "PURCHASE"
118
+ TransactionReasonRenewal = "RENEWAL"
119
+ )
120
+
121
+ // IAPType https://developer.apple.com/documentation/appstoreserverapi/type
122
+ type IAPType string
123
+
124
+ const (
125
+ AutoRenewable IAPType = "Auto-Renewable Subscription"
126
+ NonConsumable IAPType = "Non-Consumable"
127
+ Consumable IAPType = "Consumable"
128
+ NonRenewable IAPType = "Non-Renewing Subscription"
129
+ )
130
+
78
131
// JWSTransaction https://developer.apple.com/documentation/appstoreserverapi/jwstransaction
79
132
type JWSTransaction struct {
80
- TransactionID string `json:"transactionId,omitempty"`
81
- OriginalTransactionId string `json:"originalTransactionId,omitempty"`
82
- WebOrderLineItemId string `json:"webOrderLineItemId,omitempty"`
83
- BundleID string `json:"bundleId,omitempty"`
84
- ProductID string `json:"productId,omitempty"`
85
- SubscriptionGroupIdentifier string `json:"subscriptionGroupIdentifier,omitempty"`
86
- PurchaseDate int64 `json:"purchaseDate,omitempty"`
87
- OriginalPurchaseDate int64 `json:"originalPurchaseDate,omitempty"`
88
- ExpiresDate int64 `json:"expiresDate,omitempty"`
89
- Quantity int64 `json:"quantity,omitempty"`
90
- Type string `json:"type,omitempty"`
91
- AppAccountToken string `json:"appAccountToken,omitempty"`
92
- InAppOwnershipType string `json:"inAppOwnershipType,omitempty"`
93
- SignedDate int64 `json:"signedDate,omitempty"`
94
- OfferType int64 `json:"offerType,omitempty"`
95
- OfferIdentifier string `json:"offerIdentifier,omitempty"`
96
- RevocationDate int64 `json:"revocationDate,omitempty"`
97
- RevocationReason int `json:"revocationReason,omitempty"`
98
- IsUpgraded bool `json:"isUpgraded,omitempty"`
133
+ TransactionID string `json:"transactionId,omitempty"`
134
+ OriginalTransactionId string `json:"originalTransactionId,omitempty"`
135
+ WebOrderLineItemId string `json:"webOrderLineItemId,omitempty"`
136
+ BundleID string `json:"bundleId,omitempty"`
137
+ ProductID string `json:"productId,omitempty"`
138
+ SubscriptionGroupIdentifier string `json:"subscriptionGroupIdentifier,omitempty"`
139
+ PurchaseDate int64 `json:"purchaseDate,omitempty"`
140
+ OriginalPurchaseDate int64 `json:"originalPurchaseDate,omitempty"`
141
+ ExpiresDate int64 `json:"expiresDate,omitempty"`
142
+ Quantity int32 `json:"quantity,omitempty"`
143
+ Type IAPType `json:"type,omitempty"`
144
+ AppAccountToken string `json:"appAccountToken,omitempty"`
145
+ InAppOwnershipType string `json:"inAppOwnershipType,omitempty"`
146
+ SignedDate int64 `json:"signedDate,omitempty"`
147
+ OfferType int32 `json:"offerType,omitempty"`
148
+ OfferIdentifier string `json:"offerIdentifier,omitempty"`
149
+ RevocationDate int64 `json:"revocationDate,omitempty"`
150
+ RevocationReason int32 `json:"revocationReason,omitempty"`
151
+ IsUpgraded bool `json:"isUpgraded,omitempty"`
152
+ Storefront string `json:"storefront,omitempty"`
153
+ StorefrontId string `json:"storefrontId,omitempty"`
154
+ TransactionReason TransactionReason `json:"transactionReason,omitempty"`
155
+ Environment Environment `json:"environment,omitempty"`
99
156
}
100
157
101
158
func (J JWSTransaction ) Valid () error {
@@ -114,18 +171,29 @@ const (
114
171
115
172
// ExtendRenewalDateRequest https://developer.apple.com/documentation/appstoreserverapi/extendrenewaldaterequest
116
173
type ExtendRenewalDateRequest struct {
117
- ExtendByDays int `json:"extendByDays"`
174
+ ExtendByDays int32 `json:"extendByDays"`
118
175
ExtendReasonCode ExtendReasonCode `json:"extendReasonCode"`
119
176
RequestIdentifier string `json:"requestIdentifier"`
120
177
}
121
178
179
+ // MassExtendRenewalDateStatusResponse https://developer.apple.com/documentation/appstoreserverapi/massextendrenewaldatestatusresponse
180
+ type MassExtendRenewalDateStatusResponse struct {
181
+ RequestIdentifier string `json:"requestIdentifier"`
182
+ Complete bool `json:"complete"`
183
+ CompleteDate int64 `json:"completeDate,omitempty"`
184
+ FailedCount int64 `json:"failedCount,omitempty"`
185
+ SucceededCount int64 `json:"succeededCount,omitempty"`
186
+ }
187
+
122
188
// NotificationHistoryRequest https://developer.apple.com/documentation/appstoreserverapi/notificationhistoryrequest
123
189
type NotificationHistoryRequest struct {
124
190
StartDate int64 `json:"startDate"`
125
191
EndDate int64 `json:"endDate"`
126
192
OriginalTransactionId string `json:"originalTransactionId,omitempty"`
127
193
NotificationType NotificationTypeV2 `json:"notificationType,omitempty"`
128
194
NotificationSubtype SubtypeV2 `json:"notificationSubtype,omitempty"`
195
+ OnlyFailures bool `json:"onlyFailures"`
196
+ TransactionId string `json:"transactionId"`
129
197
}
130
198
131
199
type NotificationTypeV2 string
@@ -181,6 +249,13 @@ type NotificationHistoryResponses struct {
181
249
type NotificationHistoryResponseItem struct {
182
250
SignedPayload string `json:"signedPayload"`
183
251
FirstSendAttemptResult FirstSendAttemptResult `json:"firstSendAttemptResult"`
252
+ SendAttempts []SendAttemptItem `json:"sendAttempts"`
253
+ }
254
+
255
+ // SendAttemptItem https://developer.apple.com/documentation/appstoreserverapi/sendattemptitem
256
+ type SendAttemptItem struct {
257
+ AttemptDate int64 `json:"attemptDate"`
258
+ SendAttemptResult FirstSendAttemptResult `json:"sendAttemptResult"`
184
259
}
185
260
186
261
// https://developer.apple.com/documentation/appstoreserverapi/firstsendattemptresult
0 commit comments