最近项目中频繁需要支付,每次做的时候都因为没有做笔记而再次花时间去看文档,所以现在还是记录下来
1.按照开发文档配置工程:
2.注册:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//向微信注册 Wxappid为微信APPID
[WXApi registerApp:Wxappid];
[manger postpayinfogetPayInfoWithtype:type orderid:orderid serverType:serverType userid:userid timestamp:timestamp sign:sign success:^(ResponseModel *responseModel) {
if (!responseModel) {
return;
}
if (![responseModel.data isKindOfClass:[NSDictionary class]]) {
return;
}
NSDictionary *data = responseModel.data;
//调起微信支付
PayReq* req = [[PayReq alloc] init];
req.partnerId = [data objectForKey:@"partnerid"];
req.prepayId = [data objectForKey:@"prepayid"];
req.nonceStr = [data objectForKey:@"noncestr"];
NSMutableString *stamp = [data objectForKey:@"timestamp"];
req.timeStamp = stamp.intValue;
req.package = [data objectForKey:@"package"];
req.sign = [data objectForKey:@"sign"];
[WXApi sendReq:req];
} failure:^(NSError *error) {
}];