Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
c9c8d39f
提交
c9c8d39f
authored
7月 09, 2020
作者:
Jack Liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added wechat pay hk by WXOpenBusinessWebview
上级
e0521d1d
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
57 行增加
和
9 行删除
+57
-9
FluwxPlugin.kt
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
+11
-0
FluwxResponseHandler.kt
.../kotlin/com/jarvan/fluwx/handlers/FluwxResponseHandler.kt
+2
-1
FluwxPlugin.m
ios/Classes/FluwxPlugin.m
+15
-1
FluwxResponseHandler.m
ios/Classes/FluwxResponseHandler.m
+1
-1
fluwx_iml.dart
lib/src/fluwx_iml.dart
+8
-0
wechat_response.dart
lib/src/response/wechat_response.dart
+18
-4
wechat_response_test.dart
test/response/wechat_response_test.dart
+2
-2
没有找到文件。
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
浏览文件 @
c9c8d39f
...
@@ -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"
)
?:
""
...
...
android/src/main/kotlin/com/jarvan/fluwx/handlers/FluwxResponseHandler.kt
浏览文件 @
c9c8d39f
...
@@ -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
(
"on
AutoDeduct
Response"
,
result
)
channel
?.
invokeMethod
(
"on
WXOpenBusinessWebview
Response"
,
result
)
}
}
}
}
\ No newline at end of file
ios/Classes/FluwxPlugin.m
浏览文件 @
c9c8d39f
...
@@ -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
]];
}
}
...
...
ios/Classes/FluwxResponseHandler.m
浏览文件 @
c9c8d39f
...
@@ -188,7 +188,7 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
...
@@ -188,7 +188,7 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
@"businessType"
:
@
(
businessResp
.
businessType
),
@"businessType"
:
@
(
businessResp
.
businessType
),
};
};
[
fluwxMethodChannel
invokeMethod
:
@"on
AutoDeduct
Response"
arguments
:
result
];
[
fluwxMethodChannel
invokeMethod
:
@"on
WXOpenBusinessWebview
Response"
arguments
:
result
];
}
}
}
}
...
...
lib/src/fluwx_iml.dart
浏览文件 @
c9c8d39f
...
@@ -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
,
...
...
lib/src/response/wechat_response.dart
浏览文件 @
c9c8d39f
...
@@ -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
),
"on
AutoDeduct
Response"
:
(
Map
argument
)
=>
"on
WXOpenBusinessWebview
Response"
:
(
Map
argument
)
=>
WeChat
AutoDeduct
Response
.
fromMap
(
argument
),
WeChat
OpenBusinessWebview
Response
.
fromMap
(
argument
),
"onAuthByQRCodeFinished"
:
(
Map
argument
)
=>
"onAuthByQRCodeFinished"
:
(
Map
argument
)
=>
WeChatAuthByQRCodeFinishedResponse
.
fromMap
(
argument
),
WeChatAuthByQRCodeFinishedResponse
.
fromMap
(
argument
),
"onAuthGotQRCode"
:
(
Map
argument
)
=>
"onAuthGotQRCode"
:
(
Map
argument
)
=>
...
@@ -134,13 +134,27 @@ class WeChatSubscribeMsgResponse extends BaseWeChatResponse {
...
@@ -134,13 +134,27 @@ class WeChatSubscribeMsgResponse extends BaseWeChatResponse {
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
}
}
class
WeChat
AutoDeduc
tResponse
extends
BaseWeChatResponse
{
class
WeChat
PayWithHongKongWalle
tResponse
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
)
WeChatPayWithHongKongWalletResponse
.
fromMap
(
Map
map
)
:
type
=
map
[
"type"
],
errCode
=
map
[
_errCode
],
businessType
=
map
[
"businessType"
],
resultInfo
=
map
[
"resultInfo"
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
}
class
WeChatOpenBusinessWebviewResponse
extends
BaseWeChatResponse
{
final
int
type
;
final
int
errCode
;
final
int
businessType
;
final
String
resultInfo
;
WeChatOpenBusinessWebviewResponse
.
fromMap
(
Map
map
)
:
type
=
map
[
"type"
],
:
type
=
map
[
"type"
],
errCode
=
map
[
_errCode
],
errCode
=
map
[
_errCode
],
businessType
=
map
[
"businessType"
],
businessType
=
map
[
"businessType"
],
...
...
test/response/wechat_response_test.dart
浏览文件 @
c9c8d39f
...
@@ -105,8 +105,8 @@ void main() {
...
@@ -105,8 +105,8 @@ void main() {
"businessType"
:
2
,
"businessType"
:
2
,
"resultInfo"
:
"resultInfo"
"resultInfo"
:
"resultInfo"
});
});
expect
(
response
is
WeChat
AutoDeduct
Response
,
true
);
expect
(
response
is
WeChat
OpenBusinessWebview
Response
,
true
);
var
casted
=
response
as
WeChat
AutoDeduct
Response
;
var
casted
=
response
as
WeChat
OpenBusinessWebview
Response
;
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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论