diff --git a/Sample/src/main/java/io/github/socialhelper/demo/MainActivity.kt b/Sample/src/main/java/io/github/socialhelper/demo/MainActivity.kt
index 3eb89b4..e4165c9 100644
--- a/Sample/src/main/java/io/github/socialhelper/demo/MainActivity.kt
+++ b/Sample/src/main/java/io/github/socialhelper/demo/MainActivity.kt
@@ -25,7 +25,12 @@ class MainActivity : AppCompatActivity() {
// Toast.makeText(this,it,Toast.LENGTH_LONG).show()
// })
- SocialHelper.startWeChatPay("1365026102","wx271754067562114fedb5565b1827663000","D94996F23D4542B277F35756122DEF7C")
+// SocialHelper.startWeChatPay("1365026102","wx271754067562114fedb5565b1827663000","C380BEC2BFD727A4B6845133519F3AD6",{
+// Toast.makeText(this,"支付成功",Toast.LENGTH_LONG).show()
+// },{
+// Toast.makeText(this,it,Toast.LENGTH_LONG).show()
+// })
+
// SocialHelper.getUserInfo("56_qoH8DaSoiTeRKWA-KHd6ExkKKK3j9N5v5ykfvJ22D3OG97hUFOzY_Xr-VHWS4SVErlh3Ox3Mp6p8sAieRQfhmgzN-OBslqxG6PKFhyvWZAQ","oHyiq6WWtG8-xgJDWWYMvShFRNyU",{
// Toast.makeText(this,it.toJsonStr(), Toast.LENGTH_LONG).show()
diff --git a/Sample/src/main/java/io/github/socialhelper/demo/wxapi/WxPayEntryActivity.kt b/Sample/src/main/java/io/github/socialhelper/demo/wxapi/WxPayEntryActivity.kt
index 25396f8..38e3576 100644
--- a/Sample/src/main/java/io/github/socialhelper/demo/wxapi/WxPayEntryActivity.kt
+++ b/Sample/src/main/java/io/github/socialhelper/demo/wxapi/WxPayEntryActivity.kt
@@ -1,6 +1,6 @@
package io.github.socialhelper.demo.wxapi
-import io.github.socialhelper.wechat.WeChatSocialPayEntryActivity
+import io.github.socialhelper.wechat.WeChatSocialEntryActivity
-class WxPayEntryActivity:WeChatSocialPayEntryActivity() {
+class WxPayEntryActivity: WeChatSocialEntryActivity() {
}
\ No newline at end of file
diff --git a/SocialHelper/src/main/AndroidManifest.xml b/SocialHelper/src/main/AndroidManifest.xml
index e030285..4cb1bcb 100644
--- a/SocialHelper/src/main/AndroidManifest.xml
+++ b/SocialHelper/src/main/AndroidManifest.xml
@@ -2,4 +2,6 @@
+
+
\ No newline at end of file
diff --git a/WeChat/proguard-rules.pro b/WeChat/proguard-rules.pro
index 481bb43..1ecc6e2 100644
--- a/WeChat/proguard-rules.pro
+++ b/WeChat/proguard-rules.pro
@@ -18,4 +18,15 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
-#-renamesourcefileattribute SourceFile
\ No newline at end of file
+#-renamesourcefileattribute SourceFile
+-keep class com.tencent.mm.opensdk.** {
+ *;
+}
+
+-keep class com.tencent.wxop.** {
+ *;
+}
+
+-keep class com.tencent.mm.sdk.** {
+ *;
+}
\ No newline at end of file
diff --git a/WeChat/src/main/java/io/github/socialhelper/wechat/WeChatSocialEntryActivity.kt b/WeChat/src/main/java/io/github/socialhelper/wechat/WeChatSocialEntryActivity.kt
index 71d77d7..0f44ff5 100644
--- a/WeChat/src/main/java/io/github/socialhelper/wechat/WeChatSocialEntryActivity.kt
+++ b/WeChat/src/main/java/io/github/socialhelper/wechat/WeChatSocialEntryActivity.kt
@@ -55,18 +55,7 @@ open class WeChatSocialEntryActivity : Activity(), IWXAPIEventHandler {
when (mBaseResp.type) {
WECHAT_RESULT_TYPE_LOGIN -> {
//授权回调
- (mBaseResp as SendAuth.Resp).also { sendAuthResp ->
- sendAuthResp.authResult.yes {
- onReqAuthSucc(sendAuthResp)
- }.otherwise {
- mWeChatReqAuthErrorListener(
- if (sendAuthResp.errStr == null) application.getString(
- R.string.social_wechat_resp_auth_fail
- ) else sendAuthResp.errStr
- )
- }
- }
-
+ onReqAuthSucc(mBaseResp as SendAuth.Resp)
}
WECHAT_RESULT_TYPE_SHARE -> {
diff --git a/WeChat/src/main/java/io/github/socialhelper/wechat/WeChatSocialHelperExt.kt b/WeChat/src/main/java/io/github/socialhelper/wechat/WeChatSocialHelperExt.kt
index fa51246..ae51f43 100644
--- a/WeChat/src/main/java/io/github/socialhelper/wechat/WeChatSocialHelperExt.kt
+++ b/WeChat/src/main/java/io/github/socialhelper/wechat/WeChatSocialHelperExt.kt
@@ -33,6 +33,11 @@ var mWeChatReqShareSuccessListener: (() -> Unit)? = null
//微信分享结果错误回传接口
var mWeChatReqShareErrorListener: ((String) -> Unit)? = null
+//微信支付结果回传接口
+lateinit var mWeChatReqPaySuccessListener: () -> Unit
+
+//微信支付结果错误回传接口
+lateinit var mWeChatReqPayErrorListener: (String) -> Unit
/**
* 发起微信授权 如果配置了appSecretKey则会返回 authCode + accessToken,否则将只返回 authCode
@@ -97,7 +102,7 @@ fun SocialHelper.getUserInfo(
fun SocialHelper.shareTextToWeChat(
weChatShareType: WeChatShareType,
text: String,
- description: String? = null,
+ description: String,
onShareSuccess: (() -> Unit)? = null,
onShareError: ((String) -> Unit)? = null
) {
@@ -113,9 +118,7 @@ fun SocialHelper.shareTextToWeChat(
mWXMediaMessage.mediaObject = WXTextObject().also {
it.text = text
}
- (description.isNullOrEmpty()).no {
mWXMediaMessage.description = description
- }
}
scene = getShareScene(weChatShareType)
})
@@ -175,7 +178,7 @@ fun SocialHelper.shareImageToWeChat(
fun SocialHelper.shareMusicToWeChat(
weChatShareType: WeChatShareType,
musicUrl: String,
- musicTitle: String?=null,
+ musicTitle: String,
musicDescription: String?=null,
thumbBitmap: Bitmap? = null,
onShareSuccess: (() -> Unit)? = null,
@@ -286,7 +289,7 @@ fun SocialHelper.shareWebPageToWeChat(
weChatShareType: WeChatShareType,
webpageUrl: String,
webpageTitle: String?=null,
- webpageDescription: String?=null,
+ webpageDescription: String,
thumbBitmap: Bitmap? = null,
onShareSuccess: (() -> Unit)? = null,
onShareError: ((String) -> Unit)? = null
@@ -398,9 +401,9 @@ fun SocialHelper.shareMiniProgramToWeChat(
* 发起微信支付
* [partnerId] 商户号 请填写商户号mchid对应的值。示例值:1900000109
* [prepayid] 预支付交易会话ID 微信返回的支付交易会话ID,该值有效期为2小时。 示例值: WX1217752501201407033233368018
- *
+ * [sign] 签名
*/
-fun SocialHelper.startWeChatPay(partnerId:String,prepayId:String,sign:String){
+fun SocialHelper.startWeChatPay(partnerId:String,prepayId:String,sign:String,onPaySuccess:()->Unit,onPayError:(String)->Unit){
regWeChatSDK(this)
diff --git a/WeChat/src/main/java/io/github/socialhelper/wechat/WeChatSocialPayEntryActivity.kt b/WeChat/src/main/java/io/github/socialhelper/wechat/WeChatSocialPayEntryActivity.kt
index de0faab..24704c0 100644
--- a/WeChat/src/main/java/io/github/socialhelper/wechat/WeChatSocialPayEntryActivity.kt
+++ b/WeChat/src/main/java/io/github/socialhelper/wechat/WeChatSocialPayEntryActivity.kt
@@ -45,17 +45,12 @@ open class WeChatSocialPayEntryActivity : Activity(), IWXAPIEventHandler {
(mBaseResp.errCode == BaseResp.ErrCode.ERR_OK).yes {
"${localClassName}->onResp():mBaseResp:${mBaseResp.toJsonStr()}".logD()
-
-
+ mWeChatReqPaySuccessListener()
}.otherwise {
-
+ mWeChatReqPayErrorListener( if (mBaseResp.errCode == BaseResp.ErrCode.ERR_USER_CANCEL) application.getString(R.string.social_wechat_pay_cancel_err) else (if (mBaseResp.errStr.isNullOrEmpty()) getString(R.string.social_wechat_pay_other_err,mBaseResp.errCode) else mBaseResp.errStr))
"${localClassName}->onResp():mBaseResp:${mBaseResp.toJsonStr()}".logE()
-
}
- mWeChatReqShareErrorListener = null
- mWeChatReqShareSuccessListener = null
-
finish()
}
diff --git a/WeChat/src/main/res/values/strings.xml b/WeChat/src/main/res/values/strings.xml
index 68dd526..52d7172 100644
--- a/WeChat/src/main/res/values/strings.xml
+++ b/WeChat/src/main/res/values/strings.xml
@@ -1,10 +1,12 @@
微信未安装,请安装微信后再试
授权被取消
- 授权验证失败
accessToken获取失败,%s
用户资料获取失败,%d
分享失败,%d
+ 用户取消支付
+ 支付失败,%d
+
\ No newline at end of file