Advertisement
Guest User

Untitled

a guest
Oct 26th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (void)readJsonResponeEndPPWide:(NSURLRequest *)request{
  2.     if(request && [request URL] && [[request URL] absoluteString] && [UiElementsUtils isNotEmpty:[[request URL] absoluteString]]){
  3.         if (![[FBNetworkReachability sharedInstance]reachable]) {
  4.             [[NSNotificationCenter defaultCenter] postNotificationName:kHideHUD object:nil];
  5.             [[NSNotificationCenter defaultCenter] postNotificationName:kConnectionLose object:nil];
  6.             return;
  7.         }
  8.         [[NSNotificationCenter defaultCenter] postNotificationName:kShowHUD object:nil];
  9.         NSString *tmpUrl = [[request URL] absoluteString];
  10.         if(tmpUrl && [UiElementsUtils isNotEmpty:tmpUrl]){
  11.             NSString *decodedText = [tmpUrl stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  12.             if(decodedText && [UiElementsUtils isNotEmpty:decodedText]){
  13.                 if([decodedText containsString:@"parameters="]){
  14.                    
  15.                     NSURLComponents *urlComponents = [NSURLComponents componentsWithURL:[request URL] resolvingAgainstBaseURL:NO];
  16.                     NSArray *queryItems = urlComponents.queryItems;
  17.                     if(queryItems && [UiElementsUtils isNotEmpty:queryItems]){
  18.                         NSString *paramTot = [UiElementsUtils valueForKey:@"parameters" fromQueryItems:queryItems];
  19.                         DDLogInfo(@"Parameters - %@",paramTot);
  20.                         if(paramTot && [UiElementsUtils isNotEmpty:paramTot]){
  21.                             if([paramTot containsString:@"%5B"]){
  22.                                 paramTot = [paramTot stringByReplacingOccurrencesOfString:@"%5B" withString:@"]"];
  23.                             }
  24.                             if([paramTot containsString:@"%5D"]){
  25.                                 paramTot = [paramTot stringByReplacingOccurrencesOfString:@"%5D" withString:@"]"];
  26.                             }
  27.                             if([paramTot containsString:@"]"] && [paramTot containsString:@"["]){
  28.                                 NSRange start = [paramTot rangeOfString:@"["];
  29.                                 NSRange end = [paramTot rangeOfString:@"]"];
  30.                                 NSString *shortString = [paramTot substringWithRange:NSMakeRange(start.location, end.location)];
  31.                                
  32.                                 if(shortString && [UiElementsUtils isNotEmpty:shortString]){
  33.                                    
  34.                                     shortString = [shortString stringByReplacingOccurrencesOfString:@"]" withString:@""];
  35.                                     shortString = [shortString stringByReplacingOccurrencesOfString:@"[" withString:@""];
  36.                                    
  37.                                     NSArray *splitParam = [shortString componentsSeparatedByString:@","];
  38.                                     if(splitParam && [UiElementsUtils isNotEmpty:splitParam]){
  39.                                         NSString *msisdn = @"";
  40.                                         NSString *customerCode = @"";
  41.                                         NSString *contractCode = @"";
  42.                                         NSString *msisdnToRecharge = @"";
  43.                                         NSString *flagPP = @"";
  44.                                         NSString *agreementId = @"";
  45.                                         NSString *channel = @"";
  46.                                         NSString *importo = @"";
  47.                                         NSString *importoBonus = @"";
  48.                                         NSString *value = @"";
  49.                                         NSString *idPromo = @"";
  50.                                         NSString *percentualeGA = @"";
  51.                                         NSString *tagPromo = @"";
  52.                                         NSString *transactionID = @"";
  53.                                         NSString *callID = @"";
  54.                                         NSString *testoGA = @"";
  55.                                        
  56.                                         for(int i=0; i<[splitParam count];i++){
  57.                                             NSString *str = splitParam[i];
  58.                                             if(str && [UiElementsUtils isNotEmpty:str]){
  59.                                                 if([str containsString:@"'"]){
  60.                                                     str = [str stringByReplacingOccurrencesOfString:@"'" withString:@""];
  61.                                                 }
  62.                                             }
  63.                                            
  64.                                            
  65.                                             if(i==0){
  66.                                                 msisdn = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  67.                                             }else if(i==1){
  68.                                                 customerCode = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  69.                                             }else if(i==2){
  70.                                                 contractCode = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  71.                                             }else if(i==3){
  72.                                                 msisdnToRecharge = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  73.                                             }else if(i==4){
  74.                                                 flagPP = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  75.                                             }else if(i==5){
  76.                                                 agreementId = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  77.                                             }else if(i==6){
  78.                                                 channel = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  79.                                             }else if(i==7){
  80.                                                 importo = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  81.                                             }else if(i==8){
  82.                                                 importoBonus = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  83.                                             }else if(i==9){
  84.                                                 value = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  85.                                             }else if(i==10){
  86.                                                 idPromo = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  87.                                             }else if(i==11){
  88.                                                 percentualeGA = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  89.                                             }else if(i==12){
  90.                                                 tagPromo = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  91.                                             }else if(i==13){
  92.                                                 transactionID = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  93.                                             }else if(i==14){
  94.                                                 callID = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  95.                                             }else if(i==15){
  96.                                                 testoGA = (str && [UiElementsUtils isNotEmpty:str])?[str copy]:@"";
  97.                                             }else{
  98.                                                 //NOP
  99.                                             }
  100.                                         }
  101.                                        
  102.                                         NSString *token = @"";
  103.                                         NSString *payerId = @"";
  104.                                        
  105.                                         NSString *paramToken = [UiElementsUtils valueForKey:@"token" fromQueryItems:queryItems];
  106.                                         DDLogInfo(@"Token - %@", paramToken);
  107.                                         if(paramToken && [UiElementsUtils isNotEmpty:paramToken]){
  108.                                             token = [paramToken copy];
  109.                                         }
  110.                                         NSString *paramPayerID = [UiElementsUtils valueForKey:@"PayerID" fromQueryItems:queryItems];
  111.                                         DDLogInfo(@"PayerID - %@", paramPayerID);
  112.                                         if(paramPayerID && [UiElementsUtils isNotEmpty:paramPayerID]){
  113.                                             payerId = [paramPayerID copy];
  114.                                         }
  115.                                        
  116.                                        
  117.                                        
  118.                                         __typeof(self) __weak weakSelf = self;
  119.                                         [[WLBlocks sharedManager] endPaypalRechargeNewWideWithMsisdn:msisdn
  120.                                                                                   andCustomerCode:customerCode
  121.                                                                                   andContractCode:contractCode
  122.                                                                               andMsisdnToRecharge:msisdnToRecharge
  123.                                                                                            andFlagPP:flagPP
  124.                                                                                    andAgreementId:agreementId
  125.                                                                                        andImporto:importo
  126.                                                                                   andImportoBonus:importoBonus
  127.                                                                                          andValue:value
  128.                                                                                        andIdPromo:idPromo
  129.                                                                                  andPercentualeGA:percentualeGA
  130.                                                                                       andTagPromo:tagPromo
  131.                                                                                  andTransactionID:transactionID
  132.                                                                                            andCallID:callID
  133.                                                                                        andTestoGA:testoGA
  134.                                                                                        andChannel:channel
  135.                                                                                             andToken:token
  136.                                                                                           andPayerId:payerId
  137.                                                                      andShowProgressBeforeProcess:NO
  138.                                                                       andHideProgressAfterProcess:NO
  139.                                                                                           success:^(id data, NSString *request) {
  140.                                                                                               weakSelf.statoPagamento = failure;
  141.                                                                                               if(request && data && [request isEqualToString:EndPaypalRechargeNew] && [data isKindOfClass:[NSDictionary class]]){
  142.                                                                                                   NSDictionary *responseDic = (NSDictionary *)data;
  143.                                                                                                   if(responseDic && [UiElementsUtils isNotEmpty:responseDic]){
  144.                                                                                                       RechargeResponseNewObj *ppObj = [weakSelf managerResponse:responseDic];
  145.                                                                                                       if(ppObj){
  146.                                                                                                           if([ppObj transactionId] && [UiElementsUtils isNotEmpty:[ppObj transactionId]]){
  147.                                                                                                               weakSelf.statoPagamento = success;
  148.                                                                                                               [ppObj setStatus:@0];
  149.                                                                                                               [weakSelf goToNextStepWide:ppObj];
  150.                                                                                                           }else{
  151.                                                                                                               [weakSelf goToNextStepWide:ppObj];
  152.                                                                                                           }
  153.                                                                                                           return;
  154.                                                                                                       }
  155.                                                                                                   }
  156.                                                                                               }
  157.                                                                                               [weakSelf goToNextStepWide:[weakSelf defaultResponse]];
  158.                                                                                           }failure:^(ResponseModel *response, NSString *request) {
  159.                                                                                               weakSelf.statoPagamento = failure;
  160.                                                                                               [weakSelf goToNextStepWide:[weakSelf defaultResponse]];
  161.                                                                                           }failureFull:^(ResponseModel *response, id data, NSString *request) {
  162.                                                                                               weakSelf.statoPagamento = failure;
  163.                                                                                               if(request && data && [request isEqualToString:EndPaypalRechargeNew] && [data isKindOfClass:[NSDictionary class]]){
  164.                                                                                                   NSDictionary *responseDic = (NSDictionary *)data;
  165.                                                                                                   if(responseDic && [UiElementsUtils isNotEmpty:responseDic]){
  166.                                                                                                       RechargeResponseNewObj *ppObj = [weakSelf managerResponse:responseDic];
  167.                                                                                                       if(ppObj){
  168.                                                                                                           [weakSelf goToNextStepWide:ppObj];
  169.                                                                                                           return;
  170.                                                                                                       }
  171.                                                                                                   }
  172.                                                                                               }
  173.                                                                                               [weakSelf goToNextStepWide:[weakSelf defaultResponse]];
  174.                                                                                           }connectionError:^{ }];
  175.                                         return;
  176.                                     }
  177.                                 }
  178.                             }
  179.                         }
  180.                     }
  181.                 }
  182.             }
  183.         }
  184.     }
  185.     _statoPagamento = failure;
  186.     [self goToNextStepWide:[self defaultResponse]];
  187. }
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214. -(void)endPaypalRechargeNewWideWithMsisdn:(NSString *)msisdn
  215.                           andCustomerCode:(NSString *)customerCode
  216.                           andContractCode:(NSString *)contractCode
  217.                       andMsisdnToRecharge:(NSString *)msisdnToRecharge
  218.                                 andFlagPP:(NSString *)flagPP
  219.                            andAgreementId:(NSString *)agreementId
  220.                                andImporto:(NSString *)importo
  221.                           andImportoBonus:(NSString *)importoBonus
  222.                                  andValue:(NSString *)value
  223.                                andIdPromo:(NSString *)idPromo
  224.                          andPercentualeGA:(NSString *)percentualeGA
  225.                               andTagPromo:(NSString *)tagPromo
  226.                          andTransactionID:(NSString *)transactionID
  227.                                 andCallID:(NSString *)callID
  228.                                andTestoGA:(NSString *)testoGA
  229.                                andChannel:(NSString *)channel
  230.                                  andToken:(NSString *)token
  231.                                andPayerId:(NSString *)payerId
  232.              andShowProgressBeforeProcess:(BOOL)show
  233.               andHideProgressAfterProcess:(BOOL)hide
  234.                                   success:(void (^)(id data, NSString *request))success
  235.                                   failure:(void (^)(ResponseModel *response, NSString *request))failure
  236.                               failureFull:(void (^)(ResponseModel *response, id data, NSString *request))failureFull
  237.                           connectionError:(void (^)())connectionError{
  238.    
  239.     [self loadBlockWithSuccess:success failure:failure
  240.                    failureFull:failureFull connectionError:connectionError
  241.                andHideProgress:hide andShowProgress:show];
  242.    
  243.     if([self connectionCheck]){
  244.         NSDictionary *dicParams = @{@"msisdn":(msisdn && [UiElementsUtils isNotEmpty:msisdn])?msisdn:@"",
  245.                                     @"customerCode":(customerCode && [UiElementsUtils isNotEmpty:customerCode])?customerCode:@"",
  246.                                     @"contractCode":(contractCode && [UiElementsUtils isNotEmpty:contractCode])?contractCode:@"",
  247.                                     @"msisdnToRecharge":(msisdnToRecharge && [UiElementsUtils isNotEmpty:msisdnToRecharge])?msisdnToRecharge:@"",
  248.                                     @"channel":(channel && [UiElementsUtils isNotEmpty:channel])?channel:@"",
  249.                                     @"flagPP":(flagPP && [UiElementsUtils isNotEmpty:flagPP])?flagPP:@"",
  250.                                     @"agreementId":(agreementId && [UiElementsUtils isNotEmpty:agreementId])?agreementId:@"",
  251.                                     @"importo":(importo && [UiElementsUtils isNotEmpty:importo])?importo:@"",
  252.                                     @"importoBonus":(importoBonus && [UiElementsUtils isNotEmpty:importoBonus])?importoBonus:@"",
  253.                                     @"value":(value && [UiElementsUtils isNotEmpty:value])?value:@"",
  254.                                     @"idPromo":(idPromo && [UiElementsUtils isNotEmpty:idPromo])?idPromo:@"",
  255.                                     @"percentualeGA":(percentualeGA && [UiElementsUtils isNotEmpty:percentualeGA])?percentualeGA:@"",
  256.                                     @"tagPromo":(tagPromo && [UiElementsUtils isNotEmpty:tagPromo])?tagPromo:@"",
  257.                                     @"transactionID":(transactionID && [UiElementsUtils isNotEmpty:transactionID])?transactionID:@"",
  258.                                     @"callID":(callID && [UiElementsUtils isNotEmpty:callID])?callID:@"",
  259.                                     @"testoGA":(testoGA && [UiElementsUtils isNotEmpty:testoGA])?testoGA:@"",
  260.                                     @"token":(token && [UiElementsUtils isNotEmpty:token])?token:@"",
  261.                                     @"payerId":(payerId && [UiElementsUtils isNotEmpty:payerId])?payerId:@""};
  262.         if([UiElementsUtils isNotEmpty:dicParams]){
  263.             [[BackendInterface sharedBackendInterface] endPaypalRechargeNewWide:dicParams delegate:self];
  264.             return;
  265.         }
  266.         ResponseModel *response = [[ResponseModel alloc]initWithDictionary:@{@"status":@(-999),@"reason":@""}];
  267.         self.failure(response, EndPaypalRechargeNew);
  268.         [self closeBlock];
  269.     }
  270. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement