IT虾米网

IOS实现微信支付流程

sanshao 2018年06月23日 手机开发 1112 0

1.注册微信开发账号,开通支付权限(注册谁都会了)


2.把三个文件拉进去

libWeChatSDK.a
WXApi.h
WXApiObject.h

3.添加URL Types



4.AppDelegate.m中添加微信账号

[WXApi registerApp:@"wxalsdfjalsfals" withDescription:@"tencent”];
回调
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    return  [WXApi handleOpenURL:url delegate:self];
}

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return  [WXApi handleOpenURL:url delegate:self];
}

- (void)onResp:(BaseResp *)resp {
    if ([resp isKindOfClass:[PayResp class]]) {
        PayResp *response = (PayResp *)resp;
        switch (response.errCode) {
            case WXSuccess:
                NSLog(@"suceess");
                break;
            default:
                NSLog(@"failed");
                break;
        }
    }
}

5.调用的文件

评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!