1
This commit is contained in:
@@ -16,16 +16,29 @@
|
||||
completion:(KBPayCompletion)completion {
|
||||
if (needShow) { [KBHUD show]; }
|
||||
|
||||
[[KBNetworkManager shared] POST:API_VALIDATE_RECEIPT jsonBody:params headers:nil autoShowBusinessError:false completion:^(NSDictionary * _Nullable json, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
[[KBNetworkManager shared] POST:API_VALIDATE_RECEIPT
|
||||
jsonBody:params
|
||||
headers:nil
|
||||
autoShowBusinessError:false
|
||||
completion:^(NSDictionary *json,
|
||||
NSURLResponse *response,
|
||||
NSError *error) {
|
||||
if (needShow) { [KBHUD dismiss]; }
|
||||
|
||||
|
||||
if (error) {
|
||||
if (completion) completion(ERROR_CODE, error.localizedDescription ?: KBLocalized(@"Network error"));
|
||||
if ([error.domain isEqualToString:KBNetworkErrorDomain] &&
|
||||
error.code == KBNetworkErrorBusiness) {
|
||||
NSNumber *codeNum = error.userInfo[@"code"];
|
||||
NSInteger bizCode = codeNum.integerValue; // 这里就是底层附带的业务 code
|
||||
// 根据 bizCode 做处理,比如透传给上层 completion
|
||||
if (completion) completion(bizCode, error.localizedDescription ?: KBLocalized(@"Network error"));
|
||||
return;
|
||||
}
|
||||
|
||||
// if (completion) completion(ERROR_CODE, error.localizedDescription ?: KBLocalized(@"Network error"));
|
||||
return;
|
||||
}
|
||||
|
||||
// NSInteger sta = [self.class extractStatusFromResponseObject:jsonOrData response:response];
|
||||
// NSString *msg = [self.class extractMessageFromResponseObject:jsonOrData] ?: (sta == KBBizCodeSuccess ? @"OK" : KBLocalized(@"Failed"));
|
||||
|
||||
if (completion) completion(KBBizCodeSuccess, @"ok");
|
||||
}];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user