zoukankan      html  css  js  c++  java
  • 微信支付回调

    1.在AppDelegate中设置微信代理

    @interface AppDelegate ()<WXApiDelegate>

    2.在openUrl中判断返回url   并设置代理

    - (BOOL)application:(UIApplication *)application

                openURL:(NSURL *)url

      sourceApplication:(NSString *)sourceApplication

            annotation:(id)annotation{

    ([[url scheme] isEqualToString:@"wx711e29e7c52bb3d9"]) {

            if ([url.host isEqualToString:@"pay"]) {

      [WXApi handleOpenURL:url delegate:self];

            }

    }

    3,调用代理方法

    - (void)onResp:(BaseResp *)resp {
        if ([resp isKindOfClass:[PayResp class]]) {
            PayResp *response = (PayResp *)resp;
            if (response.errCode == WXSuccess) {
                  NSLog(@"支付成功");
          
            }else{
               
                NSString *string = @"支付成功";
                [[NSNotificationCenter defaultCenter] postNotificationName:@"wxResult" object:string];
               
                  NSLog(@"支付失败, retcode=%d",resp.errCode);
            }
        }
    }
  • 相关阅读:
    17_8_30 Mybatis 入门
    17_8_29 mysql 导入导出备份还原
    [iOS基础控件
    [iOS基础控件
    [iOS基础控件
    [MAC OSX
    [iOS基础控件
    [iOS基础控件
    [iOS基础控件
    [iOS基础控件
  • 原文地址:https://www.cnblogs.com/gaojingxuan/p/4942793.html
Copyright © 2011-2022 走看看