微信支付回调

微信支付回调是在appdelegate里面
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options {
    
    BOOL result = [[UMSocialManager defaultManager] handleOpenURL:url];
    if ([options[UIApplicationOpenURLOptionsSourceApplicationKey] isEqualToString:@"com.tencent.xin"] && [url.absoluteString containsString:@"pay"]) {
        
        return [WXApi handleOpenURL:url delegate:self];
        
    }else if ([url.host isEqualToString:@"safepay"]){
        // 支付跳转支付宝钱包进行支付,处理支付结果
        NSLog(@"%@",url);
        [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
            NSLog(@"支付返回结果result = %@",resultDic);//该回调是用于非钱包跳转
        }];
         return  YES;
    }
    else{
            return result;
    }
}
-(void)onResp:(BaseResp*)resp{
    
    PayResp * response=(PayResp*)resp;

    NSLog(@"%d",response.errCode);
    [[NSNotificationCenter defaultCenter] postNotificationName:@"weixinpay" object:nil userInfo:@{@"resultcode":@(response.errCode)}];
    
}
- (void)weixinpay:(NSNotification *)notific{
    
    NSLog(@"%d",[notific.userInfo[@"resultcode"] intValue]);
    [self.navigationController popViewControllerAnimated:YES];
    NSString* memo;
    switch ([notific.userInfo[@"resultcode"] intValue]) {
            
        case WXSuccess :{
            memo=@"支付成功";
            OrderPayStateController* ovc=[[OrderPayStateController alloc]initWithname:self.consignee withaddressage:[NSString stringWithFormat:@"收货地址:%@%@%@%@",self.defaultInfo.province,self.defaultInfo.city,self.defaultInfo.district,self.defaultInfo.address] withphone:self.mobile withPrice:self.allgoodprices];
            ovc.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:ovc animated:YES];
        }
            break;
        case WXErrCodeCommon:{
            memo=@"普通类型错误";
            [self paydetail:memo];
        }
            break;
        case WXErrCodeUserCancel:{
            memo=@"用户支付中途取消";
            [self paydetail:memo];
        }
            break;
        case WXErrCodeSentFail:{
             memo=@"发送订单失败";
            [self paydetail:memo];
        }
            break;
        case WXErrCodeAuthDeny :{
             memo=@"授权失败";
            [self paydetail:memo];
        }
            break;
        case WXErrCodeUnsupport:{
             memo=@"微信不支持";
            [self paydetail:memo];
        }
            break;
        default:
            break;
    }
    
}

你可能感兴趣的:(微信支付回调)