支付-微信支付(2)

236 阅读1分钟

1 微信支付2 ,参与后台接口:

-(void)textWeixin{
    // 1.拼接请求参数
    JYUserInfomation *info=[JYUserInfomation allObjects].firstObject;
    if (info==nil|| !info.isLoged) {
        return;
    }
    WeakSelf(weakSelf);
    NSDictionary *dic = @{
                        @"person_id":info.person_id,
                        @"orderId":self.listModel.id,
                        @"token":info.appkey,
                        @"version":AppVersion,
                        };
    
    [LOHttpHelper lo_requestWithType:LO_HttpRequestTypeGet withPath:@"app/pay/weixinPay.htm?" params:dic successOrFail:^(NSDictionary *responseDic, NSError *error) {
        if (!error) {
            if ([responseDic[@"status"] integerValue]==1) {
                NSLog(@"%@",responseDic);
                NSDictionary *dict=responseDic[@"data"];
                
                NSMutableString *retcode = [dict objectForKey:@"retcode"];
                if (retcode.intValue == 0){
                    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 );
                }
            }else{
                
                [KVNProgress showErrorWithStatus:responseDic[@"msg"]];
            }
            
        }else{
            [KVNProgress showErrorWithStatus:@"请重新再试!"];
        }
    }];
}
  • 拼接参数,掉后台接口,接受后台参数:

    微信支付2-1

  • 根据返回的参数,调用微信SDK,进行支付:

    微信支付2-2