Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (void)readJsonResponeEndPPWide:(NSURLRequest *)request{
- if(request && [request URL] && [[request URL] absoluteString] && [UiElementsUtils isNotEmpty:[[request URL] absoluteString]]){
- if (![[FBNetworkReachability sharedInstance]reachable]) {
- [[NSNotificationCenter defaultCenter] postNotificationName:kHideHUD object:nil];
- [[NSNotificationCenter defaultCenter] postNotificationName:kConnectionLose object:nil];
- return;
- }
- [[NSNotificationCenter defaultCenter] postNotificationName:kShowHUD object:nil];
- NSString *tmpUrl = [[request URL] absoluteString];
- if(tmpUrl && [UiElementsUtils isNotEmpty:tmpUrl]){
- NSString *decodedText = [tmpUrl stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- if(decodedText && [UiElementsUtils isNotEmpty:decodedText]){
- if([decodedText containsString:@"parameters="]){
- NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:[request URL] resolvingAgainstBaseURL:NO];
- NSArray *queryItems = urlComponents.queryItems;
- if(queryItems && [UiElementsUtils isNotEmpty:queryItems]){
- NSString *paramTot = [UiElementsUtils valueForKey:@"parameters" fromQueryItems:queryItems];
- DDLogInfo(@"Parameters - %@",paramTot);
- if(paramTot && [UiElementsUtils isNotEmpty:paramTot]){
- if([paramTot containsString:@"%5B"]){
- paramTot = [paramTot stringByReplacingOccurrencesOfString:@"%5B" withString:@"]"];
- }
- if([paramTot containsString:@"%5D"]){
- paramTot = [paramTot stringByReplacingOccurrencesOfString:@"%5D" withString:@"]"];
- }
- if([paramTot containsString:@"]"] && [paramTot containsString:@"["]){
- NSRange start = [paramTot rangeOfString:@"["];
- NSRange end = [paramTot rangeOfString:@"]"];
- NSString *shortString = [paramTot substringWithRange:NSMakeRange(start.location, end.location)];
- if(shortString && [UiElementsUtils isNotEmpty:shortString]){
- shortString = [shortString stringByReplacingOccurrencesOfString:@"]" withString:@""];
- shortString = [shortString stringByReplacingOccurrencesOfString:@"[" withString:@""];
- NSArray *splitParam = [shortString componentsSeparatedByString:@","];
- if(splitParam && [UiElementsUtils isNotEmpty:splitParam]){
- NSString *msisdn = @"";
- NSString *customerCode = @"";
- NSString *contractCode = @"";
- NSString *msisdnToRecharge = @"";
- NSString *flagPP = @"";
- NSString *agreementId = @"";
- NSString *channel = @"";
- NSString *importo = @"";
- NSString *importoBonus = @"";
- NSString *value = @"";
- NSString *idPromo = @"";
- NSString *percentualeGA = @"";
- NSString *tagPromo = @"";
- NSString *transactionID = @"";
- NSString *callID = @"";
- NSString *testoGA = @"";
- for(int i=0; i<[splitParam count];i++){
- NSString *str = splitParam[i];
- if(str && [UiElementsUtils isNotEmpty:str]){
- if([str containsString:@"'"]){
- str = [str stringByReplacingOccurrencesOfString:@"'" withString:@""];
- }
- }
- if(i==0){
- msisdn = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==1){
- customerCode = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==2){
- contractCode = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==3){
- msisdnToRecharge = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==4){
- flagPP = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==5){
- agreementId = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==6){
- channel = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==7){
- importo = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==8){
- importoBonus = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==9){
- value = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==10){
- idPromo = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==11){
- percentualeGA = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==12){
- tagPromo = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==13){
- transactionID = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==14){
- callID = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else if(i==15){
- testoGA = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
- }else{
- //NOP
- }
- }
- NSString *token = @"";
- NSString *payerId = @"";
- NSString *paramToken = [UiElementsUtils valueForKey:@"token" fromQueryItems:queryItems];
- DDLogInfo(@"Token - %@", paramToken);
- if(paramToken && [UiElementsUtils isNotEmpty:paramToken]){
- token = [paramToken copy];
- }
- NSString *paramPayerID = [UiElementsUtils valueForKey:@"PayerID" fromQueryItems:queryItems];
- DDLogInfo(@"PayerID - %@", paramPayerID);
- if(paramPayerID && [UiElementsUtils isNotEmpty:paramPayerID]){
- payerId = [paramPayerID copy];
- }
- __typeof(self) __weak weakSelf = self;
- [[WLBlocks sharedManager] endPaypalRechargeNewWideWithMsisdn:msisdn
- andCustomerCode:customerCode
- andContractCode:contractCode
- andMsisdnToRecharge:msisdnToRecharge
- andFlagPP:flagPP
- andAgreementId:agreementId
- andImporto:importo
- andImportoBonus:importoBonus
- andValue:value
- andIdPromo:idPromo
- andPercentualeGA:percentualeGA
- andTagPromo:tagPromo
- andTransactionID:transactionID
- andCallID:callID
- andTestoGA:testoGA
- andChannel:channel
- andToken:token
- andPayerId:payerId
- andShowProgressBeforeProcess:NO
- andHideProgressAfterProcess:NO
- success:^(id data, NSString *request) {
- weakSelf.statoPagamento = failure;
- if(request && data && [request isEqualToString:EndPaypalRechargeNew] && [data isKindOfClass:[NSDictionary class]]){
- NSDictionary *responseDic = (NSDictionary *)data;
- if(responseDic && [UiElementsUtils isNotEmpty:responseDic]){
- RechargeResponseNewObj *ppObj = [weakSelf managerResponse:responseDic];
- if(ppObj){
- if([ppObj transactionId] && [UiElementsUtils isNotEmpty:[ppObj transactionId]]){
- weakSelf.statoPagamento = success;
- [ppObj setStatus:@0];
- [weakSelf goToNextStepWide:ppObj];
- }else{
- [weakSelf goToNextStepWide:ppObj];
- }
- return;
- }
- }
- }
- [weakSelf goToNextStepWide:[weakSelf defaultResponse]];
- }failure:^(ResponseModel *response, NSString *request) {
- weakSelf.statoPagamento = failure;
- [weakSelf goToNextStepWide:[weakSelf defaultResponse]];
- }failureFull:^(ResponseModel *response, id data, NSString *request) {
- weakSelf.statoPagamento = failure;
- if(request && data && [request isEqualToString:EndPaypalRechargeNew] && [data isKindOfClass:[NSDictionary class]]){
- NSDictionary *responseDic = (NSDictionary *)data;
- if(responseDic && [UiElementsUtils isNotEmpty:responseDic]){
- RechargeResponseNewObj *ppObj = [weakSelf managerResponse:responseDic];
- if(ppObj){
- [weakSelf goToNextStepWide:ppObj];
- return;
- }
- }
- }
- [weakSelf goToNextStepWide:[weakSelf defaultResponse]];
- }connectionError:^{ }];
- return;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- _statoPagamento = failure;
- [self goToNextStepWide:[self defaultResponse]];
- }
- -(void)endPaypalRechargeNewWideWithMsisdn:(NSString *)msisdn
- andCustomerCode:(NSString *)customerCode
- andContractCode:(NSString *)contractCode
- andMsisdnToRecharge:(NSString *)msisdnToRecharge
- andFlagPP:(NSString *)flagPP
- andAgreementId:(NSString *)agreementId
- andImporto:(NSString *)importo
- andImportoBonus:(NSString *)importoBonus
- andValue:(NSString *)value
- andIdPromo:(NSString *)idPromo
- andPercentualeGA:(NSString *)percentualeGA
- andTagPromo:(NSString *)tagPromo
- andTransactionID:(NSString *)transactionID
- andCallID:(NSString *)callID
- andTestoGA:(NSString *)testoGA
- andChannel:(NSString *)channel
- andToken:(NSString *)token
- andPayerId:(NSString *)payerId
- andShowProgressBeforeProcess:(BOOL)show
- andHideProgressAfterProcess:(BOOL)hide
- success:(void (^)(id data, NSString *request))success
- failure:(void (^)(ResponseModel *response, NSString *request))failure
- failureFull:(void (^)(ResponseModel *response, id data, NSString *request))failureFull
- connectionError:(void (^)())connectionError{
- [self loadBlockWithSuccess:success failure:failure
- failureFull:failureFull connectionError:connectionError
- andHideProgress:hide andShowProgress:show];
- if([self connectionCheck]){
- NSDictionary *dicParams = @{@"msisdn":(msisdn && [UiElementsUtils isNotEmpty:msisdn])?msisdn:@"",
- @"customerCode":(customerCode && [UiElementsUtils isNotEmpty:customerCode])?customerCode:@"",
- @"contractCode":(contractCode && [UiElementsUtils isNotEmpty:contractCode])?contractCode:@"",
- @"msisdnToRecharge":(msisdnToRecharge && [UiElementsUtils isNotEmpty:msisdnToRecharge])?msisdnToRecharge:@"",
- @"channel":(channel && [UiElementsUtils isNotEmpty:channel])?channel:@"",
- @"flagPP":(flagPP && [UiElementsUtils isNotEmpty:flagPP])?flagPP:@"",
- @"agreementId":(agreementId && [UiElementsUtils isNotEmpty:agreementId])?agreementId:@"",
- @"importo":(importo && [UiElementsUtils isNotEmpty:importo])?importo:@"",
- @"importoBonus":(importoBonus && [UiElementsUtils isNotEmpty:importoBonus])?importoBonus:@"",
- @"value":(value && [UiElementsUtils isNotEmpty:value])?value:@"",
- @"idPromo":(idPromo && [UiElementsUtils isNotEmpty:idPromo])?idPromo:@"",
- @"percentualeGA":(percentualeGA && [UiElementsUtils isNotEmpty:percentualeGA])?percentualeGA:@"",
- @"tagPromo":(tagPromo && [UiElementsUtils isNotEmpty:tagPromo])?tagPromo:@"",
- @"transactionID":(transactionID && [UiElementsUtils isNotEmpty:transactionID])?transactionID:@"",
- @"callID":(callID && [UiElementsUtils isNotEmpty:callID])?callID:@"",
- @"testoGA":(testoGA && [UiElementsUtils isNotEmpty:testoGA])?testoGA:@"",
- @"token":(token && [UiElementsUtils isNotEmpty:token])?token:@"",
- @"payerId":(payerId && [UiElementsUtils isNotEmpty:payerId])?payerId:@""};
- if([UiElementsUtils isNotEmpty:dicParams]){
- [[BackendInterface sharedBackendInterface] endPaypalRechargeNewWide:dicParams delegate:self];
- return;
- }
- ResponseModel *response = [[ResponseModel alloc]initWithDictionary:@{@"status":@(-999),@"reason":@""}];
- self.failure(response, EndPaypalRechargeNew);
- [self closeBlock];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement