Skip to content

Commit

Permalink
MANY bugfixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
millenomi committed Feb 3, 2010
1 parent 293cfd9 commit 6cbedf9
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 11 deletions.
4 changes: 3 additions & 1 deletion ILSimSKPayment.m
Expand Up @@ -27,8 +27,10 @@ @implementation ILSimSKPayment


- (id) initWithProductIdentifier:(NSString*) pid; - (id) initWithProductIdentifier:(NSString*) pid;
{ {
if (self = [super init]) if (self = [super init]) {
productIdentifier = [pid copy]; productIdentifier = [pid copy];
quantity = 1;
}


return self; return self;
} }
Expand Down
6 changes: 4 additions & 2 deletions ILSimSKPaymentQueue.m
Expand Up @@ -74,6 +74,8 @@ - (void) addPayment:(ILSimSKPayment*) p;
t.payment = p; t.payment = p;
t.transactionDate = [NSDate date]; t.transactionDate = [NSDate date];


[transactions addObject:t];

if ([observers count] > 0) if ([observers count] > 0)
[self performSelector:@selector(processNextTransaction) withObject:nil afterDelay:2.0]; [self performSelector:@selector(processNextTransaction) withObject:nil afterDelay:2.0];
} }
Expand Down Expand Up @@ -153,7 +155,7 @@ - (void) succeed;
p.productIdentifier, @"ProductID", p.productIdentifier, @"ProductID",
[NSNumber numberWithInteger:self.currentTransaction.payment.quantity], @"Quantity", [NSNumber numberWithInteger:self.currentTransaction.payment.quantity], @"Quantity",
self.currentTransaction.transactionIdentifier, @"TransactionID", self.currentTransaction.transactionIdentifier, @"TransactionID",
[NSNumber numberWithInteger:p.simulatedProductType], @"SimulatedProductType", [NSNumber numberWithInteger:p.simulatedProductType], @"ProductType",
self.currentTransaction.transactionDate, @"Date", self.currentTransaction.transactionDate, @"Date",
nil]; nil];


Expand Down Expand Up @@ -218,7 +220,7 @@ - (void) restoreCompletedTransactions;
if (![d isKindOfClass:[NSDictionary class]]) if (![d isKindOfClass:[NSDictionary class]])
continue; continue;


id kind = [d objectForKey:@"SimulatedProductType"]; id kind = [d objectForKey:@"ProductType"];
if (!kind || ![kind isKindOfClass:[NSNumber class]] || [kind integerValue] != kILSimSimulatedProductTypeNonConsumable) if (!kind || ![kind isKindOfClass:[NSNumber class]] || [kind integerValue] != kILSimSimulatedProductTypeNonConsumable)
continue; continue;


Expand Down
12 changes: 4 additions & 8 deletions ILSimSKProductsRequest.m
Expand Up @@ -21,13 +21,6 @@ - (id) initWithProducts:(NSArray*) p invalidProductIdentifiers:(NSArray*) i;


@implementation ILSimSKProductsRequest @implementation ILSimSKProductsRequest


+ (id) allocWithZone:(NSZone*) z;
{
return [[self class] allocWithZone:z];
}

// Default behavior: none found.

