接入微信支付,微信提现
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2289
.idea/caches/deviceStreaming.xml
generated
2289
.idea/caches/deviceStreaming.xml
generated
File diff suppressed because it is too large
Load Diff
@@ -155,6 +155,7 @@ object ActionCode {
|
||||
"找回支付密码" -> url = "/app/setting/payPassword/reset"
|
||||
"查询支付密码状态" -> url = "/app/setting/payPassword/status"
|
||||
"订单支付" -> url = "/app/order/pay"
|
||||
"取消待支付订单" -> url = "/app/order/cancelPending"
|
||||
|
||||
|
||||
"修改个人信息" -> url = "/app/profile/update"
|
||||
@@ -178,6 +179,7 @@ object ActionCode {
|
||||
"绑定微信" -> url = "/app/profile/wx/bind"
|
||||
|
||||
|
||||
|
||||
}
|
||||
TTLog.e(url)
|
||||
return url;
|
||||
|
||||
@@ -4,4 +4,10 @@ class WithDrawModel {
|
||||
|
||||
var amount :String? = ""
|
||||
var payMethod :String? = ""
|
||||
}
|
||||
var authPackageInfo :String? = null
|
||||
var thirdOrderNo :String? = null
|
||||
var outBillNo :String? = null
|
||||
var mchId :String? = null
|
||||
var appId :String? = null
|
||||
var needConfirm :Boolean = false
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ class RechargeActivity : CKBaseActivity() {
|
||||
GlobalScope.launch(Dispatchers.IO){
|
||||
// [支付宝沙箱测试] 仅 Debug 包启用,Release 包继续使用正式环境。
|
||||
if (applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0) {
|
||||
EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX)
|
||||
// EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX)
|
||||
}
|
||||
val alipay = PayTask(this@RechargeActivity)
|
||||
val result = alipay.payV2(model?.orderStr, true)
|
||||
|
||||
@@ -20,11 +20,17 @@ import com.google.gson.Gson
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.tt.kit.model.Data
|
||||
import com.tt.kit.model.DataCollection
|
||||
import com.tt.kit.utils.LiveDataBus
|
||||
import com.tencent.mm.opensdk.modelbiz.WXOpenBusinessView
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory
|
||||
import com.ck.ckcollar.app.utils.Const
|
||||
import java.net.URLEncoder
|
||||
import java.math.BigDecimal
|
||||
|
||||
class WithDrawActivity : CKLHBaseActionBarActivity() {
|
||||
lateinit var binding: ActivityWithdrawBinding
|
||||
var model : BalanceModle? = null
|
||||
private var pendingWithdraw: WithDrawModel? = null
|
||||
|
||||
var payType = "0"
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -39,6 +45,14 @@ class WithDrawActivity : CKLHBaseActionBarActivity() {
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
LiveDataBus.get().with(WX_WITHDRAW_RESULT, Int::class.java).observe(this) { resultCode ->
|
||||
val withdraw = pendingWithdraw ?: return@observe
|
||||
if (resultCode == 0) {
|
||||
showWithdrawSuccess(withdraw)
|
||||
} else {
|
||||
toast(if (resultCode == -2) "已取消微信收款确认" else "微信提现确认失败")
|
||||
}
|
||||
}
|
||||
|
||||
binding.btnAli.setOnClickListener {
|
||||
binding.image1.setImageResource(R.mipmap.image_address_check_select)
|
||||
@@ -91,14 +105,13 @@ class WithDrawActivity : CKLHBaseActionBarActivity() {
|
||||
add(TTRequestData("payType", payType))
|
||||
}, object : ICallback {
|
||||
override fun onSuccess(data: String) {
|
||||
|
||||
var model = Gson().fromJson<WithDrawModel>(data, WithDrawModel::class.java)
|
||||
toActivity(WithDrawSuccessActivity::class.java, DataCollection().apply {
|
||||
add(Data("data", Gson().toJson(model)))
|
||||
|
||||
})
|
||||
|
||||
finish()
|
||||
val withdraw = Gson().fromJson(data, WithDrawModel::class.java)
|
||||
pendingWithdraw = withdraw
|
||||
if (withdraw.needConfirm && "0" == payType) {
|
||||
openWeChatTransferConfirm(withdraw)
|
||||
} else {
|
||||
showWithdrawSuccess(withdraw)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -110,6 +123,52 @@ class WithDrawActivity : CKLHBaseActionBarActivity() {
|
||||
|
||||
}
|
||||
|
||||
private fun openWeChatTransferConfirm(withdraw: WithDrawModel) {
|
||||
val mchId = withdraw.mchId
|
||||
val appId = withdraw.appId
|
||||
val packageInfo = withdraw.authPackageInfo
|
||||
if (mchId.isNullOrBlank() || appId.isNullOrBlank() || packageInfo.isNullOrBlank()) {
|
||||
toast("微信收款确认参数不完整")
|
||||
return
|
||||
}
|
||||
if (appId != Const.WX_APP_ID) {
|
||||
toast("微信支付 AppID 不匹配")
|
||||
return
|
||||
}
|
||||
|
||||
val api = WXAPIFactory.createWXAPI(this, Const.WX_APP_ID, true)
|
||||
api.registerApp(Const.WX_APP_ID)
|
||||
if (!api.isWXAppInstalled) {
|
||||
toast("请先安装微信")
|
||||
return
|
||||
}
|
||||
if (api.wxAppSupportAPI < 0x28002d33) {
|
||||
toast("当前微信版本过低,请升级微信")
|
||||
return
|
||||
}
|
||||
|
||||
val request = WXOpenBusinessView.Req().apply {
|
||||
businessType = "requestMerchantTransfer"
|
||||
query = "mchId=${URLEncoder.encode(mchId, "UTF-8")}" +
|
||||
"&appId=${URLEncoder.encode(appId, "UTF-8")}" +
|
||||
"&package=${URLEncoder.encode(packageInfo, "UTF-8")}"
|
||||
}
|
||||
if (!api.sendReq(request)) {
|
||||
toast("微信收款确认页拉起失败")
|
||||
}
|
||||
}
|
||||
|
||||
private fun showWithdrawSuccess(withdraw: WithDrawModel) {
|
||||
toActivity(WithDrawSuccessActivity::class.java, DataCollection().apply {
|
||||
add(Data("data", Gson().toJson(withdraw)))
|
||||
})
|
||||
finish()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val WX_WITHDRAW_RESULT = "wx_withdraw_result"
|
||||
}
|
||||
|
||||
|
||||
fun getBalanceInfo(){
|
||||
TTHttpClient.get(this,"余额", TTRequestParam(),object : ICallback{
|
||||
|
||||
@@ -242,7 +242,7 @@ class OpenMemberActivity : CKLHBaseActionBarActivity() {
|
||||
GlobalScope.launch(Dispatchers.IO){
|
||||
// [支付宝沙箱测试] 仅 Debug 包启用,Release 包继续使用正式环境。
|
||||
if (applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0) {
|
||||
EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX)
|
||||
// EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX)
|
||||
}
|
||||
val alipay = PayTask(this@OpenMemberActivity)
|
||||
val result = alipay.payV2(orderStr, true)
|
||||
|
||||
@@ -411,7 +411,7 @@ class PayOrderActivity : CKBaseActivity() {
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
// [支付宝沙箱测试] 仅 Debug 包启用,Release 包继续使用正式环境。
|
||||
if (applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0) {
|
||||
EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX)
|
||||
// EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX)
|
||||
}
|
||||
val alipay = PayTask(this@PayOrderActivity)
|
||||
val result = alipay.payV2(orderStr, true)
|
||||
|
||||
@@ -337,6 +337,7 @@ class OrderActivity : CKBaseActivity() {
|
||||
|
||||
toActivity(OrderSuccessActivity::class.java, DataCollection())
|
||||
finish()
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -361,7 +362,7 @@ class OrderActivity : CKBaseActivity() {
|
||||
|
||||
// [支付宝沙箱测试] 仅 Debug 包启用,Release 包继续使用正式环境。
|
||||
if (applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0) {
|
||||
EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX)
|
||||
// EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX)
|
||||
}
|
||||
val alipay = PayTask(this@OrderActivity)
|
||||
val result = alipay.payV2(orderStr, true)
|
||||
|
||||
@@ -78,7 +78,9 @@ object TTHttpClient {
|
||||
val string = response.body?.string()
|
||||
string?.let { TTLog.e("response", actionCode + "====" + it) }
|
||||
var model = JSONObject(string)
|
||||
if (isSusscee(model)) {
|
||||
// A withdrawal code of 201 means the transfer bill was created
|
||||
// and the client must continue with WeChat confirmation.
|
||||
if (isSusscee(model) || (actionCode == "提现" && getCode(model) == "201")) {
|
||||
activity.runOnUiThread {
|
||||
activity.hiddenProgeassDialog()
|
||||
iCallback.onSuccess(getData(model))
|
||||
@@ -137,7 +139,10 @@ object TTHttpClient {
|
||||
val string = response.body?.string()
|
||||
string?.let { TTLog.e("response", actionCode + "====" + it) }
|
||||
var model = JSONObject(string)
|
||||
if (isSusscee(model)) {
|
||||
// code 201 means the withdrawal bill was created and the
|
||||
// client must continue with WeChat confirmation. Keep the
|
||||
// response data available to the withdrawal screen.
|
||||
if (isSusscee(model) || (actionCode == "提现" && getCode(model) == "201")) {
|
||||
activity.runOnUiThread {
|
||||
activity.hiddenProgeassDialog()
|
||||
iCallback.onSuccess(getData(model))
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.ck.ckcollar.app.CKApp
|
||||
import com.ck.ckcollar.app.ui.act.balance.WithDrawActivity
|
||||
import com.ck.ckcollar.app.ui.act.login.LoginActivity
|
||||
import com.ck.ckcollar.app.ui.act.user.UserInfoActivity
|
||||
import com.ck.ckcollar.app.utils.Const
|
||||
@@ -15,6 +16,7 @@ import com.tencent.mm.opensdk.openapi.IWXAPI
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory
|
||||
import com.tt.kit.utils.TTLog
|
||||
import com.tt.kit.utils.LiveDataBus
|
||||
|
||||
|
||||
class WXEntryActivity : Activity(), IWXAPIEventHandler {
|
||||
@@ -43,6 +45,13 @@ class WXEntryActivity : Activity(), IWXAPIEventHandler {
|
||||
}
|
||||
|
||||
override fun onResp(resp: BaseResp?) {
|
||||
if (resp?.type == ConstantsAPI.COMMAND_OPEN_BUSINESS_VIEW) {
|
||||
LiveDataBus.get()
|
||||
.with(WithDrawActivity.WX_WITHDRAW_RESULT)
|
||||
.value = resp.errCode
|
||||
finish()
|
||||
return
|
||||
}
|
||||
if (resp!!.getType() === ConstantsAPI.COMMAND_SENDAUTH) {
|
||||
val authResp = resp as SendAuth.Resp
|
||||
val code = authResp.code
|
||||
@@ -59,4 +68,4 @@ class WXEntryActivity : Activity(), IWXAPIEventHandler {
|
||||
}
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.ck.ckcollar.app.ui.act.balance.RechargeActivity
|
||||
import com.ck.ckcollar.app.utils.Const
|
||||
import com.tencent.mm.opensdk.modelbase.BaseReq
|
||||
import com.tencent.mm.opensdk.modelbase.BaseResp
|
||||
import com.tencent.mm.opensdk.constants.ConstantsAPI
|
||||
import com.ck.ckcollar.app.ui.act.balance.WithDrawActivity
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory
|
||||
@@ -32,6 +34,11 @@ class WXPayEntryActivity : Activity(), IWXAPIEventHandler {
|
||||
|
||||
override fun onResp(resp: BaseResp?) {
|
||||
val resultCode = resp?.errCode ?: -1
|
||||
if (resp?.type == ConstantsAPI.COMMAND_OPEN_BUSINESS_VIEW) {
|
||||
LiveDataBus.get().with(WithDrawActivity.WX_WITHDRAW_RESULT).value = resultCode
|
||||
finish()
|
||||
return
|
||||
}
|
||||
val message = when (resultCode) {
|
||||
BaseResp.ErrCode.ERR_OK -> "微信支付成功"
|
||||
BaseResp.ErrCode.ERR_USER_CANCEL -> "已取消微信支付"
|
||||
|
||||
@@ -183,7 +183,7 @@
|
||||
android:layout_marginTop="50dp"
|
||||
android:background="@drawable/bg_login_button"
|
||||
android:text="@string/apply_withdraw"
|
||||
android:textColor="@color/buttonTextColor"></com.ck.ckcollar.app.widget.CKButton>
|
||||
android:textColor="@color/buttonTextColor"/>
|
||||
|
||||
|
||||
</com.ck.ckcollar.app.widget.CKLinearLayout>
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
android:layout_marginTop="200dp">
|
||||
<ImageView
|
||||
android:id="@+id/img_noresult"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="150dp"
|
||||
android:src="@mipmap/icon_no_result"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
<TextView
|
||||
android:id="@+id/tv_noresult"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/img_noresult"
|
||||
android:layout_marginTop="50dp"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/color_999999"
|
||||
android:text="暂无结果"
|
||||
android:layout_below="@+id/img_noresult"
|
||||
android:layout_centerHorizontal="true"/>
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/icon_no_result.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/icon_no_result.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 62 KiB |
Reference in New Issue
Block a user