微信支付
2016-07-06 17:22
681 查看
#pragma mark- 微信支付 - (void)bizPay:(NSDictionary *)dic { NSString *res = [self jumpToBizPay:dic]; if( ![@"" isEqual:res] ){ UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"支付失败" message:res delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alter show]; } } - (NSString *)jumpToBizPay:(NSDictionary *)dict { if(dict != nil){ NSMutableString *stamp = [dict objectForKey:@"timestamp"]; //调起微信支付 PayReq* req = [[PayReq alloc] init]; req.partnerId = [dict objectForKey:@"partnerid"]; req.prepayId = [dict objectForKey:@"prepayid"]; req.nonceStr = [dict objectForKey:@"noncestr"]; req.timeStamp = stamp.intValue; req.package = [dict objectForKey:@"package"]; req.sign = [dict objectForKey:@"sign"]; [WXApi sendReq:req]; //日志输出 NSLog(@"appid=%@\npartid=%@\nprepayid=%@\nnoncestr=%@\ntimestamp=%ld\npackage=%@\nsign=%@",[dict objectForKey:@"appid"],req.partnerId,req.prepayId,req.nonceStr,(long)req.timeStamp,req.package,req.sign ); return @""; }else{ return @"服务器返回错误,未获取到json对象"; } return @"服务器返回错误"; }
- (void)connect{ HUD_ = [[MyActivityView alloc] initWithSuperView:WINDOW title:HUD_TITLE]; [HUD_ show:YES]; NSString *tNumber = [NSString stringWithFormat:@"%@",[self.orderDictionary objectForKey:@"tNumber"]]; NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:tNumber,@"tradeId", nil]; //必须实现的两步------------------------ NSString *jsonString = [AsyConnecModel DataTOjsonString:dic]; NSDictionary *postDic = [AsyConnecModel setPostValue:jsonString]; //------------------------ //拼接接口地址 NSString *url = [NSString stringWithFormat:@"%@%@",ServerKey,AF_WXpay]; [AsyConnecModel asyncPostWithUrl:url strparmaters:postDic finishBlock:^(id response){ //接口返回值 NSLog(@"response : %@",response); if ([response isKindOfClass:[NSError class]]) { NSError *error = (NSError *)response; NSLog(@"%@",error.localizedDescription); UIView *view = WINDOW; [view makeToast:error.localizedDescription duration:TOAST_TIMER position:TOAST_CENTER]; [HUD_ hide]; return; } NSDictionary *dic = (NSDictionary *)response; if ([[dic objectForKey:@"result"] integerValue] == 1) { [HUD_ hide]; if (![Collect replaceNull:[[dic objectForKey:@"message"] objectForKey:@"prepayid"]].length) { UIView *view = WINDOW; [view makeToast:@"权鉴错误" duration:TOAST_TIMER position:TOAST_CENTER]; }else{ [self bizPay:[dic objectForKey:@"message"]]; } }else{ NSLog(ERROR_LOG); [HUD_ hide]; } }]; }
相关文章推荐
- 使用RadioButton+Fragment实现微信底部标签菜单
- 微信公众平台下Access Token的概念及获取方法
- 通过微信公众号ID生成公众号的二维码
- 微信公众帐号开发教程第4篇-消息及消息处理工具的封装
- 【转载】微信公众帐号开发教程第3篇-开发模式启用及接口配置
- 微信公众帐号开发教程第2篇-微信公众帐号的类型(普通和会议)
- 微信公众帐号开发教程第1篇-引言
- 微信企业号支付PHP实现分析
- 微信公众平台js-sdk对接页面和Action
- 微信公众平台获得jsApiTicket
- 微信获得accessToken
- 公众号开发关键字回复 该公众号暂时无法提供服务,请稍后再试
- 微信支付各种key的申请
- PHP通过微信跳转的Code参数获取用户的openid(关键代码)
- 微信支付之h5网页支付
- 微信redirecturi参数错误
- 微信支付接入指南
- 微信支付接入指南
- 微信支付接入指南
- 微信支付接入指南