IAPHelper.h
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// IAPHelper.h
//
// Original Created by Ray Wenderlich on 2/28/11.
// Created by saturngod on 7/9/12.
// 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 (^resoreProductsCompleteResponseBlock) (SKPaymentQueue* payment,NSError* error);
@interface IAPHelper : NSObject <SKProductsRequestDelegate, SKPaymentTransactionObserver>
@property (nonatomic,strong) NSSet *productIdentifiers;
@property (nonatomic,strong) NSArray * products;
@property (nonatomic,strong) NSMutableSet *purchasedProducts;
@property (nonatomic,strong) SKProductsRequest *request;
@property (nonatomic) BOOL production;
//init With Product Identifiers
- (id)initWithProductIdentifiers:(NSSet *)productIdentifiers;
//get Products List
- (void)requestProductsWithCompletion:(IAPProductsResponseBlock)completion;
//Buy Product
- (void)buyProduct:(SKProduct *)productIdentifier onCompletion:(IAPbuyProductCompleteResponseBlock)completion;
//restore Products
- (void)restoreProductsWithCompletion:(resoreProductsCompleteResponseBlock)completion;
//check isPurchased or not
- (BOOL)isPurchasedProductsIdentifier:(NSString*)productID;
//check receipt but recommend to use in server side instead of using this function
- (void)checkReceipt:(NSData*)receiptData onCompletion:(checkReceiptCompleteResponseBlock)completion;
- (void)checkReceipt:(NSData*)receiptData AndSharedSecret:(NSString*)secretKey onCompletion:(checkReceiptCompleteResponseBlock)completion;
//saved purchased product
- (void)provideContentWithTransaction:(SKPaymentTransaction *)transaction;
- (void)provideContent:(NSString *)productIdentifier __deprecated_msg("use provideContentWithTransaction: instead.");
//clear the saved products
- (void)clearSavedPurchasedProducts;
- (void)clearSavedPurchasedProductByID:(NSString*)productIdentifier;
//Get The Price with local currency
- (NSString *)getLocalePrice:(SKProduct *)product;
@end