Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 04f64ec

Browse files
authored
[in_app_purchase] Implements transaction caching for StoreKit (#4985)
1 parent f25e370 commit 04f64ec

File tree

12 files changed

+712
-203
lines changed

12 files changed

+712
-203
lines changed

packages/in_app_purchase/in_app_purchase_storekit/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.0+3
2+
3+
* Implements transaction caching for StoreKit ensuring transactions are delivered to the Flutter client.
4+
15
## 0.3.0+2
26

37
* Internal code cleanup for stricter analysis options.

packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 46;
6+
objectVersion = 50;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -22,6 +22,7 @@
2222
A5279298219369C600FF69E6 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A5279297219369C600FF69E6 /* StoreKit.framework */; };
2323
A59001A721E69658004A3E5E /* InAppPurchasePluginTests.m in Sources */ = {isa = PBXBuildFile; fileRef = A59001A621E69658004A3E5E /* InAppPurchasePluginTests.m */; };
2424
F67646F82681D9A80048C2EA /* FIAPPaymentQueueDeleteTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F67646F72681D9A80048C2EA /* FIAPPaymentQueueDeleteTests.m */; };
25+
F6995BDD27CF73000050EA78 /* FIATransactionCacheTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F6995BDC27CF73000050EA78 /* FIATransactionCacheTests.m */; };
2526
F78AF3142342BC89008449C7 /* PaymentQueueTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F78AF3132342BC89008449C7 /* PaymentQueueTests.m */; };
2627
/* End PBXBuildFile section */
2728

@@ -78,6 +79,7 @@
7879
A59001A821E69658004A3E5E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7980
E4F9651425A612301059769C /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
8081
F67646F72681D9A80048C2EA /* FIAPPaymentQueueDeleteTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIAPPaymentQueueDeleteTests.m; sourceTree = "<group>"; };
82+
F6995BDC27CF73000050EA78 /* FIATransactionCacheTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FIATransactionCacheTests.m; sourceTree = "<group>"; };
8183
F6E5D5F926131C4800C68BED /* Configuration.storekit */ = {isa = PBXFileReference; lastKnownFileType = text; path = Configuration.storekit; sourceTree = "<group>"; };
8284
F78AF3132342BC89008449C7 /* PaymentQueueTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PaymentQueueTests.m; sourceTree = "<group>"; };
8385
/* End PBXFileReference section */
@@ -190,6 +192,7 @@
190192
F78AF3132342BC89008449C7 /* PaymentQueueTests.m */,
191193
688DE35021F2A5A100EA2684 /* TranslatorTests.m */,
192194
F67646F72681D9A80048C2EA /* FIAPPaymentQueueDeleteTests.m */,
195+
F6995BDC27CF73000050EA78 /* FIATransactionCacheTests.m */,
193196
);
194197
path = RunnerTests;
195198
sourceTree = "<group>";
@@ -254,7 +257,7 @@
254257
isa = PBXProject;
255258
attributes = {
256259
DefaultBuildSystemTypeForWorkspace = Original;
257-
LastUpgradeCheck = 1100;
260+
LastUpgradeCheck = 1300;
258261
ORGANIZATIONNAME = "The Flutter Authors";
259262
TargetAttributes = {
260263
97C146ED1CF9000F007C117D = {
@@ -406,6 +409,7 @@
406409
F67646F82681D9A80048C2EA /* FIAPPaymentQueueDeleteTests.m in Sources */,
407410
6896B34621E9363700D37AEF /* ProductRequestHandlerTests.m in Sources */,
408411
688DE35121F2A5A100EA2684 /* TranslatorTests.m in Sources */,
412+
F6995BDD27CF73000050EA78 /* FIATransactionCacheTests.m in Sources */,
409413
A59001A721E69658004A3E5E /* InAppPurchasePluginTests.m in Sources */,
410414
6896B34C21EEB4B800D37AEF /* Stubs.m in Sources */,
411415
);

packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1100"
3+
LastUpgradeVersion = "1300"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#import <XCTest/XCTest.h>
6+
7+
@import in_app_purchase_storekit;
8+
9+
@interface FIATransactionCacheTests : XCTestCase
10+
11+
@end
12+
13+
@implementation FIATransactionCacheTests
14+
15+
- (void)testAddObjectsForNewKey {
16+
NSArray *dummyArray = @[ @1, @2, @3 ];
17+
FIATransactionCache *cache = [[FIATransactionCache alloc] init];
18+
[cache addObjects:dummyArray forKey:TransactionCacheKeyUpdatedTransactions];
19+
20+
XCTAssertEqual(dummyArray, [cache getObjectsForKey:TransactionCacheKeyUpdatedTransactions]);
21+
}
22+
23+
- (void)testAddObjectsForExistingKey {
24+
NSArray *dummyArray = @[ @1, @2, @3 ];
25+
FIATransactionCache *cache = [[FIATransactionCache alloc] init];
26+
[cache addObjects:dummyArray forKey:TransactionCacheKeyUpdatedTransactions];
27+
28+
XCTAssertEqual(dummyArray, [cache getObjectsForKey:TransactionCacheKeyUpdatedTransactions]);
29+
30+
[cache addObjects:@[ @4, @5, @6 ] forKey:TransactionCacheKeyUpdatedTransactions];
31+
32+
NSArray *expected = @[ @1, @2, @3, @4, @5, @6 ];
33+
XCTAssertEqualObjects(expected, [cache getObjectsForKey:TransactionCacheKeyUpdatedTransactions]);
34+
}
35+
36+
- (void)testGetObjectsForNonExistingKey {
37+
FIATransactionCache *cache = [[FIATransactionCache alloc] init];
38+
XCTAssertNil([cache getObjectsForKey:TransactionCacheKeyUpdatedTransactions]);
39+
}
40+
41+
- (void)testClear {
42+
NSArray *fakeUpdatedTransactions = @[ @1, @2, @3 ];
43+
NSArray *fakeRemovedTransactions = @[ @"Remove 1", @"Remove 2", @"Remove 3" ];
44+
NSArray *fakeUpdatedDownloads = @[ @"Download 1", @"Download 2" ];
45+
FIATransactionCache *cache = [[FIATransactionCache alloc] init];
46+
[cache addObjects:fakeUpdatedTransactions forKey:TransactionCacheKeyUpdatedTransactions];
47+
[cache addObjects:fakeRemovedTransactions forKey:TransactionCacheKeyRemovedTransactions];
48+
[cache addObjects:fakeUpdatedDownloads forKey:TransactionCacheKeyUpdatedDownloads];
49+
50+
XCTAssertEqual(fakeUpdatedTransactions,
51+
[cache getObjectsForKey:TransactionCacheKeyUpdatedTransactions]);
52+
XCTAssertEqual(fakeRemovedTransactions,
53+
[cache getObjectsForKey:TransactionCacheKeyRemovedTransactions]);
54+
XCTAssertEqual(fakeUpdatedDownloads,
55+
[cache getObjectsForKey:TransactionCacheKeyUpdatedDownloads]);
56+
57+
[cache clear];
58+
59+
XCTAssertNil([cache getObjectsForKey:TransactionCacheKeyUpdatedTransactions]);
60+
XCTAssertNil([cache getObjectsForKey:TransactionCacheKeyRemovedTransactions]);
61+
XCTAssertNil([cache getObjectsForKey:TransactionCacheKeyUpdatedDownloads]);
62+
}
63+
@end

0 commit comments

Comments
 (0)