银联支付 支付代码
_rowSelect = 2 银联支付 下方是所有的支付代码
#pragma mark 第三支付 - (void)postUpload { NSString *channel; switch (_rowSelect) { case 0: channel = @"wx"; self.channel = channel; break; case 1: channel = @"alipay"; self.channel = channel; break; case 2: channel = @"upacp"; self.channel = channel; break; case 3: { channel = @"supervip"; self.channel = channel; [self issetpaypwdApiWith:0]; return; } break; default: break; } // 1. url - 负责上传的脚本 NSString *urlStr = [NSString stringWithFormat:@"%@soonpay/payForOrder.json",BASE_MALL_URL]; NSURL *url = [NSURL URLWithString:urlStr]; // 2. request NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; int price = round(_amount*100); // 3. 上传文件的参数 NSDictionary *dict; if ([channel isEqualToString:@"supervip"]) { dict = @{@"order_no":_orderNo, @"amount":@(price), @"channel":channel, @"cardNum":self.accountInfo.cardNum}; } else { dict = @{@"order_no":_orderNo, @"amount":@(price), @"channel":channel}; } [SoonProgressHUD show]; NSData* data = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:nil]; NSString *bodyData = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; [request setHTTPBody:[NSData dataWithBytes:[bodyData UTF8String] length:strlen([bodyData UTF8String])]]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; NSOperationQueue *queue = [[NSOperationQueue alloc] init]; [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response2, NSData *data, NSError *connectionError) { dispatch_async(dispatch_get_main_queue(), ^{ [SoonProgressHUD dismiss]; }); NSLog(@"%@", [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL]); id responseObject = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL]; NSString *msg = responseObject[@"msg"]; if (msg.length>0) { dispatch_async(dispatch_get_main_queue(), ^{ [[TKAlertCenter shareInstance] postAlertWithMessage:msg]; [_footerView setButtonStatus:TRUE]; }); return; } PayInfo *payInfo; // if (_rowSelect!=0) { payInfo = [PayInfo objectWithKeyValues:responseObject]; // } if (_notSupportSoonPay == 0) { switch (_rowSelect) { case 3: break; case 0: { Wechat *wechat = payInfo.credential.wx; //调起微信支付 PayReq* req = [[PayReq alloc] init]; req.openID = wechat.appId; req.partnerId = wechat.partnerId; req.prepayId = wechat.prepayId; req.nonceStr = wechat.nonceStr; req.timeStamp = [wechat.timeStamp intValue]; req.package = wechat.packageValue; req.sign = wechat.sign; [WXApi sendReq:req]; } break; case 1: { [[AlipaySDK defaultService] payOrder:payInfo.credential.alipay.orderInfo fromScheme:@"O2O" callback:^(NSDictionary *resultDic) { DLog(@"resultDic = %@", resultDic); int resultStatus = [resultDic[@"resultStatus"] intValue]; if (resultStatus==9000) { _isSuccess = 1; }else { _isSuccess = 0; } [self pingSuccessOrFail]; }]; } break; case 2: { Upacp *upacp = payInfo.credential.upacp; NSString *mode = upacp.mode; NSString *tn = upacp.tn; [UPPayPlugin startPay:tn mode:mode viewController:self delegate:self]; } break; default: break; } } else { switch (_rowSelect) { case 0: { Wechat *wechat = payInfo.credential.wx; //调起微信支付 PayReq* req = [[PayReq alloc] init]; req.openID = wechat.appId; req.partnerId = wechat.partnerId; req.prepayId = wechat.prepayId; req.nonceStr = wechat.nonceStr; req.timeStamp = [wechat.timeStamp intValue]; req.package = wechat.packageValue; req.sign = wechat.sign; [WXApi sendReq:req]; } break; case 1: { [[AlipaySDK defaultService] payOrder:payInfo.credential.alipay.orderInfo fromScheme:@"O2O" callback:^(NSDictionary *resultDic) { DLog(@"resultDic = %@", resultDic); int resultStatus = [resultDic[@"resultStatus"] intValue]; if (resultStatus==9000) { _isSuccess = 1; }else { _isSuccess = 0; } [self pingSuccessOrFail]; }]; } break; case 2: { Upacp *upacp = payInfo.credential.upacp; NSString *mode = upacp.mode; NSString *tn = upacp.tn; [UPPayPlugin startPay:tn mode:mode viewController:self delegate:self]; } break; default: break; } } }]; }