update 微信登录和微信支付的功能
parent
5602bbfd82
commit
b38cb30e94
|
@ -172,7 +172,7 @@
|
|||
9DD565B623EC45080011FC4A /* Frameworks */,
|
||||
9DD565B723EC45080011FC4A /* Resources */,
|
||||
DFB054DF507DE3B18CCCE932 /* [CP] Embed Pods Frameworks */,
|
||||
33C306F0B0B6C469FD078FB0 /* [CP] Copy Pods Resources */,
|
||||
11B173FBB433EBB6C00BA0E7 /* [CP] Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
@ -231,7 +231,7 @@
|
|||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
33C306F0B0B6C469FD078FB0 /* [CP] Copy Pods Resources */ = {
|
||||
11B173FBB433EBB6C00BA0E7 /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
|
|
|
@ -46,7 +46,8 @@
|
|||
|
||||
FATConfig *config = [FATConfig configWithStoreConfigs:configs];
|
||||
[[FATClient sharedClient] initWithConfig:config error:nil];
|
||||
[[FATClient sharedClient] setEnableLog:YES];
|
||||
// 设置Log日志
|
||||
[[FATClient sharedClient].logManager initLogWithLogDir:nil logLevel:FATLogLevelVerbose consoleLog:YES];
|
||||
|
||||
[FATClient sharedClient].delegate = [FINDemoClientHelper sharedHelper];
|
||||
// 注入自定义api
|
||||
|
@ -57,10 +58,8 @@
|
|||
// // 注册高德地图
|
||||
// [FATGDMapComponent setGDMapAppKey:@"申请的key"];
|
||||
|
||||
if ([bundleId isEqualToString:@"com.finogeeks.mop.finosprite"]) {
|
||||
// 该appID【wx85663af68a0cbbc8】绑定的应用为凡泰助手,若要生效,请修改BundleID为com.finogeeks.mop.finosprite
|
||||
[WXApi registerApp:@"wx85663af68a0cbbc8" universalLink:@"https://www.finclip.com/finosprite/"];
|
||||
}
|
||||
// 注册微信SDK
|
||||
// [WXApi registerApp:@"微信开放sdk的key" universalLink:@"微信开放sdk的universalLink"];
|
||||
|
||||
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
self.window.backgroundColor = [UIColor whiteColor];
|
||||
|
|
|
@ -85,14 +85,19 @@ static FINExtensionHelper *instance = nil;
|
|||
// 注入微信支付方法
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[[FATClient sharedClient] registerExtensionApi:@"requestPayment" handler:^(FATAppletInfo *appletInfo, id param, FATExtensionApiCallback callback) {
|
||||
// 支付调用,调用结果通过回调通告小程序
|
||||
// 支付有两种方式实现:
|
||||
// 1.利用app实现支付,结果通过回调通告小程序
|
||||
[weakSelf getTestPayment:callback];
|
||||
|
||||
// 2.使用微信小程序实现支付
|
||||
// [weakSelf wechatMiniProgramPayment:appletInfo param:param callback:callback];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - WXPay
|
||||
// 模拟向服务请求支付订单
|
||||
- (void)getTestPayment:(FATExtensionApiCallback)callback {
|
||||
// 以下支持示例代码,演示自行实现的过程
|
||||
NSString *urlString = @"https://finclip-testing.finogeeks.club/mop/wechat-auth/api/order";
|
||||
NSURL *url = [NSURL URLWithString:urlString];
|
||||
NSMutableURLRequest *requset = [NSMutableURLRequest requestWithURL:url];
|
||||
|
@ -132,6 +137,42 @@ static FINExtensionHelper *instance = nil;
|
|||
[task resume];
|
||||
}
|
||||
|
||||
- (void)wechatMiniProgramPayment:(FATAppletInfo *)appletInfo
|
||||
param:(NSDictionary *)param
|
||||
callback:(FATExtensionApiCallback)callback
|
||||
{
|
||||
NSDictionary *info = appletInfo.wechatLoginInfo;
|
||||
NSString *wxid = appletInfo.wechatLoginInfo[@"wechatOriginId"];
|
||||
NSString *path = appletInfo.wechatLoginInfo[@"paymentUrl"];
|
||||
if (wxid.length == 0 || path.length == 0) {
|
||||
callback(FATExtensionCodeFailure, @{@"desc":@"微信小程序关联信息异常"});
|
||||
return;
|
||||
}
|
||||
|
||||
NSDictionary *dataDic = param;
|
||||
NSString *payString = [NSString stringWithFormat:@"?appId=%@&nonceStr=%@&package=%@&paySign=%@&signType=%@&timeStamp=%@&type=%@", dataDic[@"appId"], dataDic[@"nonceStr"], dataDic[@"package"], dataDic[@"paySign"], dataDic[@"signType"], dataDic[@"timeStamp"], dataDic[@"type"]];
|
||||
|
||||
// 需要appDelegate 里注册微信开放SDK。
|
||||
WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
|
||||
launchMiniProgramReq.userName = wxid;
|
||||
launchMiniProgramReq.path = [NSString stringWithFormat:@"%@%@", wxid, payString];
|
||||
if (appletInfo.appletVersionType == FATAppletVersionTypeRelease) {
|
||||
launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //正式版
|
||||
} else if (appletInfo.appletVersionType == FATAppletVersionTypeTrial) {
|
||||
launchMiniProgramReq.miniProgramType = WXMiniProgramTypePreview; //体验版
|
||||
} else {
|
||||
launchMiniProgramReq.miniProgramType = WXMiniProgramTypeTest; //开发版
|
||||
}
|
||||
[WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
|
||||
NSLog(@"打开微信:%d", success);
|
||||
if (success) {
|
||||
callback(FATExtensionCodeSuccess, @{@"desc":@"支付成功"});
|
||||
return;
|
||||
}
|
||||
callback(FATExtensionCodeFailure, @{@"desc":@"支付失败"});
|
||||
}];
|
||||
}
|
||||
|
||||
// 签名加密(正常是放在后台处理,由上面的请求接口返回
|
||||
- (NSString *)sha256:(NSString *)shaStr {
|
||||
NSData *data = [shaStr dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
|
|
@ -137,7 +137,7 @@
|
|||
[[FATClient sharedClient] startAppletWithRequest:request InParentViewController:self completion:^(BOOL result, FATError *error) {
|
||||
|
||||
} closeCompletion:^{
|
||||
|
||||
[[FATClient sharedClient] clearMemoryCache];
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<array>
|
||||
<dict>
|
||||
<key>appId</key>
|
||||
<string>60d58080a2b11b0001c439a4</string>
|
||||
<key>title</key>
|
||||
<string>小程序微信登录&支付示例</string>
|
||||
<key>startParams</key>
|
||||
<dict/>
|
||||
</dict>
|
||||
</array>
|
||||
</plist>
|
Loading…
Reference in New Issue