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);
            }
        }
    }
  • 相关阅读:
    Atos cannot get symbols from dSYM of archived application
    iOS 中捕获程序崩溃日志 (2014-04-22 17:35:59)
    mysql创建索引
    maven整理项目spring配置文件加载问题
    js继承
    创建对象的方式
    js闭包
    js两种创建对象方式
    shiro-web整合
    shiro连接数据库
  • 原文地址:https://www.cnblogs.com/gaojingxuan/p/4942793.html
Copyright © 2011-2022 走看看