配置
在JMThirdPayHelper.m
顶部,配置支付宝、微信的key。
支付宝自定义字符串,保证唯一性即可,建议使用bundle identity。
微信是需要到微信开发后台申请的,将申请到的key设置到这里就好。
添加URL
info.plist中添加白名单
使用步骤
1、在AppDelegate的didFinishLaunchingWithOptions
中注册
[[JMThirdPayHelper sharedJMThirdPayHelper] start];
2、在AppDelegate的openURL
中响应回调
[[JMThirdPayHelper sharedJMThirdPayHelper] handleOpenURL:url];
3、支付的地方调用(调用后台的接口获取订单信息)
NSMutableDictionary *params = [JMCommonMethod baseRequestParams];
[params setJsonValue:self.orderNo key:@"orderNo"];
[params setJsonValue:requestType key:@"payType"];
[[JMRequestManager sharedManager] POST:kUrlPay parameters:params completion:^(JMBaseResponse *response) {
if(response.error){
[JMProgressHelper toastInWindowWithMessage:response.errorMsg];
}else{
NSString *payInfo = response.responseObject[@"data"][@"pay_info"];
[[JMThirdPayHelper sharedJMThirdPayHelper] paymentWithData:[payInfo mj_JSONObject] type:type completionBlock:^(BOOL success) {
if(success){
[self goSuccessVC];
}else{
[self goFailVC];
}
}];
}
}];