微信支付

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

可参考了网友幻想无极的博客:http://www.cnblogs.com/hxwj/p/4563351.html

1. 引入文档

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

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

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

1.libsqlite3.0

2.libz

3.libc++

微信支付_第1张图片微信支付_第2张图片

 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网络异常");
      }];
}

 微信支付_第3张图片

你可能感兴趣的:(微信)