IOS实现微信支付流程
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;
}
}
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;
}
}
}