Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
Sending receipt data is now possible
Browse files Browse the repository at this point in the history
  • Loading branch information
MugunthKumar committed May 11, 2012
1 parent c91a876 commit 28d483e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion MKSKProduct.m
Expand Up @@ -30,7 +30,7 @@

#import "MKSKProduct.h"
#if ! __has_feature(objc_arc)
#error MKNetworkKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#error MKStoreKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#endif

static void (^onReviewRequestVerificationSucceeded)();
Expand Down
2 changes: 1 addition & 1 deletion MKSKSubscriptionProduct.m
Expand Up @@ -32,7 +32,7 @@
#import "MKSKSubscriptionProduct.h"
#import "NSData+Base64.h"
#if ! __has_feature(objc_arc)
#error MKNetworkKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#error MKStoreKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#endif

@implementation MKSKSubscriptionProduct
Expand Down
1 change: 1 addition & 0 deletions MKStoreManager.h
Expand Up @@ -76,6 +76,7 @@
//for testing proposes you can use this method to remove all the saved keychain data (saved purchases, etc.)
- (BOOL) removeAllKeychainData;

+(id) receiptForKey:(NSString*) key;
+(void) setObject:(id) object forKey:(NSString*) key;
+(NSNumber*) numberForKey:(NSString*) key;

Expand Down
21 changes: 16 additions & 5 deletions MKStoreManager.m
Expand Up @@ -38,7 +38,7 @@
#import "MKSKProduct.h"
#import "NSData+Base64.h"
#if ! __has_feature(objc_arc)
#error MKNetworkKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#error MKStoreKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#endif

@interface MKStoreManager () //private methods and properties
Expand All @@ -57,7 +57,7 @@ @interface MKStoreManager () //private methods and properties

- (void) requestProductData;
- (void) startVerifyingSubscriptionReceipts;
-(void) rememberPurchaseOfProduct:(NSString*) productIdentifier;
-(void) rememberPurchaseOfProduct:(NSString*) productIdentifier withReceipt:(NSData*) receiptData;
-(void) addToQueue:(NSString*) productId;
@end

Expand Down Expand Up @@ -151,6 +151,15 @@ +(void) setObject:(id) object forKey:(NSString*) key
}
}

+(id) receiptForKey:(NSString*) key {

NSData *receipt = [MKStoreManager objectForKey:key];
if(!receipt)
receipt = [MKStoreManager objectForKey:[NSString stringWithFormat:@"%@-receipt", key]];

return receipt;
}

+(id) objectForKey:(NSString*) key
{
NSError *error = nil;
Expand Down Expand Up @@ -589,7 +598,7 @@ -(void) provideContent: (NSString*) productIdentifier

[thisProduct verifyReceiptOnComplete:^
{
[self rememberPurchaseOfProduct:productIdentifier];
[self rememberPurchaseOfProduct:productIdentifier withReceipt:receiptData];
}
onError:^(NSError* error)
{
Expand All @@ -605,15 +614,15 @@ -(void) provideContent: (NSString*) productIdentifier
}
else
{
[self rememberPurchaseOfProduct:productIdentifier];
[self rememberPurchaseOfProduct:productIdentifier withReceipt:receiptData];
if(self.onTransactionCompleted)
self.onTransactionCompleted(productIdentifier, receiptData);
}
}
}


-(void) rememberPurchaseOfProduct:(NSString*) productIdentifier
-(void) rememberPurchaseOfProduct:(NSString*) productIdentifier withReceipt:(NSData*) receiptData
{
NSDictionary *allConsumables = [[self storeKitItems] objectForKey:@"Consumables"];
if([[allConsumables allKeys] containsObject:productIdentifier])
Expand All @@ -631,6 +640,8 @@ -(void) rememberPurchaseOfProduct:(NSString*) productIdentifier
{
[MKStoreManager setObject:[NSNumber numberWithBool:YES] forKey:productIdentifier];
}

[MKStoreManager setObject:receiptData forKey:[NSString stringWithFormat:@"%@-receipt", productIdentifier]];
}

- (void) transactionCanceled: (SKPaymentTransaction *)transaction
Expand Down
2 changes: 1 addition & 1 deletion MKStoreObserver.m
Expand Up @@ -18,7 +18,7 @@
#import "MKStoreObserver.h"
#import "MKStoreManager.h"
#if ! __has_feature(objc_arc)
#error MKNetworkKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#error MKStoreKit is ARC only. Either turn on ARC for the project or use -fobjc-arc flag
#endif

@interface MKStoreManager (InternalMethods)
Expand Down

0 comments on commit 28d483e

Please sign in to comment.