Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
c0e1c434
提交
c0e1c434
authored
5月 19, 2022
作者:
孙普伦
提交者:
jarvanmo
5月 19, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bump to 3.9.0
上级
876c74c5
显示空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
191 行增加
和
16 行删除
+191
-16
CHANGELOG.md
CHANGELOG.md
+3
-0
FluwxPlugin.kt
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
+26
-0
FluwxResponseHandler.kt
.../kotlin/com/jarvan/fluwx/handlers/FluwxResponseHandler.kt
+12
-0
WXApiUtils.java
...id/src/main/kotlin/com/jarvan/fluwx/utils/WXApiUtils.java
+66
-0
FluwxPlugin.m
ios/Classes/FluwxPlugin.m
+19
-5
FluwxResponseHandler.m
ios/Classes/FluwxResponseHandler.m
+36
-3
WXApiRequestHandler.h
ios/Classes/WXApiRequestHandler.h
+5
-6
WXApiRequestHandler.m
ios/Classes/WXApiRequestHandler.m
+13
-0
fluwx_iml.dart
lib/src/fluwx_iml.dart
+1
-1
wechat_response.dart
lib/src/response/wechat_response.dart
+9
-0
pubspec.yaml
pubspec.yaml
+1
-1
没有找到文件。
CHANGELOG.md
浏览文件 @
c0e1c434
# 3.9.0
*
支持微信卡包
# 3.8.5
*
Fix #471
...
...
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
浏览文件 @
c0e1c434
...
...
@@ -2,8 +2,10 @@ package com.jarvan.fluwx
import
android.content.Context
import
android.content.Intent
import
android.util.Log
import
androidx.annotation.NonNull
import
com.jarvan.fluwx.handlers.*
import
com.jarvan.fluwx.utils.WXApiUtils
import
com.tencent.mm.opensdk.modelbiz.*
import
com.tencent.mm.opensdk.modelpay.PayReq
import
io.flutter.embedding.engine.plugins.FlutterPlugin
...
...
@@ -80,10 +82,34 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
result
)
call
.
method
==
"openBusinessView"
->
openBusinessView
(
call
,
result
)
call
.
method
==
"openWeChatInvoice"
->
openWeChatInvoice
(
call
,
result
);
else
->
result
.
notImplemented
()
}
}
private
fun
openWeChatInvoice
(
call
:
MethodCall
,
result
:
Result
)
{
if
(
WXAPiHandler
.
wxApi
==
null
)
{
result
.
error
(
"Unassigned WxApi"
,
"please config wxapi first"
,
null
)
return
}
else
{
//android 只有ChooseCard, IOS直接有ChooseInvoice
val
request
=
ChooseCardFromWXCardPackage
.
Req
()
request
.
cardType
=
call
.
argument
(
"cardType"
)
request
.
appId
=
call
.
argument
(
"appId"
)
request
.
locationId
=
call
.
argument
(
"locationId"
)
request
.
cardId
=
call
.
argument
(
"cardId"
)
request
.
canMultiSelect
=
call
.
argument
(
"canMultiSelect"
)
request
.
timeStamp
=
System
.
currentTimeMillis
().
toString
()
request
.
nonceStr
=
System
.
currentTimeMillis
().
toString
()
request
.
signType
=
"SHA1"
request
.
cardSign
=
WXApiUtils
.
createSign
(
request
.
appId
,
request
.
nonceStr
,
request
.
timeStamp
,
request
.
cardType
)
val
done
=
WXAPiHandler
.
wxApi
?.
sendReq
(
request
)
result
.
success
(
done
)
}
}
override
fun
onDetachedFromEngine
(
@NonNull
binding
:
FlutterPlugin
.
FlutterPluginBinding
)
{
shareHandler
?.
onDestroy
()
authHandler
?.
removeAllListeners
()
...
...
android/src/main/kotlin/com/jarvan/fluwx/handlers/FluwxResponseHandler.kt
浏览文件 @
c0e1c434
...
...
@@ -40,8 +40,20 @@ object FluwxResponseHandler {
is
WXOpenBusinessWebview
.
Resp
->
handlerWXOpenBusinessWebviewResponse
(
response
)
is
WXOpenCustomerServiceChat
.
Resp
->
handlerWXOpenCustomerServiceChatResponse
(
response
)
is
WXOpenBusinessView
.
Resp
->
handleWXOpenBusinessView
(
response
)
is
ChooseCardFromWXCardPackage
.
Resp
->
handleWXOpenInvoiceResponse
(
response
)
}
}
private
fun
handleWXOpenInvoiceResponse
(
response
:
ChooseCardFromWXCardPackage
.
Resp
)
{
val
result
=
mapOf
(
"cardItemList"
to
response
.
cardItemList
,
"transaction"
to
response
.
transaction
,
"openid"
to
response
.
openId
,
errStr
to
response
.
errStr
,
type
to
response
.
type
,
errCode
to
response
.
errCode
)
FluwxPlugin
.
callingChannel
?.
invokeMethod
(
"onOpenWechatInvoiceResponse"
,
result
)
}
private
fun
handleWXOpenBusinessView
(
response
:
WXOpenBusinessView
.
Resp
)
{
val
result
=
mapOf
(
...
...
android/src/main/kotlin/com/jarvan/fluwx/utils/WXApiUtils.java
0 → 100644
浏览文件 @
c0e1c434
package
com
.
jarvan
.
fluwx
.
utils
;
import
java.io.UnsupportedEncodingException
;
import
java.security.MessageDigest
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.SortedMap
;
import
java.util.TreeMap
;
public
class
WXApiUtils
{
public
static
String
createSign
(
String
appId
,
String
nonceStr
,
String
timestamp
,
String
card_type
)
{
SortedMap
<
Object
,
Object
>
parameters
=
new
TreeMap
<>();
parameters
.
put
(
"app_id"
,
appId
);
parameters
.
put
(
"nonce_str"
,
nonceStr
);
parameters
.
put
(
"card_type"
,
timestamp
);
parameters
.
put
(
"time_stamp"
,
card_type
);
StringBuffer
sb
=
new
StringBuffer
();
Set
es
=
parameters
.
entrySet
();
// 所有参与传参的参数按照accsii排序(升序)
Iterator
it
=
es
.
iterator
();
while
(
it
.
hasNext
())
{
@SuppressWarnings
(
"rawtypes"
)
Map
.
Entry
entry
=
(
Map
.
Entry
)
it
.
next
();
String
k
=
(
String
)
entry
.
getKey
();
Object
v
=
entry
.
getValue
();
if
(
null
!=
v
&&
!
""
.
equals
(
v
)
&&
!
"sign"
.
equals
(
k
)
&&
!
"key"
.
equals
(
k
))
{
sb
.
append
(
k
+
"="
+
v
+
"&"
);
}
}
String
sign
=
shaEncode
(
sb
.
toString
()).
toUpperCase
();
return
sign
;
}
public
static
String
shaEncode
(
String
inStr
)
{
MessageDigest
sha
=
null
;
try
{
sha
=
MessageDigest
.
getInstance
(
"SHA"
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
toString
());
e
.
printStackTrace
();
return
""
;
}
byte
[]
byteArray
=
new
byte
[
0
];
try
{
byteArray
=
inStr
.
getBytes
(
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
byte
[]
md5Bytes
=
sha
.
digest
(
byteArray
);
StringBuffer
hexValue
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
md5Bytes
.
length
;
i
++)
{
int
val
=
((
int
)
md5Bytes
[
i
])
&
0xff
;
if
(
val
<
16
)
{
hexValue
.
append
(
"0"
);
}
hexValue
.
append
(
Integer
.
toHexString
(
val
));
}
return
hexValue
.
toString
();
}
}
ios/Classes/FluwxPlugin.m
浏览文件 @
c0e1c434
...
...
@@ -73,10 +73,6 @@ FlutterMethodChannel *channel = nil;
[
_fluwxAuthHandler
stopAuthByQRCode
:
call
result
:
result
];
}
else
if
([
@"openWXApp"
isEqualToString
:
call
.
method
])
{
result
(
@
([
WXApi
openWXApp
]));
}
else
if
([
@"payWithFluwx"
isEqualToString
:
call
.
method
])
{
[
self
handlePayment
:
call
result
:
result
];
}
else
if
([
@"payWithHongKongWallet"
isEqualToString
:
call
.
method
])
{
[
self
handleHongKongWalletPayment
:
call
result
:
result
];
}
else
if
([
@"launchMiniProgram"
isEqualToString
:
call
.
method
])
{
[
self
handleLaunchMiniProgram
:
call
result
:
result
];
}
else
if
([
@"subscribeMsg"
isEqualToString
:
call
.
method
])
{
...
...
@@ -97,11 +93,29 @@ FlutterMethodChannel *channel = nil;
[
self
openWeChatCustomerServiceChat
:
call
result
:
result
];
}
else
if
([
@"checkSupportOpenBusinessView"
isEqualToString
:
call
.
method
])
{
[
self
checkSupportOpenBusinessView
:
call
result
:
result
];
}
else
{
}
else
if
([
@"openWeChatInvoice"
isEqualToString
:
call
.
method
])
{
[
self
openWeChatInvoice
:
call
result
:
result
];
}
else
{
result
(
FlutterMethodNotImplemented
);
}
}
-
(
void
)
openWeChatInvoice
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
NSString
*
appId
=
call
.
arguments
[
@"appId"
];
if
([
FluwxStringUtil
isBlank
:
appId
])
{
result
([
FlutterError
errorWithCode
:
@"invalid app id"
message
:
@"are you sure your app id is correct ? "
details
:
appId
]);
return
;
}
[
WXApiRequestHandler
chooseInvoice
:
appId
timestamp
:[[
NSDate
date
]
timeIntervalSince1970
]
completion:
^
(
BOOL
done
)
{
result
(
@
(
done
));
}];
}
-
(
void
)
registerApp
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
NSNumber
*
doOnIOS
=
call
.
arguments
[
@"iOS"
];
...
...
ios/Classes/FluwxResponseHandler.m
浏览文件 @
c0e1c434
...
...
@@ -92,11 +92,44 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
[
_delegate
managerDidRecvChooseCardResponse
:
chooseCardResp
];
}
}
else
if
([
resp
isKindOfClass
:[
WXChooseInvoiceResp
class
]])
{
if
(
_delegate
&&
[
_delegate
respondsToSelector
:
@selector
(
managerDidRecvChooseInvoiceResponse
:)])
{
//TODO 处理发票返回,并回调Dart
WXChooseInvoiceResp
*
chooseInvoiceResp
=
(
WXChooseInvoiceResp
*
)
resp
;
[
_delegate
managerDidRecvChooseInvoiceResponse
:
chooseInvoiceResp
];
NSArray
*
array
=
chooseInvoiceResp
.
cardAry
;
NSMutableArray
*
mutableArray
=
[
NSMutableArray
arrayWithCapacity
:
array
.
count
];
for
(
int
i
=
0
;
i
<
array
.
count
;
i
++
)
{
WXInvoiceItem
*
item
=
array
[
i
];
NSDictionary
*
dict
=
@{
@"app_id"
:
item
.
appID
,
@"encrypt_code"
:
item
.
encryptCode
,
@"card_id"
:
item
.
cardId
};
[
mutableArray
addObject
:
dict
];
}
NSError
*
error
=
nil
;
NSData
*
jsonData
=
[
NSJSONSerialization
dataWithJSONObject
:
mutableArray
options
:
NSJSONWritingPrettyPrinted
error
:
&
error
];
NSString
*
cardItemList
=
@""
;
if
([
jsonData
length
]
&&
error
==
nil
)
{
cardItemList
=
[[
NSString
alloc
]
initWithData
:
jsonData
encoding
:
NSUTF8StringEncoding
];
}
NSDictionary
*
result
=
@{
description:
chooseInvoiceResp
.
description
==
nil
?
@""
:
chooseInvoiceResp
.
description
,
errStr:
chooseInvoiceResp
.
errStr
==
nil
?
@""
:
chooseInvoiceResp
.
errStr
,
errCode:
@
(
chooseInvoiceResp
.
errCode
),
type:
@
(
chooseInvoiceResp
.
type
),
@"cardItemList"
:
cardItemList
};
[
fluwxMethodChannel
invokeMethod
:
@"onOpenWechatInvoiceResponse"
arguments
:
result
];
}
else
if
([
resp
isKindOfClass
:[
WXSubscribeMsgResp
class
]])
{
if
([
_delegate
respondsToSelector
:
@selector
(
managerDidRecvSubscribeMsgResponse
:)])
{
[
_delegate
managerDidRecvSubscribeMsgResponse
:(
WXSubscribeMsgResp
*
)
resp
];
...
...
ios/Classes/WXApiRequestHandler.h
浏览文件 @
c0e1c434
...
...
@@ -125,16 +125,15 @@ NS_ASSUME_NONNULL_BEGIN
timestamp
:(
UInt32
)
timestamp
completion
:(
void
(
^
__nullable
)(
BOOL
success
))
completion
;
+
(
void
)
openUrl
:(
NSString
*
)
url
completion
:(
void
(
^
__nullable
)(
BOOL
success
))
completion
;
+
(
void
)
chooseInvoice
:(
NSString
*
)
appid
cardSign
:(
NSString
*
)
cardSign
nonceStr
:(
NSString
*
)
nonceStr
signType
:(
NSString
*
)
signType
timestamp
:(
UInt32
)
timestamp
completion
:(
void
(
^
__nullable
)(
BOOL
success
))
completion
;
+
(
void
)
openUrl
:(
NSString
*
)
url
completion
:(
void
(
^
__nullable
)(
BOOL
success
))
completion
;
+
(
void
)
sendPayment
:(
NSString
*
)
appId
PartnerId
:(
NSString
*
)
partnerId
...
...
ios/Classes/WXApiRequestHandler.m
浏览文件 @
c0e1c434
...
...
@@ -326,6 +326,19 @@
}
+
(
void
)
chooseInvoice
:(
NSString
*
)
appid
timestamp
:(
UInt32
)
timestamp
completion
:(
void
(
^
__nullable
)(
BOOL
success
))
completion
{
WXChooseInvoiceReq
*
chooseInvoiceReq
=
[[
WXChooseInvoiceReq
alloc
]
init
];
chooseInvoiceReq
.
appID
=
appid
;
chooseInvoiceReq
.
timeStamp
=
timestamp
;
chooseInvoiceReq
.
signType
=
@"SHA1"
;
chooseInvoiceReq
.
cardSign
=
@""
;
chooseInvoiceReq
.
nonceStr
=
@""
;
[
WXApi
sendReq
:
chooseInvoiceReq
completion
:
completion
];
}
+
(
void
)
sendAuthRequestScope
:(
NSString
*
)
scope
State
:(
NSString
*
)
state
OpenID
:(
NSString
*
)
openID
...
...
lib/src/fluwx_iml.dart
浏览文件 @
c0e1c434
...
...
@@ -314,7 +314,7 @@ Future<bool> checkSupportOpenBusinessView() async {
return
await
_channel
.
invokeMethod
(
"checkSupportOpenBusinessView"
);
}
///open wechat invoice list
Future
<
bool
>
openWeChatInvoice
({
required
String
appId
,
required
String
cardType
,
...
...
lib/src/response/wechat_response.dart
浏览文件 @
c0e1c434
...
...
@@ -46,6 +46,8 @@ Map<String, _WeChatResponseInvoker> _nameAndResponseMapper = {
WeChatOpenCustomerServiceChatResponse
.
fromMap
(
argument
),
"onOpenBusinessViewResponse"
:
(
Map
argument
)
=>
WeChatOpenBusinessViewResponse
.
fromMap
(
argument
),
"onOpenWechatInvoiceResponse"
:
(
Map
argument
)
=>
WeChatOpenInvoiceResponse
.
fromMap
(
argument
),
};
class
BaseWeChatResponse
{
...
...
@@ -66,6 +68,13 @@ class BaseWeChatResponse {
bool
get
isSuccessful
=>
errCode
==
0
;
}
class
WeChatOpenInvoiceResponse
extends
BaseWeChatResponse
{
String
?
cardItemList
;
WeChatOpenInvoiceResponse
.
fromMap
(
Map
map
)
:
cardItemList
=
map
[
"cardItemList"
],
super
.
_
(
map
[
_errCode
],
map
[
_errStr
]);
}
class
WeChatShareResponse
extends
BaseWeChatResponse
{
WeChatShareResponse
.
fromMap
(
Map
map
)
:
type
=
map
[
'type'
],
...
...
pubspec.yaml
浏览文件 @
c0e1c434
name
:
fluwx
description
:
The capability of implementing WeChat SDKs in Flutter. With Fluwx, developers can use WeChatSDK easily, such as sharing, payment, lanuch mini program and etc.
version
:
3.
8.5
version
:
3.
9.0
homepage
:
https://github.com/JarvanMo/fluwx
environment
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论