@@ -17,9 +17,12 @@ const (
17
17
NotificationTypeV2PriceIncrease NotificationTypeV2 = "PRICE_INCREASE"
18
18
NotificationTypeV2Refund NotificationTypeV2 = "REFUND"
19
19
NotificationTypeV2RefundDeclined NotificationTypeV2 = "REFUND_DECLINED"
20
+ NotificationTyp2V2RefundReversed NotificationTypeV2 = "REFUND_REVERSED"
20
21
NotificationTypeV2RenewalExtended NotificationTypeV2 = "RENEWAL_EXTENDED"
22
+ NotificationTypeV2RenewalExtension NotificationTypeV2 = "RENEWAL_EXTENSION"
21
23
NotificationTypeV2Revoke NotificationTypeV2 = "REVOKE"
22
24
NotificationTypeV2Subscribed NotificationTypeV2 = "SUBSCRIBED"
25
+ NotificationTyp2V2Test NotificationTypeV2 = "TEST"
23
26
)
24
27
25
28
// SubtypeV2 is type
@@ -28,19 +31,22 @@ type SubtypeV2 string
28
31
// list of subtypes
29
32
// https://developer.apple.com/documentation/appstoreservernotifications/subtype
30
33
const (
31
- SubTypeV2InitialBuy = "INITIAL_BUY"
32
- SubTypeV2Resubscribe = "RESUBSCRIBE"
33
- SubTypeV2Downgrade = "DOWNGRADE"
34
- SubTypeV2Upgrade = "UPGRADE"
35
- SubTypeV2AutoRenewEnabled = "AUTO_RENEW_ENABLED"
34
+ SubTypeV2Accepted = "ACCEPTED"
36
35
SubTypeV2AutoRenewDisabled = "AUTO_RENEW_DISABLED"
37
- SubTypeV2Voluntary = "VOLUNTARY"
36
+ SubTypeV2AutoRenewEnabled = "AUTO_RENEW_ENABLED"
37
+ SubTypeV2BillingRecovery = "BILLING_RECOVERY"
38
38
SubTypeV2BillingRetry = "BILLING_RETRY"
39
- SubTypeV2PriceIncrease = "PRICE_INCREASE"
39
+ SubTypeV2Downgrade = "DOWNGRADE"
40
+ SubTypeV2Failure = "FAILURE"
40
41
SubTypeV2GracePeriod = "GRACE_PERIOD"
41
- SubTypeV2BillingRecovery = "BILLING_RECOVERY "
42
+ SubTypeV2InitialBuy = "INITIAL_BUY "
42
43
SubTypeV2Pending = "PENDING"
43
- SubTypeV2Accepted = "ACCEPTED"
44
+ SubTypeV2PriceIncrease = "PRICE_INCREASE"
45
+ SubTypeV2ProductNotForSale = "PRODUCT_NOT_FOR_SALE"
46
+ SubTypeV2Resubscribe = "RESUBSCRIBE"
47
+ SubTypeV2Summary = "SUMMARY"
48
+ SubTypeV2Upgrade = "UPGRADE"
49
+ SubTypeV2Voluntary = "VOLUNTARY"
44
50
)
45
51
46
52
type AutoRenewStatus int
@@ -90,6 +96,28 @@ const (
90
96
NonRenewable IAPType = "Non-Renewing Subscription"
91
97
)
92
98
99
+ // AutoRenewableSubscriptionStatus status value is current as of the signedDate in the decoded payload, SubscriptionNotificationV2DecodedPayload.
100
+ // https://developer.apple.com/documentation/appstoreservernotifications/status
101
+ type AutoRenewableSubscriptionStatus int32
102
+
103
+ const (
104
+ AutoRenewableSubscriptionStatusActive = iota + 1
105
+ AutoRenewableSubscriptionStatusExpired
106
+ AutoRenewableSubscriptionStatusBillingRetryPeriod
107
+ AutoRenewableSubscriptionStatusBillingGracePeriod
108
+ AutoRenewableSubscriptionStatusRevoked
109
+ )
110
+
111
+ // TransactionReason indicates the cause of a purchase transaction,
112
+ // which indicates whether it’s a customer’s purchase or a renewal for an auto-renewable subscription that the system initiates.
113
+ // https://developer.apple.com/documentation/appstoreservernotifications/transactionreason
114
+ type TransactionReason string
115
+
116
+ const (
117
+ TransactionReasonPurchase = "PURCHASE"
118
+ TransactionReasonRenewal = "RENEWAL"
119
+ )
120
+
93
121
type (
94
122
// SubscriptionNotificationV2 is struct for
95
123
// https://developer.apple.com/documentation/appstoreservernotifications/responsebodyv2
@@ -131,12 +159,13 @@ type (
131
159
// SubscriptionNotificationV2Data is struct
132
160
// https://developer.apple.com/documentation/appstoreservernotifications/data
133
161
SubscriptionNotificationV2Data struct {
134
- AppAppleID int `json:"appAppleId"`
135
- BundleID string `json:"bundleId"`
136
- BundleVersion string `json:"bundleVersion"`
137
- Environment string `json:"environment"`
138
- SignedRenewalInfo JWSRenewalInfo `json:"signedRenewalInfo"`
139
- SignedTransactionInfo JWSTransaction `json:"signedTransactionInfo"`
162
+ AppAppleID int `json:"appAppleId"`
163
+ BundleID string `json:"bundleId"`
164
+ BundleVersion string `json:"bundleVersion"`
165
+ Environment string `json:"environment"`
166
+ SignedRenewalInfo JWSRenewalInfo `json:"signedRenewalInfo"`
167
+ SignedTransactionInfo JWSTransaction `json:"signedTransactionInfo"`
168
+ Status AutoRenewableSubscriptionStatus `json:"status"`
140
169
}
141
170
142
171
// SubscriptionNotificationV2JWSDecodedHeader is struct
@@ -169,31 +198,35 @@ type (
169
198
PriceIncreaseStatus PriceIncreaseStatus `json:"priceIncreaseStatus"`
170
199
ProductId string `json:"productId"`
171
200
RecentSubscriptionStartDate int64 `json:"recentSubscriptionStartDate"`
201
+ RenewalDate int64 `json:"renewalDate"`
172
202
SignedDate int64 `json:"signedDate"`
173
203
}
174
204
175
205
// JWSTransactionDecodedPayload contains the decoded transaction information
176
206
// https://developer.apple.com/documentation/appstoreservernotifications/jwstransactiondecodedpayload
177
207
JWSTransactionDecodedPayload struct {
178
- AppAccountToken string `json:"appAccountToken"`
179
- BundleId string `json:"bundleId"`
180
- Environment Environment `json:"environment"`
181
- ExpiresDate int64 `json:"expiresDate"`
182
- InAppOwnershipType string `json:"inAppOwnershipType"`
183
- IsUpgraded bool `json:"isUpgraded"`
184
- OfferIdentifier string `json:"offerIdentifier"`
185
- OfferType OfferType `json:"offerType"`
186
- OriginalPurchaseDate int64 `json:"originalPurchaseDate"`
187
- OriginalTransactionId string `json:"originalTransactionId"`
188
- ProductId string `json:"productId"`
189
- PurchaseDate int64 `json:"purchaseDate"`
190
- Quantity int64 `json:"quantity"`
191
- RevocationDate int64 `json:"revocationDate"`
192
- RevocationReason RevocationReason `json:"revocationReason"`
193
- SignedDate int64 `json:"signedDate"`
194
- SubscriptionGroupIdentifier string `json:"subscriptionGroupIdentifier"`
195
- TransactionId string `json:"transactionId"`
196
- IAPtype IAPType `json:"type"`
197
- WebOrderLineItemId string `json:"webOrderLineItemId"`
208
+ AppAccountToken string `json:"appAccountToken"`
209
+ BundleId string `json:"bundleId"`
210
+ Environment Environment `json:"environment"`
211
+ ExpiresDate int64 `json:"expiresDate"`
212
+ InAppOwnershipType string `json:"inAppOwnershipType"`
213
+ IsUpgraded bool `json:"isUpgraded"`
214
+ OfferIdentifier string `json:"offerIdentifier"`
215
+ OfferType OfferType `json:"offerType"`
216
+ OriginalPurchaseDate int64 `json:"originalPurchaseDate"`
217
+ OriginalTransactionId string `json:"originalTransactionId"`
218
+ ProductId string `json:"productId"`
219
+ PurchaseDate int64 `json:"purchaseDate"`
220
+ Quantity int64 `json:"quantity"`
221
+ RevocationDate int64 `json:"revocationDate"`
222
+ RevocationReason RevocationReason `json:"revocationReason"`
223
+ SignedDate int64 `json:"signedDate"`
224
+ Storefront string `json:"storefront"`
225
+ StorefrontId string `json:"storefrontId"`
226
+ SubscriptionGroupIdentifier string `json:"subscriptionGroupIdentifier"`
227
+ TransactionId string `json:"transactionId"`
228
+ TransactionReason TransactionReason `json:"transactionReason"`
229
+ IAPtype IAPType `json:"type"`
230
+ WebOrderLineItemId string `json:"webOrderLineItemId"`
198
231
}
199
232
)
0 commit comments