update 微信登录和微信支付的功能

master
wanghualei 2023-03-07 14:04:48 +08:00
parent 5602bbfd82
commit b38cb30e94
5 changed files with 49 additions and 23 deletions

View File

@ -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 = (

View File

@ -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"]) {
// appIDwx85663af68a0cbbc8BundleIDcom.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];

View File

@ -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];

View File

@ -137,7 +137,7 @@
[[FATClient sharedClient] startAppletWithRequest:request InParentViewController:self completion:^(BOOL result, FATError *error) {
} closeCompletion:^{
[[FATClient sharedClient] clearMemoryCache];
}];
}

View File

@ -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>&amp;</string>
<key>startParams</key>
<dict/>
</dict>
</array>
</plist>