- (id) initWithProductIdentifiers:(NSSet*) productIdentifiers; - (id) initWithProductIdentifiers:(NSSet*) productIdentifiers;
{ {
if (self = [super init]) { if (self = [super init]) {
Expand Down Expand Up @@ -73,7 +66,7 @@ - (void) cancel;
+ (ILSimSKProduct*) simulatedProductForIdentifier:(NSString*) ident; + (ILSimSKProduct*) simulatedProductForIdentifier:(NSString*) ident;
{ {
NSString* productsFile = [[[NSProcessInfo processInfo] environment] objectForKey:@"ILSimSKProductsPlist"]; NSString* productsFile = [[[NSProcessInfo processInfo] environment] objectForKey:@"ILSimSKProductsPlist"];
NSDictionary* d = [NSDictionary dictionaryWithContentsOfFile:productsFile]; NSDictionary* d = productsFile? [NSDictionary dictionaryWithContentsOfFile:productsFile] : nil;


NSDictionary* productData = [d objectForKey:ident]; NSDictionary* productData = [d objectForKey:ident];
if (!productData) if (!productData)
Expand All @@ -87,6 +80,9 @@ + (ILSimSKProduct*) simulatedProductForIdentifier:(NSString*) ident;
NSInteger i = [[productData objectForKey:@"Tier"] unsignedIntegerValue]; NSInteger i = [[productData objectForKey:@"Tier"] unsignedIntegerValue];
p.price = ILSimSKPriceAtTierForCurrentStorefront(i); p.price = ILSimSKPriceAtTierForCurrentStorefront(i);
p.priceLocale = ILSimSKLocaleForCurrentStorefront(); p.priceLocale = ILSimSKLocaleForCurrentStorefront();

NSInteger j = [[productData objectForKey:@"ProductType"] integerValue];
p.simulatedProductType = j;
return p; return p;
} }


Expand Down
23 changes: 23 additions & 0 deletions Products.plist
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>TestItem</key>
<dict>
<key>Title</key>
<string>Test Item</string>
<key>Description</key>
<string>A small test item used to test the simulated StoreKit.</string>
<key>Tier</key>
<integer>2</integer>
<key>ProductType</key>
<integer>0</integer>
<key>COMMENT: ProductType meanings</key>
<array>
<string>Non-Consumable</string>
<string>Consumable</string>
<string>Subscription</string>
</array>
</dict>
</dict>
</plist>
4 changes: 4 additions & 0 deletions SimStoreKit.xcodeproj/project.pbxproj
Expand Up @@ -12,6 +12,7 @@
15491D531119C79B000CE8BB /* libSimStoreKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC07E0554694100DB518D /* libSimStoreKit.a */; }; 15491D531119C79B000CE8BB /* libSimStoreKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC07E0554694100DB518D /* libSimStoreKit.a */; };
15491D561119C7C7000CE8BB /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 15491D551119C7C7000CE8BB /* MainWindow.xib */; }; 15491D561119C7C7000CE8BB /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 15491D551119C7C7000CE8BB /* MainWindow.xib */; };
15491D5E1119C7FB000CE8BB /* TestApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 15491D5D1119C7FB000CE8BB /* TestApp.m */; }; 15491D5E1119C7FB000CE8BB /* TestApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 15491D5D1119C7FB000CE8BB /* TestApp.m */; };
15491DEC1119CF60000CE8BB /* Products.plist in Resources */ = {isa = PBXBuildFile; fileRef = 15491DEB1119CF60000CE8BB /* Products.plist */; };
155551DA111842630082EF0A /* ILSimSKPayment.h in Headers */ = {isa = PBXBuildFile; fileRef = 155551D8111842630082EF0A /* ILSimSKPayment.h */; }; 155551DA111842630082EF0A /* ILSimSKPayment.h in Headers */ = {isa = PBXBuildFile; fileRef = 155551D8111842630082EF0A /* ILSimSKPayment.h */; };
155551DB111842630082EF0A /* ILSimSKPayment.m in Sources */ = {isa = PBXBuildFile; fileRef = 155551D9111842630082EF0A /* ILSimSKPayment.m */; }; 155551DB111842630082EF0A /* ILSimSKPayment.m in Sources */ = {isa = PBXBuildFile; fileRef = 155551D9111842630082EF0A /* ILSimSKPayment.m */; };
155551EC111844230082EF0A /* ILSimSKProduct.h in Headers */ = {isa = PBXBuildFile; fileRef = 155551EA111844230082EF0A /* ILSimSKProduct.h */; }; 155551EC111844230082EF0A /* ILSimSKProduct.h in Headers */ = {isa = PBXBuildFile; fileRef = 155551EA111844230082EF0A /* ILSimSKProduct.h */; };
Expand Down Expand Up @@ -50,6 +51,7 @@
15491D551119C7C7000CE8BB /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; }; 15491D551119C7C7000CE8BB /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; };
15491D5C1119C7FB000CE8BB /* TestApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestApp.h; sourceTree = "<group>"; }; 15491D5C1119C7FB000CE8BB /* TestApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestApp.h; sourceTree = "<group>"; };
15491D5D1119C7FB000CE8BB /* TestApp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestApp.m; sourceTree = "<group>"; }; 15491D5D1119C7FB000CE8BB /* TestApp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestApp.m; sourceTree = "<group>"; };
15491DEB1119CF60000CE8BB /* Products.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Products.plist; sourceTree = "<group>"; };
155551D8111842630082EF0A /* ILSimSKPayment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ILSimSKPayment.h; sourceTree = "<group>"; }; 155551D8111842630082EF0A /* ILSimSKPayment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ILSimSKPayment.h; sourceTree = "<group>"; };
155551D9111842630082EF0A /* ILSimSKPayment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ILSimSKPayment.m; sourceTree = "<group>"; }; 155551D9111842630082EF0A /* ILSimSKPayment.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ILSimSKPayment.m; sourceTree = "<group>"; };
155551EA111844230082EF0A /* ILSimSKProduct.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ILSimSKProduct.h; sourceTree = "<group>"; }; 155551EA111844230082EF0A /* ILSimSKProduct.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ILSimSKProduct.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -159,6 +161,7 @@
children = ( children = (
15491D551119C7C7000CE8BB /* MainWindow.xib */, 15491D551119C7C7000CE8BB /* MainWindow.xib */,
15491D361119C715000CE8BB /* TestApp-Info.plist */, 15491D361119C715000CE8BB /* TestApp-Info.plist */,
15491DEB1119CF60000CE8BB /* Products.plist */,
); );
name = Resources; name = Resources;
sourceTree = "<group>"; sourceTree = "<group>";
Expand Down Expand Up @@ -264,6 +267,7 @@
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
15491D561119C7C7000CE8BB /* MainWindow.xib in Resources */, 15491D561119C7C7000CE8BB /* MainWindow.xib in Resources */,
15491DEC1119CF60000CE8BB /* Products.plist in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
Expand Down
2 changes: 2 additions & 0 deletions TestApp.m
Expand Up @@ -12,6 +12,8 @@ @implementation TestApp


- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
{ {
setenv("ILSimSKProductsPlist", [[[NSBundle mainBundle] pathForResource:@"Products" ofType:@"plist"] fileSystemRepresentation], 1);

[[SKPaymentQueue defaultQueue] addTransactionObserver:self]; [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[window makeKeyAndVisible]; [window makeKeyAndVisible];
return YES; return YES;
Expand Down

0 comments on commit 6cbedf9

Please sign in to comment.