InApps iOS
LDInAppService.h
1 #import <UIKit/UIKit.h>
2 
3 @interface LDInAppProduct: NSObject
4 
8 @property (nonatomic, strong) NSString * productId;
9 
13 @property (nonatomic, strong) NSString * localizedTitle;
14 
18 @property (nonatomic, strong) NSString * localizedDescription;
19 
23 @property (nonatomic, assign) CGFloat price;
24 
28 @property (nonatomic, strong) NSString * localizedPrice;
29 
30 @property (nonatomic, strong) NSString * currency;
31 
32 -(NSDictionary *) toDictionary;
33 +(instancetype) fromDictionary:(NSDictionary *) dic;
34 
35 @end
36 
37 @interface LDInAppPurchase : NSObject
38 
42 @property (nonatomic, strong) NSString * transactionId;
43 
47 @property (nonatomic, strong) NSString * productId;
48 
52 @property (nonatomic, strong) NSDate * purchaseDate;
53 
57 @property (nonatomic, assign) NSInteger quantity;
58 
59 -(NSDictionary *) toDictionary;
60 
61 @end
62 
63 @class LDInAppService;
64 
66 @optional
67 
74 -(void) inAppService:(LDInAppService *) service didStartPurchase:(NSString *) productId;
75 
83 -(void) inAppService:(LDInAppService *) service didFailPurchase:(NSString *) productId withError:(NSError *) error;
84 
91 -(void) inAppService:(LDInAppService *) service didCompletePurchase:(LDInAppPurchase *) purchase;
92 
93 @end
94 
95 @interface LDInAppService: NSObject
96 
100 @property (nonatomic, readonly) NSMutableArray * products;
101 
105 @property (nonatomic, assign) BOOL autoFinishPurchases;
106 
107 
108 typedef void(^LDFetchProductsCallback)(NSArray * products, NSError * error);
109 typedef void(^LDValidationCompletion)(NSError * error);
110 typedef void(^LDValidationHandler)(NSData * validationReceipt, NSString * productId, LDValidationCompletion completion);
111 
112 -(instancetype) init;
113 
119 -(void) addPurchaseObserver:(id<LDInAppPurchaseObserver>) observer;
120 
126 -(void) removePurchaseObserver:(id<LDInAppPurchaseObserver>) observer;
127 
132 -(void) start;
133 
141 -(void) fetchProducts: (NSArray *) productIds completion:(LDFetchProductsCallback) completion;
142 
151 -(LDInAppProduct*) productForId:(NSString *) identifier;
152 
161 -(BOOL) isPurchased:(NSString *) productId;
162 
173 -(NSInteger) stockOfProduct:(NSString *) productId;
174 
183 -(void) restorePurchases:(void(^)(NSError * error)) completion;
184 
190 -(BOOL) canPurchase;
191 
200 -(void) purchase:(NSString *) productId completion:(void(^)(NSError * error)) completion;
201 
211 -(void) purchase:(NSString *) productId quantity:(NSInteger) quantity completion:(void(^)(NSError * error)) completion;
212 
222 -(NSInteger) consume:(NSString *) productId quantity:(NSInteger) quantity;
223 
230 -(void) finishPurchase:(NSString *) transactionId;
231 
239 -(void) setValidationHandler:(LDValidationHandler) handler;
240 
245 -(void) setLudeiServerValidationHandler;
246 
247 @end
NSString * localizedTitle
Definition: LDInAppService.h:13
NSString * localizedPrice
Definition: LDInAppService.h:28
Definition: LDInAppService.h:65
Definition: LDInAppService.h:3
NSString * productId
Definition: LDInAppService.h:8
NSString * localizedDescription
Definition: LDInAppService.h:18
CGFloat price
Definition: LDInAppService.h:23
Definition: LDInAppService.h:95
Definition: LDInAppService.h:37