TCGBPurchase Class Reference
Inherits from | NSObject |
---|---|
Declared in | TCGBPurchase.h |
Overview
The TCGBPurchase class provides several APIs related to purchasing processes.
Before using these APIs, You should be logged in. Because every TCGBPurchase API need informations that are obtained from TCGBServer.
If you do not have been authenticated, you will get TCGB_ERROR_NOT_LOGGED_IN error.
Request Item List
+ requestItemListPurchasableWithCompletion:
This is the primary method for obtaining ItemList which is registered at ToastCloud IAP Console and Apple Itunes Connect.
+ (void)requestItemListPurchasableWithCompletion:(void ( ^ ) ( NSArray<TCGBPurchasableItem*> *purchasableItemArray , TCGBError *error ))completion
Parameters
completion |
completion may return the NSArray of TCGBPurchasableItem. |
---|
Discussion
Request a item list which is purchasable. This list has items which are registered in both Market(AppStore) and ToastCloud IAP Console.
Warning: You should call this method after logged in
, otherwise you will get TCGB_ERROR_NOT_LOGGED_IN error in the completion.
Usage Example
- (void)viewDidLoad {
[TCGBPurchase requestItemListPurchasableWithCompletion:^(NSArray *purchasableItemArray, TCGBError *error) {
NSMutableArray *itemArrayMutable = [[NSMutableArray alloc] init];
[purchasableItemArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
TCGBPurchasableItem *item = (TCGBPurchasableItem *)obj;
[itemArrayMutable addObject:item];
}];
}];
}
Declared In
TCGBPurchase.h
+ requestItemListAtIAPConsoleWithCompletion:
This is the method for obtaining ItemList which is registered at ToastCloud IAP Console.
+ (void)requestItemListAtIAPConsoleWithCompletion:(void ( ^ ) ( NSArray<TCGBPurchasableItem*> *purchasableItemArray , TCGBError *error ))completion
Parameters
completion |
completion may return the NSArray of TCGBPurchasableItem. |
---|
Discussion
Request a item list which is purchasable. This list has items which are only registered in ToastCloud IAP Console, not Market(AppStore)
Warning: You should call this method after logged in
, otherwise you will get TCGB_ERROR_NOT_LOGGED_IN error in the completion.
Usage Example
- (void)viewDidLoad {
[TCGBPurchase requestItemListAtIAPConsoleWithCompletion:^(NSArray *purchasableItemArray, TCGBError *error) {
NSMutableArray *itemArrayMutable = [[NSMutableArray alloc] init];
[purchasableItemArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
TCGBPurchasableItem *item = (TCGBPurchasableItem *)obj;
[itemArrayMutable addObject:item];
}];
}];
}
Declared In
TCGBPurchase.h
Request Purchasing Item
+ requestPurchaseWithItemSeq:viewController:completion:
This is the method to request purchasing item which identifier is itemSeq. There is a viewController parameter and you may put your top most viewController. If you don’t, this method will find out top most view controller and put it in the parameter.
+ (void)requestPurchaseWithItemSeq:(long)itemSeq viewController:(UIViewController *)viewController completion:(void ( ^ ) ( TCGBPurchasableReceipt *purchasableReceipt , TCGBError *error ))completion
Parameters
itemSeq |
itemID which you want to purchase. |
---|---|
viewController |
represent to current viewcontroller. |
completion |
completion may return the TCGBPurchasableReceipt instance. |
Discussion
Request Purchasing Item that has itemId.
Warning: You should call this method after logged in
, otherwise you will get TCGB_ERROR_NOT_LOGGED_IN error in the completion.
Usage Example
- (void)purchasingItem:(long)itemSeq {
[TCGBPurchase requestPurchaseWithItemSeq:itemSeq viewController:self completion:^(TCGBPurchasableReceipt *purchasableReceipt, TCGBError *error) {
if (error.code == TCGB_ERROR_PURCHASE_USER_CANCELED) {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Item Purchase"
message:[NSString stringWithFormat:@"You Canceled."]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertView show];
});
} else if (error) {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Item Purchase"
message:[NSString stringWithFormat:@"There was an Error : %ld", (long)error.code]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertView show];
});
}
}];
}
Declared In
TCGBPurchase.h
Request non-consumed Item List
+ requestItemListOfNotConsumedWithCompletion:
This method provides an item list that have non-consumed.
+ (void)requestItemListOfNotConsumedWithCompletion:(void ( ^ ) ( NSArray<TCGBPurchasableReceipt*> *purchasableReceiptArray , TCGBError *error ))completion
Parameters
completion |
completion may return the NSArray of TCGBPurchasableReceipt instances. |
---|
Discussion
Request a Item List which is not consumed. You should deliver this itemReceipt to your game server to consume it or request consuming API to ToastCloud IAP Server. You may call this method after logged in and deal with these non-consumed items.
Warning: You should call this method after logged in
, otherwise you will get TCGB_ERROR_NOT_LOGGED_IN error in the completion.
Usage Example
- (void)viewDidLoad {
[TCGBPurchase requestItemListOfNotConsumedWithCompletion:^(NSArrayTCGBPurchasableReceipt *> *purchasableReceiptArray, TCGBError *error) {
// should deal with this not-consumed items.
}];
}
Declared In
TCGBPurchase.h
Request retry purchasing processes
+ requestRetryTransactionWithCompletion:
This method is for retrying failed purchasing proccesses.
+ (void)requestRetryTransactionWithCompletion:(void ( ^ ) ( TCGBPurchasableRetryTransactionResult *transactionResult , TCGBError *error ))completion
Parameters
completion |
completion may return the TCGBPurchasableRetryTransactionResult which has two member variables which are named ‘successList’ and ‘failList’. Usage Example
|
---|
Discussion
Request a retrying transaction which is not completed to IAP Server
Declared In
TCGBPurchase.h