fmk
4 years ago
33 changed files with 877 additions and 565 deletions
Binary file not shown.
@ -1,29 +1,86 @@
|
||||
package com.zsw.huixiang.wxapi |
||||
|
||||
import android.content.Intent |
||||
import android.content.pm.PackageManager |
||||
import android.os.Bundle |
||||
import android.util.Log |
||||
import com.jarvan.fluwx.handlers.FluwxRequestHandler |
||||
import com.jarvan.fluwx.handlers.FluwxResponseHandler |
||||
import com.jarvan.fluwx.handlers.WXAPiHandler |
||||
import com.tencent.mm.opensdk.modelbase.BaseReq |
||||
import com.tencent.mm.opensdk.modelbase.BaseResp |
||||
import io.dcloud.feature.payment.weixin.AbsWXPayCallbackActivity |
||||
|
||||
|
||||
class WXPayEntryActivity : AbsWXPayCallbackActivity() { |
||||
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) { |
||||
super.onCreate(savedInstanceState) |
||||
try { |
||||
if (!WXAPiHandler.wxApiRegistered) { |
||||
var appInfo = packageManager.getApplicationInfo(packageName, PackageManager.GET_META_DATA) |
||||
val wechatAppId = appInfo.metaData.getString("weChatAppId") |
||||
if (wechatAppId != null ){ |
||||
WXAPiHandler.setupWxApi(wechatAppId, this) |
||||
WXAPiHandler.setCoolBool(true) |
||||
io.flutter.Log.d("fluwx", "weChatAppId:$wechatAppId") |
||||
}else { |
||||
io.flutter.Log.e("fluwx", "can't load meta-data weChatAppId") |
||||
} |
||||
} |
||||
WXAPiHandler.wxApi?.handleIntent(intent, this) |
||||
} catch (e: Exception) { |
||||
e.printStackTrace() |
||||
startSpecifiedActivity(defaultFlutterActivityAction()) |
||||
finish() |
||||
} |
||||
Log.e("WXPayEntryActivity", "onCreate") |
||||
} |
||||
|
||||
override fun onReq(req: BaseReq?) { |
||||
override fun onNewIntent(intent: Intent) { |
||||
super.onNewIntent(intent) |
||||
|
||||
setIntent(intent) |
||||
|
||||
try { |
||||
WXAPiHandler.wxApi?.handleIntent(intent, this) |
||||
} catch (e: Exception) { |
||||
e.printStackTrace() |
||||
startSpecifiedActivity(defaultFlutterActivityAction()) |
||||
finish() |
||||
} |
||||
} |
||||
|
||||
override fun onReq(req: BaseReq) { |
||||
super.onReq(req) |
||||
FluwxRequestHandler.onReq(req, this) |
||||
Log.e("WXPayEntryActivity", "req: $req") |
||||
|
||||
} |
||||
|
||||
override fun onResp(resp: BaseResp?) { |
||||
override fun onResp(resp: BaseResp) { |
||||
FluwxResponseHandler.handleResponse(resp) |
||||
super.onResp(resp) |
||||
Log.e("WXPayEntryActivity", "resp: $resp") |
||||
} |
||||
|
||||
|
||||
|
||||
private fun startSpecifiedActivity(action: String, bundle: Bundle? = null, bundleKey: String? = null) { |
||||
Intent(action).run { |
||||
bundleKey?.let { |
||||
putExtra(bundleKey, bundle) |
||||
} |
||||
addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT) |
||||
packageManager?.let { |
||||
resolveActivity(packageManager)?.also { |
||||
startActivity(this) |
||||
finish() |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
private fun defaultFlutterActivityAction(): String = "$packageName.FlutterActivity" |
||||
|
||||
} |
After Width: | Height: | Size: 618 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 344 B |
@ -0,0 +1,65 @@
|
||||
/// appId : "" |
||||
/// nonceStr : "" |
||||
/// packageValue : "" |
||||
/// partnerId : "" |
||||
/// prepayId : "" |
||||
/// sign : "" |
||||
/// timeStamp : "" |
||||
|
||||
class WxPay { |
||||
String _appId; |
||||
String _nonceStr; |
||||
String _packageValue; |
||||
String _partnerId; |
||||
String _prepayId; |
||||
String _sign; |
||||
String _timeStamp; |
||||
|
||||
String get appId => _appId; |
||||
String get nonceStr => _nonceStr; |
||||
String get packageValue => _packageValue; |
||||
String get partnerId => _partnerId; |
||||
String get prepayId => _prepayId; |
||||
String get sign => _sign; |
||||
String get timeStamp => _timeStamp; |
||||
|
||||
WxPay({ |
||||
String appId, |
||||
String nonceStr, |
||||
String packageValue, |
||||
String partnerId, |
||||
String prepayId, |
||||
String sign, |
||||
String timeStamp}){ |
||||
_appId = appId; |
||||
_nonceStr = nonceStr; |
||||
_packageValue = packageValue; |
||||
_partnerId = partnerId; |
||||
_prepayId = prepayId; |
||||
_sign = sign; |
||||
_timeStamp = timeStamp; |
||||
} |
||||
|
||||
WxPay.fromJson(dynamic json) { |
||||
_appId = json["appId"]; |
||||
_nonceStr = json["nonceStr"]; |
||||
_packageValue = json["packageValue"]; |
||||
_partnerId = json["partnerId"]; |
||||
_prepayId = json["prepayId"]; |
||||
_sign = json["sign"]; |
||||
_timeStamp = json["timeStamp"]; |
||||
} |
||||
|
||||
Map<String, dynamic> toJson() { |
||||
var map = <String, dynamic>{}; |
||||
map["appId"] = _appId; |
||||
map["nonceStr"] = _nonceStr; |
||||
map["packageValue"] = _packageValue; |
||||
map["partnerId"] = _partnerId; |
||||
map["prepayId"] = _prepayId; |
||||
map["sign"] = _sign; |
||||
map["timeStamp"] = _timeStamp; |
||||
return map; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue