1
This commit is contained in:
@@ -9,9 +9,10 @@
|
|||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
FOUNDATION_EXPORT NSString * const KBIAPDidCompletePurchaseNotification;
|
||||||
|
|
||||||
@interface IAPVerifyTransactionObj : NSObject <FGIAPVerifyTransaction>
|
@interface IAPVerifyTransactionObj : NSObject <FGIAPVerifyTransaction>
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#import "KBHUD.h"
|
#import "KBHUD.h"
|
||||||
//#import "KBLoginSheetViewController.h"
|
//#import "KBLoginSheetViewController.h"
|
||||||
#import "KBBizCode.h"
|
#import "KBBizCode.h"
|
||||||
|
|
||||||
|
NSString * const KBIAPDidCompletePurchaseNotification = @"KBIAPDidCompletePurchaseNotification";
|
||||||
@interface IAPVerifyTransactionObj ()
|
@interface IAPVerifyTransactionObj ()
|
||||||
@property (nonatomic, strong) PayVM *payVM;
|
@property (nonatomic, strong) PayVM *payVM;
|
||||||
@end
|
@end
|
||||||
@@ -41,10 +43,11 @@
|
|||||||
__weak typeof(self) weakSelf = self;
|
__weak typeof(self) weakSelf = self;
|
||||||
[self.payVM applePayReqWithParams:params needShow:NO completion:^(NSInteger sta, NSString * _Nullable msg) {
|
[self.payVM applePayReqWithParams:params needShow:NO completion:^(NSInteger sta, NSString * _Nullable msg) {
|
||||||
// [KBHUD dismiss];
|
// [KBHUD dismiss];
|
||||||
[KBHUD showInfo:(sta == !KBBizCodeSuccess ? KBLocalized(@"Payment failed") : KBLocalized(@"Payment successful"))];
|
// [KBHUD showInfo:(sta == !KBBizCodeSuccess ? KBLocalized(@"Payment failed") : KBLocalized(@"Payment successful"))];
|
||||||
if (sta == KBBizCodeSuccess) {
|
if (sta == KBBizCodeSuccess) {
|
||||||
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
||||||
[KBHUD showSuccess:@"Success"];
|
[KBHUD showInfo:@"Success"];
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:KBIAPDidCompletePurchaseNotification object:nil];
|
||||||
if (handler) handler(KBLocalized(@"Success"), nil);
|
if (handler) handler(KBLocalized(@"Success"), nil);
|
||||||
}else if(sta == KBBizCodeReceiptError){
|
}else if(sta == KBBizCodeReceiptError){
|
||||||
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#import "KBPayProductModel.h"
|
#import "KBPayProductModel.h"
|
||||||
#import "KBBizCode.h"
|
#import "KBBizCode.h"
|
||||||
#import "KBShopVM.h"
|
#import "KBShopVM.h"
|
||||||
|
#import "IAPVerifyTransactionObj.h"
|
||||||
static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
|
static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
|
||||||
|
|
||||||
@interface KBJfPay () <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
|
@interface KBJfPay () <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
|
||||||
@@ -52,6 +53,10 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
|
|||||||
self.filter = [[FGIAPProductsFilter alloc] init];
|
self.filter = [[FGIAPProductsFilter alloc] init];
|
||||||
self.payVM = [PayVM new];
|
self.payVM = [PayVM new];
|
||||||
self.shopVM = [KBShopVM new];
|
self.shopVM = [KBShopVM new];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(handleIAPPurchaseSuccess)
|
||||||
|
name:KBIAPDidCompletePurchaseNotification
|
||||||
|
object:nil];
|
||||||
self.data = @[];
|
self.data = @[];
|
||||||
self.selectedIndex = NSNotFound;
|
self.selectedIndex = NSNotFound;
|
||||||
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_bg_icon"]];
|
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_bg_icon"]];
|
||||||
@@ -151,6 +156,10 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
|
|||||||
[self selectItemAtCurrentIndexAnimated:NO];
|
[self selectItemAtCurrentIndexAnimated:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - UICollectionView Delegate (ensure first show)
|
#pragma mark - UICollectionView Delegate (ensure first show)
|
||||||
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
|
- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||||
if (![cell isKindOfClass:KBJfPayCell.class]) { return; }
|
if (![cell isKindOfClass:KBJfPayCell.class]) { return; }
|
||||||
@@ -242,6 +251,10 @@ static NSString * const kKBJfPayCellId = @"kKBJfPayCellId";
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)handleIAPPurchaseSuccess {
|
||||||
|
[self fetchWalletBalance];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)fetchInAppProductList {
|
- (void)fetchInAppProductList {
|
||||||
__weak typeof(self) weakSelf = self;
|
__weak typeof(self) weakSelf = self;
|
||||||
[self.payVM fetchInAppProductsNeedShow:YES completion:^(NSInteger sta, NSString * _Nullable msg, NSArray<KBPayProductModel *> * _Nullable products) {
|
[self.payVM fetchInAppProductsNeedShow:YES completion:^(NSInteger sta, NSString * _Nullable msg, NSArray<KBPayProductModel *> * _Nullable products) {
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
[self fetchShopStylesWithHUD:YES];
|
[self fetchShopStylesWithHUD:YES];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)viewWillAppear:(BOOL)animated{
|
||||||
|
[super viewWillAppear:animated];
|
||||||
[self fetchWalletBalanceWithHUD:NO];
|
[self fetchWalletBalanceWithHUD:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user