微信支付回調(diào)

微信支付回調(diào)是在appdelegate里面
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)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"]){
        // 支付跳轉(zhuǎn)支付寶錢包進(jìn)行支付,處理支付結(jié)果
        NSLog(@"%@",url);
        [[AlipaySDK defaultService] processOrderWithPaymentResult:url standbyCallback:^(NSDictionary *resultDic) {
            NSLog(@"支付返回結(jié)果result = %@",resultDic);//該回調(diào)是用于非錢包跳轉(zhuǎn)
        }];
         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=@"普通類型錯(cuò)誤";
            [self paydetail:memo];
        }
            break;
        case WXErrCodeUserCancel:{
            memo=@"用戶支付中途取消";
            [self paydetail:memo];
        }
            break;
        case WXErrCodeSentFail:{
             memo=@"發(fā)送訂單失敗";
            [self paydetail:memo];
        }
            break;
        case WXErrCodeAuthDeny :{
             memo=@"授權(quán)失敗";
            [self paydetail:memo];
        }
            break;
        case WXErrCodeUnsupport:{
             memo=@"微信不支持";
            [self paydetail:memo];
        }
            break;
        default:
            break;
    }
    
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容