app_store_server_library/primitives/
jws_transaction_decoded_payload.rs

1use crate::primitives::environment::Environment;
2use crate::primitives::in_app_ownership_type::InAppOwnershipType;
3use crate::primitives::offer_discount_type::OfferDiscountType;
4use crate::primitives::offer_type::OfferType;
5use crate::primitives::product_type::ProductType;
6use crate::primitives::revocation_reason::RevocationReason;
7use crate::primitives::transaction_reason::TransactionReason;
8use chrono::{DateTime, Utc};
9use serde_with::formats::Flexible;
10use serde_with::TimestampMilliSeconds;
11use uuid::Uuid;
12
13/// A decoded payload containing transaction information.
14///
15/// [JWSTransactionDecodedPayload](https://developer.apple.com/documentation/appstoreserverapi/jwstransactiondecodedpayload)
16#[serde_with::serde_as]
17#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, Hash)]
18pub struct JWSTransactionDecodedPayload {
19    /// The original transaction identifier of a purchase.
20    ///
21    /// [originalTransactionId](https://developer.apple.com/documentation/appstoreserverapi/originaltransactionid)
22    #[serde(rename = "originalTransactionId")]
23    pub original_transaction_id: Option<String>,
24
25    /// The unique identifier for a transaction such as an in-app purchase, restored in-app purchase, or subscription renewal.
26    ///
27    /// [transactionId](https://developer.apple.com/documentation/appstoreserverapi/transactionid)
28    #[serde(rename = "transactionId")]
29    pub transaction_id: Option<String>,
30
31    /// The unique identifier of subscription-purchase events across devices, including renewals.
32    ///
33    /// [webOrderLineItemId](https://developer.apple.com/documentation/appstoreserverapi/weborderlineitemid)
34    #[serde(rename = "webOrderLineItemId")]
35    pub web_order_line_item_id: Option<String>,
36
37    /// The bundle identifier of an app.
38    ///
39    /// [bundle_id](https://developer.apple.com/documentation/appstoreserverapi/bundleid)
40    #[serde(rename = "bundleId")]
41    pub bundle_id: Option<String>,
42
43    /// The unique identifier for the product, that you create in App Store Connect.
44    ///
45    /// [productId](https://developer.apple.com/documentation/appstoreserverapi/productid)
46    #[serde(rename = "productId")]
47    pub product_id: Option<String>,
48
49    /// The identifier of the subscription group that the subscription belongs to.
50    ///
51    /// [subscriptionGroupIdentifier](https://developer.apple.com/documentation/appstoreserverapi/subscriptiongroupidentifier)
52    #[serde(rename = "subscriptionGroupIdentifier")]
53    pub subscription_group_identifier: Option<String>,
54
55    /// The time that the App Store charged the user’s account for an in-app purchase, a restored in-app purchase, a subscription, or a subscription renewal after a lapse.
56    ///
57    /// [purchaseDate](https://developer.apple.com/documentation/appstoreserverapi/purchasedate)
58    #[serde(rename = "purchaseDate")]
59    #[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
60    pub purchase_date: Option<DateTime<Utc>>,
61
62    /// The purchase date of the transaction associated with the original transaction identifier.
63    ///
64    /// [originalPurchaseDate](https://developer.apple.com/documentation/appstoreserverapi/originalpurchasedate)
65    #[serde(rename = "originalPurchaseDate")]
66    #[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
67    pub original_purchase_date: Option<DateTime<Utc>>,
68
69    /// The UNIX time, in milliseconds, an auto-renewable subscription expires or renews.
70    ///
71    /// [expiresDate](https://developer.apple.com/documentation/appstoreserverapi/expiresdate)
72    #[serde(rename = "expiresDate")]
73    #[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
74    pub expires_date: Option<DateTime<Utc>>,
75
76    /// The number of consumable products purchased.
77    ///
78    /// [quantity](https://developer.apple.com/documentation/appstoreserverapi/quantity)
79    #[serde(rename = "quantity")]
80    pub quantity: Option<i32>,
81
82    /// The type of the in-app purchase.
83    ///
84    /// [type](https://developer.apple.com/documentation/appstoreserverapi/type)
85    #[serde(rename = "type")]
86    pub r#type: Option<ProductType>,
87
88    /// The UUID that an app optionally generates to map a customer’s in-app purchase with its resulting App Store transaction.
89    ///
90    /// [appAccountToken](https://developer.apple.com/documentation/appstoreserverapi/appaccounttoken)
91    #[serde(rename = "appAccountToken")]
92    pub app_account_token: Option<Uuid>,
93
94    /// A string that describes whether the transaction was purchased by the user, or is available to them through Family Sharing.
95    ///
96    /// [inAppOwnershipType](https://developer.apple.com/documentation/appstoreserverapi/inappownershiptype)
97    #[serde(rename = "inAppOwnershipType")]
98    pub in_app_ownership_type: Option<InAppOwnershipType>,
99
100    /// The UNIX time, in milliseconds, that the App Store signed the JSON Web Signature data.
101    ///
102    /// [signedDate](https://developer.apple.com/documentation/appstoreserverapi/signeddate)
103    #[serde(rename = "signedDate")]
104    #[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
105    pub signed_date: Option<DateTime<Utc>>,
106
107    /// The reason that the App Store refunded the transaction or revoked it from family sharing.
108    ///
109    /// [revocationReason](https://developer.apple.com/documentation/appstoreserverapi/revocationreason)
110    #[serde(rename = "revocationReason")]
111    pub revocation_reason: Option<RevocationReason>,
112
113    /// The UNIX time, in milliseconds, that Apple Support refunded a transaction.
114    ///
115    /// [revocationDate](https://developer.apple.com/documentation/appstoreserverapi/revocationdate)
116    #[serde(rename = "revocationDate")]
117    #[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
118    pub revocation_date: Option<DateTime<Utc>>,
119
120    /// The Boolean value that indicates whether the user upgraded to another subscription.
121    ///
122    /// [isUpgraded](https://developer.apple.com/documentation/appstoreserverapi/isupgraded)
123    #[serde(rename = "isUpgraded")]
124    pub is_upgraded: Option<bool>,
125
126    /// A value that represents the promotional offer type.
127    ///
128    /// [offerType](https://developer.apple.com/documentation/appstoreserverapi/offertype)
129    #[serde(rename = "offerType")]
130    pub offer_type: Option<OfferType>,
131
132    /// The identifier that contains the promo code or the promotional offer identifier.
133    ///
134    /// [offerIdentifier](https://developer.apple.com/documentation/appstoreserverapi/offeridentifier)
135    #[serde(rename = "offerIdentifier")]
136    pub offer_identifier: Option<String>,
137
138    /// The server environment, either sandbox or production.
139    ///
140    /// [environment](https://developer.apple.com/documentation/appstoreserverapi/environment)
141    pub environment: Option<Environment>,
142
143    /// The three-letter code that represents the country or region associated with the App Store storefront for the purchase.
144    ///
145    /// [storefront](https://developer.apple.com/documentation/appstoreserverapi/storefront)
146    pub storefront: Option<String>,
147
148    /// An Apple-defined value that uniquely identifies the App Store storefront associated with the purchase.
149    ///
150    /// [storefrontId](https://developer.apple.com/documentation/appstoreserverapi/storefrontid)
151    #[serde(rename = "storefrontId")]
152    pub storefront_id: Option<String>,
153
154    /// The reason for the purchase transaction, which indicates whether it’s a customer’s purchase or a renewal for an auto-renewable subscription that the system initiates.
155    ///
156    /// [transactionReason](https://developer.apple.com/documentation/appstoreserverapi/transactionreason)
157    #[serde(rename = "transactionReason")]
158    pub transaction_reason: Option<TransactionReason>,
159
160    /// The three-letter ISO 4217 currency code for the price of the product.
161    ///
162    /// [currency](https://developer.apple.com/documentation/appstoreserverapi/currency)
163    pub currency: Option<String>,
164
165    /// The price, in milliunits, of the in-app purchase or subscription offer that you configured in App Store Connect.
166    ///
167    /// [price](https://developer.apple.com/documentation/appstoreserverapi/price)
168    pub price: Option<i64>,
169
170    /// The payment mode you configure for an introductory offer, promotional offer, or offer code on an auto-renewable subscription.
171    ///
172    /// [offerDiscountType](https://developer.apple.com/documentation/appstoreserverapi/offerdiscounttype)
173    #[serde(rename = "offerDiscountType")]
174    pub offer_discount_type: Option<OfferDiscountType>,
175
176    /// The unique identifier of the app download transaction.
177    ///
178    /// [appTransactionId](https://developer.apple.com/documentation/appstoreserverapi/appTransactionId)
179    #[serde(rename = "appTransactionId")]
180    pub app_transaction_id: Option<String>,
181
182    /// The duration of the offer.
183    ///
184    /// [offerPeriod](https://developer.apple.com/documentation/appstoreserverapi/offerPeriod)
185    #[serde(rename = "offerPeriod")]
186    pub offer_period: Option<String>,
187}