Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.4.11

* Fixes StoreKit 2 date format does not match in_app_purchase_platform_interface PurchaseDetails.transactionDate format.
Fixes both `SK2Transaction.purchaseDate` and `SK2Transaction.expirationDate`.

## 0.4.10

* Clarifies `completePurchase` usage and the consequences of unfinished transactions in the README and API docstrings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,8 @@ struct SK2TransactionMessage: Hashable {
var id: Int64
var originalId: Int64
var productId: String
var purchaseDate: String? = nil
var expirationDate: String? = nil
var purchaseDate: Double? = nil
var expirationDate: Double? = nil
var purchasedQuantity: Int64
var appAccountToken: String? = nil
var receiptData: String? = nil
Expand All @@ -523,8 +523,8 @@ struct SK2TransactionMessage: Hashable {
let id = pigeonVar_list[0] as! Int64
let originalId = pigeonVar_list[1] as! Int64
let productId = pigeonVar_list[2] as! String
let purchaseDate: String? = nilOrValue(pigeonVar_list[3])
let expirationDate: String? = nilOrValue(pigeonVar_list[4])
let purchaseDate: Double? = nilOrValue(pigeonVar_list[3])
let expirationDate: Double? = nilOrValue(pigeonVar_list[4])
let purchasedQuantity = pigeonVar_list[5] as! Int64
let appAccountToken: String? = nilOrValue(pigeonVar_list[6])
let receiptData: String? = nilOrValue(pigeonVar_list[7])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,12 @@ extension Product.PurchaseResult {
extension Transaction {
func convertToPigeon(receipt: String?, status: SK2PurchaseStatusMessage) -> SK2TransactionMessage
{

let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"

return SK2TransactionMessage(
id: Int64(id),
originalId: Int64(originalID),
productId: productID,
purchaseDate: dateFormatter.string(from: purchaseDate),
expirationDate: expirationDate.map { dateFormatter.string(from: $0) },
purchaseDate: purchaseDate.timeIntervalSince1970,
expirationDate: expirationDate.map { $0.timeIntervalSince1970 },
purchasedQuantity: Int64(purchasedQuantity),
appAccountToken: appAccountToken?.uuidString,
receiptData: receipt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,9 @@ class SK2TransactionMessage {

String productId;

String? purchaseDate;
double? purchaseDate;

String? expirationDate;
double? expirationDate;

int purchasedQuantity;

Expand Down Expand Up @@ -589,8 +589,8 @@ class SK2TransactionMessage {
id: result[0]! as int,
originalId: result[1]! as int,
productId: result[2]! as String,
purchaseDate: result[3] as String?,
expirationDate: result[4] as String?,
purchaseDate: result[3] as double?,
expirationDate: result[4] as double?,
purchasedQuantity: result[5]! as int,
appAccountToken: result[6] as String?,
receiptData: result[7] as String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ class SK2Transaction {

/// The date that the App Store charged the user's account for a purchased or
/// restored product, or for a subscription purchase or renewal after a lapse.
///
/// Milliseconds since epoch.
final String purchaseDate;

/// The date the subscription expires or renews.
///
/// Milliseconds since epoch.
final String? expirationDate;

/// The number of consumable products purchased.
Expand Down Expand Up @@ -124,8 +128,12 @@ extension on SK2TransactionMessage {
id: id.toString(),
originalId: originalId.toString(),
productId: productId,
purchaseDate: purchaseDate ?? '',
expirationDate: expirationDate,
purchaseDate: purchaseDate != null
? _secondsToMillisecondsSinceEpochString(purchaseDate!)
: '',
expirationDate: expirationDate != null
? _secondsToMillisecondsSinceEpochString(expirationDate!)
: null,
appAccountToken: appAccountToken,
receiptData: receiptData,
jsonRepresentation: jsonRepresentation,
Expand Down Expand Up @@ -153,12 +161,16 @@ extension on SK2TransactionMessage {
serverVerificationData: receiptData ?? '',
source: kIAPSource,
),
transactionDate: purchaseDate,
transactionDate: purchaseDate != null
? _secondsToMillisecondsSinceEpochString(purchaseDate!)
: null,
status: purchaseStatus,
purchaseID: id > 0 ? id.toString() : null,
appAccountToken: appAccountToken,
);
}

String _secondsToMillisecondsSinceEpochString(double date) => (date * 1000).round().toString();
}

/// An observer that listens to all transactions created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ class SK2TransactionMessage {
final int id;
final int originalId;
final String productId;
final String? purchaseDate;
final String? expirationDate;
final double? purchaseDate;
final double? expirationDate;
final int purchasedQuantity;
final String? appAccountToken;
final String? receiptData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: in_app_purchase_storekit
description: An implementation for the iOS and macOS platforms of the Flutter `in_app_purchase` plugin. This uses the StoreKit Framework.
repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_storekit
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
version: 0.4.10
version: 0.4.11

environment:
sdk: ^3.10.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ class FakeStoreKit2Platform implements InAppPurchase2API {
id: 123,
originalId: 321,
productId: '',
purchaseDate: '',
appAccountToken: '',
status: SK2PurchaseStatusMessage.restored,
);
Expand Down Expand Up @@ -406,7 +405,8 @@ class FakeStoreKit2Platform implements InAppPurchase2API {
id: 1,
originalId: 2,
productId: id,
purchaseDate: 'purchaseDate',
purchaseDate: 123123.121,
expirationDate: 321321.32,
appAccountToken: 'appAccountToken',
receiptData: 'receiptData',
jsonRepresentation: 'jsonRepresentation',
Expand Down Expand Up @@ -454,7 +454,7 @@ class FakeStoreKit2Platform implements InAppPurchase2API {
id: 123,
originalId: 123,
productId: 'product_id',
purchaseDate: '12-12',
purchaseDate: 123123.121,
status: SK2PurchaseStatusMessage.purchased,
),
]);
Expand All @@ -467,7 +467,8 @@ class FakeStoreKit2Platform implements InAppPurchase2API {
id: 123,
originalId: 123,
productId: 'product_id',
purchaseDate: '12-12',
purchaseDate: 123123.121,
expirationDate: 321321.32,
receiptData: 'fake_jws_representation',
appAccountToken: 'fake_app_account_token',
status: SK2PurchaseStatusMessage.purchased,
Expand Down Expand Up @@ -557,7 +558,7 @@ SK2TransactionMessage createPendingTransaction(String id, {int quantity = 1}) {
id: 1,
originalId: 2,
productId: id,
purchaseDate: 'purchaseDate',
purchaseDate: 123123.121,
appAccountToken: 'appAccountToken',
receiptData: 'receiptData',
jsonRepresentation: 'jsonRepresentation',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void main() {
expect(result.first.productID, dummyProductWrapper.id);
expect(result.first.status, PurchaseStatus.purchased);
expect(result.first.pendingCompletePurchase, true);
expect(result.first.transactionDate, (123123.121 * 1000).round().toString());
},
);

Expand Down Expand Up @@ -141,6 +142,7 @@ void main() {
final List<PurchaseDetails> result = await completer.future;
expect(result.length, 1);
expect(result.first.productID, dummyProductWrapper.id);
expect(result.first.transactionDate, (123123.121 * 1000).round().toString());
},
);

Expand Down Expand Up @@ -638,6 +640,7 @@ void main() {
expect(transactions, isNotEmpty);
expect(transactions.first.id, '123');
expect(transactions.first.productId, 'product_id');
expect(transactions.first.expirationDate, (321321.32 * 1000).round().toString());
});

test('should expose receiptData (JWS) in unfinished transactions', () async {
Expand Down