JMThirdPayHelper(微信、支付宝支付)

配置

JMThirdPayHelper.m顶部,配置支付宝、微信的key。
支付宝自定义字符串,保证唯一性即可,建议使用bundle identity。
微信是需要到微信开发后台申请的,将申请到的key设置到这里就好。

配置key

添加URL


配置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];
                }
            }];
        }
    }];

你可能感兴趣的:(JMThirdPayHelper(微信、支付宝支付))