Unverified 提交 799384d7 authored 作者: JarvanMo's avatar JarvanMo 提交者: GitHub

Merge pull request #249 from aaassseee/dev

added wechat pay hk by WXOpenBusinessWebview
...@@ -53,6 +53,7 @@ public class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { ...@@ -53,6 +53,7 @@ public class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
call.method == "authByQRCode" -> authHandler?.authByQRCode(call, result) call.method == "authByQRCode" -> authHandler?.authByQRCode(call, result)
call.method == "stopAuthByQRCode" -> authHandler?.stopAuthByQRCode(result) call.method == "stopAuthByQRCode" -> authHandler?.stopAuthByQRCode(result)
call.method == "payWithFluwx" -> pay(call, result) call.method == "payWithFluwx" -> pay(call, result)
call.method == "payWithHongKongWallet" -> payWithHongKongWallet(call, result)
call.method == "launchMiniProgram" -> launchMiniProgram(call, result) call.method == "launchMiniProgram" -> launchMiniProgram(call, result)
call.method == "subscribeMsg" -> subScribeMsg(call, result) call.method == "subscribeMsg" -> subScribeMsg(call, result)
call.method == "autoDeduct" -> signAutoDeduct(call, result) call.method == "autoDeduct" -> signAutoDeduct(call, result)
...@@ -108,6 +109,16 @@ public class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { ...@@ -108,6 +109,16 @@ public class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
} }
} }
private fun payWithHongKongWallet(call: MethodCall, result: MethodChannel.Result) {
val prepayId = call.argument<String>("prepayId") ?: ""
val request = WXOpenBusinessWebview.Req()
request.businessType = 1
request.queryInfo = hashMapOf(
"token" to prepayId
)
result.success(WXAPiHandler.wxApi?.sendReq(request))
}
private fun signAutoDeduct(call: MethodCall, result: Result) { private fun signAutoDeduct(call: MethodCall, result: Result) {
val appId: String = call.argument<String>("appid") ?: "" val appId: String = call.argument<String>("appid") ?: ""
val mchId = call.argument<String>("mch_id") ?: "" val mchId = call.argument<String>("mch_id") ?: ""
......
...@@ -121,6 +121,6 @@ object FluwxResponseHandler { ...@@ -121,6 +121,6 @@ object FluwxResponseHandler {
openId to response.openId, openId to response.openId,
type to response.type) type to response.type)
channel?.invokeMethod("onAutoDeductResponse", result) channel?.invokeMethod("onWXOpenBusinessWebviewResponse", result)
} }
} }
\ No newline at end of file
...@@ -46,6 +46,8 @@ BOOL handleOpenURLByFluwx = YES; ...@@ -46,6 +46,8 @@ BOOL handleOpenURLByFluwx = YES;
result(@([WXApi openWXApp])); result(@([WXApi openWXApp]));
} else if ([@"payWithFluwx" isEqualToString:call.method]) { } else if ([@"payWithFluwx" isEqualToString:call.method]) {
[self handlePayment:call result:result]; [self handlePayment:call result:result];
} else if ([@"payWithHongKongWallet" isEqualToString:call.method]) {
[self handleHongKongWalletPayment:call result:result];
} else if ([@"launchMiniProgram" isEqualToString:call.method]) { } else if ([@"launchMiniProgram" isEqualToString:call.method]) {
[self handleLaunchMiniProgram:call result:result]; [self handleLaunchMiniProgram:call result:result];
} else if ([@"subscribeMsg" isEqualToString:call.method]) { } else if ([@"subscribeMsg" isEqualToString:call.method]) {
...@@ -109,6 +111,19 @@ BOOL handleOpenURLByFluwx = YES; ...@@ -109,6 +111,19 @@ BOOL handleOpenURLByFluwx = YES;
}]; }];
} }
- (void)handleHongKongWalletPayment:(FlutterMethodCall *)call result:(FlutterResult)result {
NSString *partnerId = call.arguments[@"prepayId"];
WXOpenBusinessWebViewReq *req = [[WXOpenBusinessWebViewReq alloc] init];
req.businessType = 1;
NSMutableDictionary *queryInfoDic = [NSMutableDictionary dictionary];
[queryInfoDic setObject:partnerId forKey:@"token"];
req.queryInfoDic = queryInfoDic;
[WXApi sendReq:req completion:^(BOOL done) {
result(@(done));
}];
}
- (void)handleLaunchMiniProgram:(FlutterMethodCall *)call result:(FlutterResult)result { - (void)handleLaunchMiniProgram:(FlutterMethodCall *)call result:(FlutterResult)result {
NSString *userName = call.arguments[@"userName"]; NSString *userName = call.arguments[@"userName"];
NSString *path = call.arguments[@"path"]; NSString *path = call.arguments[@"path"];
...@@ -161,7 +176,6 @@ BOOL handleOpenURLByFluwx = YES; ...@@ -161,7 +176,6 @@ BOOL handleOpenURLByFluwx = YES;
}]; }];
} }
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]]; return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler defaultManager]];
} }
......
...@@ -188,7 +188,7 @@ FlutterMethodChannel *fluwxMethodChannel = nil; ...@@ -188,7 +188,7 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
@"businessType": @(businessResp.businessType), @"businessType": @(businessResp.businessType),
}; };
[fluwxMethodChannel invokeMethod:@"onAutoDeductResponse" arguments:result]; [fluwxMethodChannel invokeMethod:@"onWXOpenBusinessWebviewResponse" arguments:result];
} }
} }
......
...@@ -145,6 +145,14 @@ Future<bool> payWithWeChat( ...@@ -145,6 +145,14 @@ Future<bool> payWithWeChat(
}); });
} }
/// request Hong Kong Wallet payment with WeChat.
/// Read the official document for more detail.
Future<bool> payWithWeChatHongKongWallet({@required String prepayId}) async {
return await _channel.invokeMethod("payWithHongKongWallet", {
"prepayId": prepayId,
});
}
/// subscribe WeChat message /// subscribe WeChat message
Future<bool> subscribeWeChatMsg({ Future<bool> subscribeWeChatMsg({
@required String appId, @required String appId,
......
...@@ -32,8 +32,8 @@ Map<String, _WeChatResponseInvoker> _nameAndResponseMapper = { ...@@ -32,8 +32,8 @@ Map<String, _WeChatResponseInvoker> _nameAndResponseMapper = {
"onPayResponse": (Map argument) => WeChatPaymentResponse.fromMap(argument), "onPayResponse": (Map argument) => WeChatPaymentResponse.fromMap(argument),
"onSubscribeMsgResp": (Map argument) => "onSubscribeMsgResp": (Map argument) =>
WeChatSubscribeMsgResponse.fromMap(argument), WeChatSubscribeMsgResponse.fromMap(argument),
"onAutoDeductResponse": (Map argument) => "onWXOpenBusinessWebviewResponse": (Map argument) =>
WeChatAutoDeductResponse.fromMap(argument), WeChatOpenBusinessWebviewResponse.fromMap(argument),
"onAuthByQRCodeFinished": (Map argument) => "onAuthByQRCodeFinished": (Map argument) =>
WeChatAuthByQRCodeFinishedResponse.fromMap(argument), WeChatAuthByQRCodeFinishedResponse.fromMap(argument),
"onAuthGotQRCode": (Map argument) => "onAuthGotQRCode": (Map argument) =>
...@@ -134,13 +134,13 @@ class WeChatSubscribeMsgResponse extends BaseWeChatResponse { ...@@ -134,13 +134,13 @@ class WeChatSubscribeMsgResponse extends BaseWeChatResponse {
super._(map[_errCode], map[_errStr]); super._(map[_errCode], map[_errStr]);
} }
class WeChatAutoDeductResponse extends BaseWeChatResponse { class WeChatOpenBusinessWebviewResponse extends BaseWeChatResponse {
final int type; final int type;
final int errCode; final int errCode;
final int businessType; final int businessType;
final String resultInfo; final String resultInfo;
WeChatAutoDeductResponse.fromMap(Map map) WeChatOpenBusinessWebviewResponse.fromMap(Map map)
: type = map["type"], : type = map["type"],
errCode = map[_errCode], errCode = map[_errCode],
businessType = map["businessType"], businessType = map["businessType"],
......
...@@ -105,8 +105,8 @@ void main() { ...@@ -105,8 +105,8 @@ void main() {
"businessType": 2, "businessType": 2,
"resultInfo": "resultInfo" "resultInfo": "resultInfo"
}); });
expect(response is WeChatAutoDeductResponse, true); expect(response is WeChatOpenBusinessWebviewResponse, true);
var casted = response as WeChatAutoDeductResponse; var casted = response as WeChatOpenBusinessWebviewResponse;
assert(casted.isSuccessful); assert(casted.isSuccessful);
expect(casted.type, 1); expect(casted.type, 1);
expect(casted.errCode, 0); expect(casted.errCode, 0);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论