Skip to content

Commit 1fabbc2

Browse files
authored
Merge pull request #211 from richzw/master
feat(appstore): add more fields to JWSTransaction for app store server api
2 parents 10be9f0 + 297f2a2 commit 1fabbc2

File tree

1 file changed

+41
-19
lines changed

1 file changed

+41
-19
lines changed

appstore/api/model.go

+41-19
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,49 @@ type JWSDecodedHeader struct {
8484
X5C []string `json:"x5c,omitempty"`
8585
}
8686

87+
// TransactionReason indicates the cause of a purchase transaction,
88+
// https://developer.apple.com/documentation/appstoreservernotifications/transactionreason
89+
type TransactionReason string
90+
91+
const (
92+
TransactionReasonPurchase = "PURCHASE"
93+
TransactionReasonRenewal = "RENEWAL"
94+
)
95+
96+
// IAPType https://developer.apple.com/documentation/appstoreserverapi/type
97+
type IAPType string
98+
99+
const (
100+
AutoRenewable IAPType = "Auto-Renewable Subscription"
101+
NonConsumable IAPType = "Non-Consumable"
102+
Consumable IAPType = "Consumable"
103+
NonRenewable IAPType = "Non-Renewing Subscription"
104+
)
105+
87106
// JWSTransaction https://developer.apple.com/documentation/appstoreserverapi/jwstransaction
88107
type JWSTransaction struct {
89-
TransactionID string `json:"transactionId,omitempty"`
90-
OriginalTransactionId string `json:"originalTransactionId,omitempty"`
91-
WebOrderLineItemId string `json:"webOrderLineItemId,omitempty"`
92-
BundleID string `json:"bundleId,omitempty"`
93-
ProductID string `json:"productId,omitempty"`
94-
SubscriptionGroupIdentifier string `json:"subscriptionGroupIdentifier,omitempty"`
95-
PurchaseDate int64 `json:"purchaseDate,omitempty"`
96-
OriginalPurchaseDate int64 `json:"originalPurchaseDate,omitempty"`
97-
ExpiresDate int64 `json:"expiresDate,omitempty"`
98-
Quantity int64 `json:"quantity,omitempty"`
99-
Type string `json:"type,omitempty"`
100-
AppAccountToken string `json:"appAccountToken,omitempty"`
101-
InAppOwnershipType string `json:"inAppOwnershipType,omitempty"`
102-
SignedDate int64 `json:"signedDate,omitempty"`
103-
OfferType int64 `json:"offerType,omitempty"`
104-
OfferIdentifier string `json:"offerIdentifier,omitempty"`
105-
RevocationDate int64 `json:"revocationDate,omitempty"`
106-
RevocationReason int `json:"revocationReason,omitempty"`
107-
IsUpgraded bool `json:"isUpgraded,omitempty"`
108+
TransactionID string `json:"transactionId,omitempty"`
109+
OriginalTransactionId string `json:"originalTransactionId,omitempty"`
110+
WebOrderLineItemId string `json:"webOrderLineItemId,omitempty"`
111+
BundleID string `json:"bundleId,omitempty"`
112+
ProductID string `json:"productId,omitempty"`
113+
SubscriptionGroupIdentifier string `json:"subscriptionGroupIdentifier,omitempty"`
114+
PurchaseDate int64 `json:"purchaseDate,omitempty"`
115+
OriginalPurchaseDate int64 `json:"originalPurchaseDate,omitempty"`
116+
ExpiresDate int64 `json:"expiresDate,omitempty"`
117+
Quantity int64 `json:"quantity,omitempty"`
118+
Type IAPType `json:"type,omitempty"`
119+
AppAccountToken string `json:"appAccountToken,omitempty"`
120+
InAppOwnershipType string `json:"inAppOwnershipType,omitempty"`
121+
SignedDate int64 `json:"signedDate,omitempty"`
122+
OfferType int64 `json:"offerType,omitempty"`
123+
OfferIdentifier string `json:"offerIdentifier,omitempty"`
124+
RevocationDate int64 `json:"revocationDate,omitempty"`
125+
RevocationReason int `json:"revocationReason,omitempty"`
126+
IsUpgraded bool `json:"isUpgraded,omitempty"`
127+
Storefront string `json:"storefront"`
128+
StorefrontId string `json:"storefrontId"`
129+
TransactionReason TransactionReason `json:"transactionReason"`
108130
}
109131

110132
func (J JWSTransaction) Valid() error {

0 commit comments

Comments
 (0)