Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added error handling, organize methods #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
31 changes: 15 additions & 16 deletions IAPHelper/IAPHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,40 @@
// Copyright 2011 Ray Wenderlich. All rights reserved.
//


#import <Foundation/Foundation.h>
#import "StoreKit/StoreKit.h"


typedef void (^IAPProductsResponseBlock)(SKProductsRequest* request , SKProductsResponse* response);

typedef void (^IAPbuyProductCompleteResponseBlock)(SKPaymentTransaction* transcation);

typedef void (^checkReceiptCompleteResponseBlock)(NSString* response,NSError* error);
typedef void (^IAPRequestProductsCompletionBlock)(SKProductsRequest *request, SKProductsResponse *response, NSError *error);
typedef void (^IAPBuyProductCompletionBlock)(SKPaymentTransaction *transcation, NSError *error);
typedef void (^IAPCheckReceiptCompletionBlock)(NSString *response, NSError *error);
typedef void (^IAPRestoreProductsCompletionBlock)(SKPaymentQueue *payment, NSError *error);

typedef void (^resoreProductsCompleteResponseBlock) (SKPaymentQueue* payment,NSError* error);

@interface IAPHelper : NSObject <SKProductsRequestDelegate, SKPaymentTransactionObserver>

@property (nonatomic,strong) NSSet *productIdentifiers;
@property (nonatomic,strong) NSArray * products;
@property (nonatomic,strong) NSArray *products;
@property (nonatomic,strong) NSMutableSet *purchasedProducts;
@property (nonatomic,strong) SKProductsRequest *request;
@property (nonatomic) BOOL production;
@property (nonatomic,assign) BOOL production;

- (void)requestProductsWithCompletion:(IAPProductsResponseBlock)completion;
- (id)initWithProductIdentifiers:(NSSet *)productIdentifiers;

- (void)buyProduct:(SKProduct *)productIdentifier onCompletion:(IAPbuyProductCompleteResponseBlock)completion;

- (void)restoreProductsWithCompletion:(resoreProductsCompleteResponseBlock)completion;
- (void)requestProductsWithCompletion:(IAPRequestProductsCompletionBlock)completion;
- (void)buyProduct:(SKProduct *)productIdentifier onCompletion:(IAPBuyProductCompletionBlock)completion;
- (void)provideContent:(NSString *)productIdentifier;

- (BOOL)isPurchasedProductsIdentifier:(NSString*)productID;

- (void)checkReceipt:(NSData*)receiptData onCompletion:(checkReceiptCompleteResponseBlock)completion;
- (void)restoreProductsWithCompletion:(IAPRestoreProductsCompletionBlock)completion;

- (void)checkReceipt:(NSData*)receiptData AndSharedSecret:(NSString*)secretKey onCompletion:(checkReceiptCompleteResponseBlock)completion;

- (void)provideContent:(NSString *)productIdentifier;
- (void)checkReceipt:(NSData*)receiptData onCompletion:(IAPCheckReceiptCompletionBlock)completion;
- (void)checkReceipt:(NSData*)receiptData AndSharedSecret:(NSString*)secretKey onCompletion:(IAPCheckReceiptCompletionBlock)completion;

- (void)clearSavedPurchasedProducts;
- (void)clearSavedPurchasedProductByID:(NSString*)productIdentifier;

@end

Loading