@@ -40,7 +40,7 @@ class PurchaseWrapper {
40
40
required this .purchaseState});
41
41
42
42
/// Factory for creating a [PurchaseWrapper] from a [Map] with the purchase details.
43
- factory PurchaseWrapper .fromJson (Map map) => _$PurchaseWrapperFromJson (map);
43
+ factory PurchaseWrapper .fromJson (Map < String , dynamic > map) => _$PurchaseWrapperFromJson (map);
44
44
45
45
@override
46
46
bool operator == (Object other) {
@@ -74,22 +74,28 @@ class PurchaseWrapper {
74
74
75
75
/// The unique ID for this purchase. Corresponds to the Google Payments order
76
76
/// ID.
77
+ @JsonKey (defaultValue: '' )
77
78
final String orderId;
78
79
79
80
/// The package name the purchase was made from.
81
+ @JsonKey (defaultValue: '' )
80
82
final String packageName;
81
83
82
84
/// When the purchase was made, as an epoch timestamp.
85
+ @JsonKey (defaultValue: 0 )
83
86
final int purchaseTime;
84
87
85
88
/// A unique ID for a given [SkuDetailsWrapper] , user, and purchase.
89
+ @JsonKey (defaultValue: '' )
86
90
final String purchaseToken;
87
91
88
92
/// Signature of purchase data, signed with the developer's private key. Uses
89
93
/// RSASSA-PKCS1-v1_5.
94
+ @JsonKey (defaultValue: '' )
90
95
final String signature;
91
96
92
97
/// The product ID of this purchase.
98
+ @JsonKey (defaultValue: '' )
93
99
final String sku;
94
100
95
101
/// True for subscriptions that renew automatically. Does not apply to
@@ -105,15 +111,18 @@ class PurchaseWrapper {
105
111
/// device"](https://developer.android.com/google/play/billing/billing_library_overview#Verify-purchase-device).
106
112
/// Note though that verifying a purchase locally is inherently insecure (see
107
113
/// the article for more details).
114
+ @JsonKey (defaultValue: '' )
108
115
final String originalJson;
109
116
110
117
/// The payload specified by the developer when the purchase was acknowledged or consumed.
118
+ @JsonKey (defaultValue: '' )
111
119
final String developerPayload;
112
120
113
121
/// Whether the purchase has been acknowledged.
114
122
///
115
123
/// A successful purchase has to be acknowledged within 3 days after the purchase via [BillingClient.acknowledgePurchase] .
116
124
/// * See also [BillingClient.acknowledgePurchase] for more details on acknowledging purchases.
125
+ @JsonKey (defaultValue: false )
117
126
final bool isAcknowledged;
118
127
119
128
/// Determines the current state of the purchase.
@@ -146,20 +155,24 @@ class PurchaseHistoryRecordWrapper {
146
155
});
147
156
148
157
/// Factory for creating a [PurchaseHistoryRecordWrapper] from a [Map] with the record details.
149
- factory PurchaseHistoryRecordWrapper .fromJson (Map map) =>
158
+ factory PurchaseHistoryRecordWrapper .fromJson (Map < String , dynamic > map) =>
150
159
_$PurchaseHistoryRecordWrapperFromJson (map);
151
160
152
161
/// When the purchase was made, as an epoch timestamp.
162
+ @JsonKey (defaultValue: 0 )
153
163
final int purchaseTime;
154
164
155
165
/// A unique ID for a given [SkuDetailsWrapper] , user, and purchase.
166
+ @JsonKey (defaultValue: '' )
156
167
final String purchaseToken;
157
168
158
169
/// Signature of purchase data, signed with the developer's private key. Uses
159
170
/// RSASSA-PKCS1-v1_5.
171
+ @JsonKey (defaultValue: '' )
160
172
final String signature;
161
173
162
174
/// The product ID of this purchase.
175
+ @JsonKey (defaultValue: '' )
163
176
final String sku;
164
177
165
178
/// Details about this purchase, in JSON.
@@ -168,9 +181,11 @@ class PurchaseHistoryRecordWrapper {
168
181
/// device"](https://developer.android.com/google/play/billing/billing_library_overview#Verify-purchase-device).
169
182
/// Note though that verifying a purchase locally is inherently insecure (see
170
183
/// the article for more details).
184
+ @JsonKey (defaultValue: '' )
171
185
final String originalJson;
172
186
173
187
/// The payload specified by the developer when the purchase was acknowledged or consumed.
188
+ @JsonKey (defaultValue: '' )
174
189
final String developerPayload;
175
190
176
191
@override
@@ -232,11 +247,13 @@ class PurchasesResultWrapper {
232
247
///
233
248
/// This can represent either the status of the "query purchase history" half
234
249
/// of the operation and the "user made purchases" transaction itself.
250
+ @JsonKey (defaultValue: BillingResponse .error)
235
251
final BillingResponse responseCode;
236
252
237
253
/// The list of successful purchases made in this transaction.
238
254
///
239
255
/// May be empty, especially if [responseCode] is not [BillingResponse.ok] .
256
+ @JsonKey (defaultValue: < PurchaseWrapper > [])
240
257
final List <PurchaseWrapper > purchasesList;
241
258
}
242
259
@@ -273,6 +290,7 @@ class PurchasesHistoryResult {
273
290
/// The list of queried purchase history records.
274
291
///
275
292
/// May be empty, especially if [billingResult.responseCode] is not [BillingResponse.ok] .
293
+ @JsonKey (defaultValue: < PurchaseHistoryRecordWrapper > [])
276
294
final List <PurchaseHistoryRecordWrapper > purchaseHistoryRecordList;
277
295
}
278
296
0 commit comments