1
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#import "KBAPI.h"
|
||||
#import "KBHUD.h"
|
||||
#import "KBBizCode.h"
|
||||
#import "KBPayProductModel.h"
|
||||
#import <MJExtension/MJExtension.h>
|
||||
@implementation PayVM
|
||||
|
||||
- (void)applePayReqWithParams:(NSDictionary *)params
|
||||
@@ -28,6 +30,40 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)fetchInAppProductsNeedShow:(BOOL)needShow
|
||||
completion:(KBPayProductsCompletion)completion {
|
||||
if (needShow) { [KBHUD show]; }
|
||||
NSDictionary *params = @{ @"type": @"in-app-purchase" };
|
||||
[[KBNetworkManager shared] GET:API_INAPP_PRODUCT_LIST
|
||||
parameters:params
|
||||
headers:nil
|
||||
autoShowBusinessError:NO
|
||||
completion:^(NSDictionary * _Nullable json,
|
||||
NSURLResponse * _Nullable response,
|
||||
NSError * _Nullable error) {
|
||||
if (needShow) { [KBHUD dismiss]; }
|
||||
if (error) {
|
||||
if (completion) {
|
||||
NSInteger code = (error.code == 0 ? KBBizCodeSystemError : error.code);
|
||||
completion(code, error.localizedDescription ?: KBLocalized(@"Network error"), nil);
|
||||
}
|
||||
return;
|
||||
}
|
||||
id dataObj = json[KBData] ?: json[@"data"];
|
||||
if (![dataObj isKindOfClass:[NSArray class]]) {
|
||||
if (completion) {
|
||||
NSString *msg = [self.class extractMessageFromResponseObject:json] ?: KBLocalized(@"Invalid response");
|
||||
completion(KBBizCodeSystemError, msg, nil);
|
||||
}
|
||||
return;
|
||||
}
|
||||
NSArray<KBPayProductModel *> *models = [KBPayProductModel mj_objectArrayWithKeyValuesArray:(NSArray *)dataObj];
|
||||
if (completion) {
|
||||
completion(KBBizCodeSuccess, nil, models ?: @[]);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
||||
//+ (NSInteger)extractStatusFromResponseObject:(id)obj response:(NSURLResponse *)resp {
|
||||
|
||||
Reference in New Issue
Block a user