码迷,mamicode.com
首页 > 微信 > 详细

微信支付

时间:2015-07-14 17:49:00      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:

微信支付官方文档有点坑,要引入的库也没说明白, fuck,没有支付宝的详细,而且回调也没支付宝的完美,下面是把官方文档没写明的记了一下

1. 引入文档

技术分享

2.设置URL Schemes,官方文档有不用说明

3.在AppDeledate中注册,以及响应文档也有

4.按照文档说的加入之后还是报错,原理是没引入类库

1.libsqlite3.0

2.libz

3.libc++

技术分享技术分享

 https://pay.weixin.qq.com/wxzf_guide/detail_app.shtml?back=index 微信支付SDK还好找,支付宝就比较难

- (void)requestWechatPay:(NSString *)orderId
{
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager shareManager];
    
    NSMutableDictionary *parameters = [[NSMutableDictionary alloc] initWithDictionary:[CommonParameters getCommonParameters]];
    
    [parameters setObject:orderId forKey:@"orderId"];
    [parameters addSignatureKey];
    
    [manager GET:API_EC_PAY_WECHAT_POINFO
      parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
          
           if ([NetWorkReturnHelper NetCompatibleErrorCode:responseObject]) {
              NSDictionary *dict = [responseObject objectForKey:@"data"];
              
              NSMutableString *stamp  = [dict objectForKey:@"timestamp"];
              
              //调起微信支付
              PayReq* req             = [[PayReq alloc] init];
              req.openID              = [dict objectForKey:@"appid"];
              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"];
              BOOL flag = [WXApi sendReq:req];
              //日志输出
              NSLog(@"appid=%@\npartid=%@\nprepayid=%@\nnoncestr=%@\ntimestamp=%ld\npackage=%@\nsign=%@",req.openID,req.partnerId,req.prepayId,req.nonceStr,(long)req.timeStamp,req.package,req.sign );
              
              if (flag) {
                  NSLog(@"send succeed");
              }else{
                  NSLog(@"send failed");
              }
          } else {
              NSLog(@"获取微信支付订单信息失败");
          }
      } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          XQBLog(@"微信预支付Id网络异常");
      }];
}

 

微信支付

标签:

原文地址:http://www.cnblogs.com/cuiyw/p/4645698.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!