app_store_server_library/models/jws_transaction_decoded_payload.rs
1use chrono::{DateTime, Utc};
2use serde_with::formats::Flexible;
3use serde_with::TimestampMilliSeconds;
4use uuid::Uuid;
5
6use crate::models::advanced_commerce_transaction_info::AdvancedCommerceTransactionInfo;
7use crate::models::app_store_environment::Environment;
8use crate::models::billing_plan_type::BillingPlanType;
9use crate::models::decoded_signed_data::DecodedSignedData;
10use crate::models::in_app_ownership_type::InAppOwnershipType;
11use crate::models::offer_discount_type::OfferDiscountType;
12use crate::models::offer_type::OfferType;
13use crate::models::product_type::ProductType;
14use crate::models::revocation_reason::RevocationReason;
15use crate::models::revocation_type::RevocationType;
16use crate::models::transaction_commitment_info::TransactionCommitmentInfo;
17use crate::models::transaction_reason::TransactionReason;
18
19/// A decoded payload containing transaction information.
20///
21/// [JWSTransactionDecodedPayload](https://developer.apple.com/documentation/appstoreserverapi/jwstransactiondecodedpayload)
22#[serde_with::serde_as]
23#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, Hash)]
24#[serde(rename_all = "camelCase")]
25pub struct JWSTransactionDecodedPayload {
26 /// The original transaction identifier of a purchase.
27 ///
28 /// [originalTransactionId](https://developer.apple.com/documentation/appstoreserverapi/originaltransactionid)
29 pub original_transaction_id: Option<String>,
30
31 /// The original transaction identifier of a subscription before migration.
32 ///
33 /// [previousOriginalTransactionId](https://developer.apple.com/documentation/appstoreserverapi/previousoriginaltransactionid)
34 pub previous_original_transaction_id: Option<String>,
35
36 /// The unique identifier for a transaction such as an in-app purchase, restored in-app purchase, or subscription renewal.
37 ///
38 /// [transactionId](https://developer.apple.com/documentation/appstoreserverapi/transactionid)
39 pub transaction_id: Option<String>,
40
41 /// The unique identifier of subscription-purchase events across devices, including renewals.
42 ///
43 /// [webOrderLineItemId](https://developer.apple.com/documentation/appstoreserverapi/weborderlineitemid)
44 pub web_order_line_item_id: Option<String>,
45
46 /// The bundle identifier of an app.
47 ///
48 /// [bundle_id](https://developer.apple.com/documentation/appstoreserverapi/bundleid)
49 pub bundle_id: Option<String>,
50
51 /// The unique identifier for the product, that you create in App Store Connect.
52 ///
53 /// [productId](https://developer.apple.com/documentation/appstoreserverapi/productid)
54 pub product_id: Option<String>,
55
56 /// The identifier of the subscription group that the subscription belongs to.
57 ///
58 /// [subscriptionGroupIdentifier](https://developer.apple.com/documentation/appstoreserverapi/subscriptiongroupidentifier)
59 pub subscription_group_identifier: Option<String>,
60
61 /// 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.
62 ///
63 /// [purchaseDate](https://developer.apple.com/documentation/appstoreserverapi/purchasedate)
64 #[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
65 pub purchase_date: Option<DateTime<Utc>>,
66
67 /// The purchase date of the transaction associated with the original transaction identifier.
68 ///
69 /// [originalPurchaseDate](https://developer.apple.com/documentation/appstoreserverapi/originalpurchasedate)
70 #[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
71 pub original_purchase_date: Option<DateTime<Utc>>,
72
73 /// The UNIX time, in milliseconds, an auto-renewable subscription expires or renews.
74 ///
75 /// [expiresDate](https://developer.apple.com/documentation/appstoreserverapi/expiresdate)
76 #[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
77 pub expires_date: Option<DateTime<Utc>>,
78
79 /// The number of consumable products purchased.
80 ///
81 /// [quantity](https://developer.apple.com/documentation/appstoreserverapi/quantity)
82 pub quantity: Option<i32>,
83
84 /// The type of the in-app purchase.
85 ///
86 /// [type](https://developer.apple.com/documentation/appstoreserverapi/type)
87 pub r#type: Option<ProductType>,
88
89 /// The UUID that an app optionally generates to map a customer’s in-app purchase with its resulting App Store transaction.
90 ///
91 /// [appAccountToken](https://developer.apple.com/documentation/appstoreserverapi/appaccounttoken)
92 #[serde(skip_serializing_if = "Option::is_none")]
93 pub app_account_token: Option<Uuid>,
94
95 /// A string that describes whether the transaction was purchased by the user, or is available to them through Family Sharing.
96 ///
97 /// [inAppOwnershipType](https://developer.apple.com/documentation/appstoreserverapi/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_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
104 pub signed_date: Option<DateTime<Utc>>,
105
106 /// The reason that the App Store refunded the transaction or revoked it from Family Sharing.
107 ///
108 /// [revocationReason](https://developer.apple.com/documentation/appstoreserverapi/revocationreason)
109 pub revocation_reason: Option<RevocationReason>,
110
111 /// The UNIX time, in milliseconds, that Apple Support refunded a transaction.
112 ///
113 /// [revocationDate](https://developer.apple.com/documentation/appstoreserverapi/revocationdate)
114 #[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
115 pub revocation_date: Option<DateTime<Utc>>,
116
117 /// The type of revocation for the transaction.
118 ///
119 /// [revocationType](https://developer.apple.com/documentation/appstoreserverapi/revocationtype)
120 pub revocation_type: Option<RevocationType>,
121
122 /// The percentage of the refund amount.
123 ///
124 /// [revocationPercentage](https://developer.apple.com/documentation/appstoreserverapi/revocationpercentage)
125 pub revocation_percentage: Option<i32>,
126
127 /// The Boolean value that indicates whether the user upgraded to another subscription.
128 ///
129 /// [isUpgraded](https://developer.apple.com/documentation/appstoreserverapi/isupgraded)
130 pub is_upgraded: Option<bool>,
131
132 /// A value that represents the promotional offer type.
133 ///
134 /// [offerType](https://developer.apple.com/documentation/appstoreserverapi/offertype)
135 pub offer_type: Option<OfferType>,
136
137 /// The identifier that contains the offer code or the promotional offer identifier.
138 ///
139 /// [offerIdentifier](https://developer.apple.com/documentation/appstoreserverapi/offeridentifier)
140 pub offer_identifier: Option<String>,
141
142 /// The server environment, either sandbox or production.
143 ///
144 /// [environment](https://developer.apple.com/documentation/appstoreserverapi/environment)
145 pub environment: Option<Environment>,
146
147 /// The three-letter code that represents the country or region associated with the App Store storefront for the purchase.
148 ///
149 /// [storefront](https://developer.apple.com/documentation/appstoreserverapi/storefront)
150 pub storefront: Option<String>,
151
152 /// An Apple-defined value that uniquely identifies the App Store storefront associated with the purchase.
153 ///
154 /// [storefrontId](https://developer.apple.com/documentation/appstoreserverapi/storefrontid)
155 pub storefront_id: Option<String>,
156
157 /// 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.
158 ///
159 /// [transactionReason](https://developer.apple.com/documentation/appstoreserverapi/transactionreason)
160 pub transaction_reason: Option<TransactionReason>,
161
162 /// The three-letter ISO 4217 currency code for the price of the product.
163 ///
164 /// [currency](https://developer.apple.com/documentation/appstoreserverapi/currency)
165 pub currency: Option<String>,
166
167 /// The price, in milliunits, of the in-app purchase or subscription offer that you configured in App Store Connect.
168 ///
169 /// [price](https://developer.apple.com/documentation/appstoreserverapi/price)
170 pub price: Option<i64>,
171
172 /// The payment mode you configure for the offer.
173 ///
174 /// [offerDiscountType](https://developer.apple.com/documentation/appstoreserverapi/offerdiscounttype)
175 pub offer_discount_type: Option<OfferDiscountType>,
176
177 /// The unique identifier of the app download transaction.
178 ///
179 /// [appTransactionId](https://developer.apple.com/documentation/appstoreserverapi/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 pub offer_period: Option<String>,
186
187 /// Transaction information that is present only for Advanced Commerce SKUs.
188 ///
189 /// [advancedCommerceTransactionInfo](https://developer.apple.com/documentation/appstoreserverapi/advancedcommercetransactioninfo)
190 pub advanced_commerce_info: Option<AdvancedCommerceTransactionInfo>,
191
192 /// The billing plan type for monthly subscriptions with a 12-month commitment.
193 ///
194 /// [billingPlanType](https://developer.apple.com/documentation/appstoreserverapi/billingplantype)
195 pub billing_plan_type: Option<BillingPlanType>,
196
197 /// Commitment information for subscriptions with a 12-month commitment.
198 ///
199 /// [commitmentInfo](https://developer.apple.com/documentation/appstoreserverapi/transactioncommitmentinfo)
200 pub commitment_info: Option<TransactionCommitmentInfo>,
201}
202
203impl DecodedSignedData for JWSTransactionDecodedPayload {
204 fn signed_date_optional(&self) -> Option<DateTime<Utc>> {
205 self.signed_date
206 }
207}