Permalink
Browse files

MANY bugfixes.

  • Loading branch information...
1 parent 293cfd9 commit 6cbedf98de99899186749bc70c795d292ed69ef1 @millenomi committed Feb 3, 2010
Showing with 40 additions and 11 deletions.
  1. +3 −1 ILSimSKPayment.m
  2. +4 −2 ILSimSKPaymentQueue.m
  3. +4 −8 ILSimSKProductsRequest.m
  4. +23 −0 Products.plist
  5. +4 −0 SimStoreKit.xcodeproj/project.pbxproj
  6. +2 −0 TestApp.m
View
@@ -27,8 +27,10 @@ @implementation ILSimSKPayment
- (id) initWithProductIdentifier:(NSString*) pid;
{
- if (self = [super init])
+ if (self = [super init]) {
productIdentifier = [pid copy];
+ quantity = 1;
+ }
return self;
}
View
@@ -74,6 +74,8 @@ - (void) addPayment:(ILSimSKPayment*) p;
t.payment = p;
t.transactionDate = [NSDate date];
+ [transactions addObject:t];
+
if ([observers count] > 0)
[self performSelector:@selector(processNextTransaction) withObject:nil afterDelay:2.0];
}
@@ -153,7 +155,7 @@ - (void) succeed;
p.productIdentifier, @"ProductID",
[NSNumber numberWithInteger:self.currentTransaction.payment.quantity], @"Quantity",
self.currentTransaction.transactionIdentifier, @"TransactionID",
- [NSNumber numberWithInteger:p.simulatedProductType], @"SimulatedProductType",
+ [NSNumber numberWithInteger:p.simulatedProductType], @"ProductType",
self.currentTransaction.transactionDate, @"Date",
nil];
@@ -218,7 +220,7 @@ - (void) restoreCompletedTransactions;
if (![d isKindOfClass:[NSDictionary class]])
continue;
- id kind = [d objectForKey:@"SimulatedProductType"];
+ id kind = [d objectForKey:@"ProductType"];
if (!kind || ![kind isKindOfClass:[NSNumber class]] || [kind integerValue] != kILSimSimulatedProductTypeNonConsumable)
continue;
View
@@ -21,13 +21,6 @@ - (id) initWithProducts:(NSArray*) p invalidProductIdentifiers:(NSArray*) i;
@implementation ILSimSKProductsRequest
-+ (id) allocWithZone:(NSZone*) z;
-{
- return [[self class] allocWithZone:z];
-}
-
-// Default behavior: none found.
-
- (id) initWithProductIdentifiers:(NSSet*) productIdentifiers;
{
if (self = [super init]) {
@@ -73,7 +66,7 @@ - (void) cancel;
+ (ILSimSKProduct*) simulatedProductForIdentifier:(NSString*) ident;
{
NSString* productsFile = [[[NSProcessInfo processInfo] environment] objectForKey:@"ILSimSKProductsPlist"];
- NSDictionary* d = [NSDictionary dictionaryWithContentsOfFile:productsFile];
+ NSDictionary* d = productsFile? [NSDictionary dictionaryWithContentsOfFile:productsFile] : nil;
NSDictionary* productData = [d objectForKey:ident];
if (!productData)
@@ -87,6 +80,9 @@ + (ILSimSKProduct*) simulatedProductForIdentifier:(NSString*) ident;
NSInteger i = [[productData objectForKey:@"Tier"] unsignedIntegerValue];
p.price = ILSimSKPriceAtTierForCurrentStorefront(i);
p.priceLocale = ILSimSKLocaleForCurrentStorefront();
+
+ NSInteger j = [[productData objectForKey:@"ProductType"] integerValue];
+ p.simulatedProductType = j;
return p;
}
View
@@ -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>
@@ -12,6 +12,7 @@
15491D531119C79B000CE8BB /* libSimStoreKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D2AAC07E0554694100DB518D /* libSimStoreKit.a */; };
15491D561119C7C7000CE8BB /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 15491D551119C7C7000CE8BB /* MainWindow.xib */; };
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 */; };
155551DB111842630082EF0A /* ILSimSKPayment.m in Sources */ = {isa = PBXBuildFile; fileRef = 155551D9111842630082EF0A /* ILSimSKPayment.m */; };
155551EC111844230082EF0A /* ILSimSKProduct.h in Headers */ = {isa = PBXBuildFile; fileRef = 155551EA111844230082EF0A /* ILSimSKProduct.h */; };
@@ -50,6 +51,7 @@
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>"; };
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>"; };
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>"; };
@@ -159,6 +161,7 @@
children = (
15491D551119C7C7000CE8BB /* MainWindow.xib */,
15491D361119C715000CE8BB /* TestApp-Info.plist */,
+ 15491DEB1119CF60000CE8BB /* Products.plist */,
);
name = Resources;
sourceTree = "<group>";
@@ -264,6 +267,7 @@
buildActionMask = 2147483647;
files = (
15491D561119C7C7000CE8BB /* MainWindow.xib in Resources */,
+ 15491DEC1119CF60000CE8BB /* Products.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
@@ -12,6 +12,8 @@ @implementation TestApp
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
{
+ setenv("ILSimSKProductsPlist", [[[NSBundle mainBundle] pathForResource:@"Products" ofType:@"plist"] fileSystemRepresentation], 1);
+
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[window makeKeyAndVisible];
return YES;

0 comments on commit 6cbedf9

Please sign in to comment.