Commit 58f6aada authored by mengcuiguang's avatar mengcuiguang

添加微信预签约逻辑

parent 0cac0b81
......@@ -50,6 +50,7 @@ public class WxPayParamBean implements Serializable {
private String prepayid;
private String noncestr;
private String timestamp;
private String pre_entrustweb_id;
private String params;
private boolean agreement;//true-走自动签约
......@@ -106,6 +107,14 @@ public class WxPayParamBean implements Serializable {
return timestamp;
}
public String getPre_entrustweb_id() {
return pre_entrustweb_id;
}
public void setPre_entrustweb_id(String pre_entrustweb_id) {
this.pre_entrustweb_id = pre_entrustweb_id;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
......
......@@ -477,6 +477,8 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
val wxPay: WXPay = WXPay.getInstance()
//构造微信订单实体。一般都是由服务端直接返回。
val wxPayInfoImpl = WXPayInfoImpl()
wxPayInfoImpl.payModel = payToModel
wxPayInfoImpl.pre_entrustweb_id = data.pre_entrustweb_id
wxPayInfoImpl.timestamp = data.timestamp
wxPayInfoImpl.sign = data.sign
wxPayInfoImpl.prepayId = data.prepayid
......@@ -623,7 +625,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
private fun ruleAgreementPayDialog() {
if (vipList != null && vipList!!.size > 0) {
val vipBean = vipList!![vipAdapter.getPosition()]
ruleAgreementDialog = RuleAgreementDialog(context,payType, object : DialogListener() {
ruleAgreementDialog = RuleAgreementDialog(context, payType, object : DialogListener() {
override fun onClick(v: View) {
if (!isFinishing() && ruleAgreementDialog != null && ruleAgreementDialog!!.isShowing()) {
ruleAgreementDialog!!.dismiss()
......
......@@ -107,9 +107,8 @@ class VipAdapter(val vipList: MutableList<VipBean.ListBean>) :
// }
if(vipBean.price==0.0){
holder.tvVipItemCurMoney.text = SpanUtils()
.append("0.01")
.append("免费试用")
.setFontSize(BubbleUtils.sp2px(34))
.append("元")
.create()
}else{
holder.tvVipItemCurMoney.text = SpanUtils()
......
/*
******************************* Copyright (c)*********************************\
**
** (c) Copyright 2017, King, china
** All Rights Reserved
**
** By(King)
**
**------------------------------------------------------------------------------
*/
******************************* Copyright (c)*********************************\
**
** (c) Copyright 2017, King, china
** All Rights Reserved
**
** By(King)
**
**------------------------------------------------------------------------------
*/
package com.jobo.wxpay;
import android.app.Activity;
......@@ -18,10 +18,13 @@ import com.jobo.rxpay.base.IPayStrategy;
import com.jobo.rxpay.callback.IPayCallback;
import com.tencent.mm.opensdk.constants.Build;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.modelbiz.WXOpenBusinessWebview;
import com.tencent.mm.opensdk.modelpay.PayReq;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import java.util.HashMap;
/**
* @Desc:
* @author: admin wsj
......@@ -40,10 +43,10 @@ public class WXPay implements IPayStrategy<WXPayInfoImpl> {
}
public static WXPay getInstance(){
if(mWXPay == null){
synchronized (WXPay.class){
if(mWXPay == null) {
public static WXPay getInstance() {
if (mWXPay == null) {
synchronized (WXPay.class) {
if (mWXPay == null) {
mWXPay = new WXPay();
}
}
......@@ -66,11 +69,11 @@ public class WXPay implements IPayStrategy<WXPayInfoImpl> {
this.payInfoImpli = payInfo;
sPayCallback = payCallback;
if(payInfoImpli == null || TextUtils.isEmpty(payInfoImpli.getAppid()) || TextUtils.isEmpty(payInfoImpli.getPartnerid())
if (payInfoImpli == null || TextUtils.isEmpty(payInfoImpli.getAppid()) || TextUtils.isEmpty(payInfoImpli.getPartnerid())
|| TextUtils.isEmpty(payInfoImpli.getPrepayId()) || TextUtils.isEmpty(payInfoImpli.getPackageValue()) ||
TextUtils.isEmpty(payInfoImpli.getNonceStr()) || TextUtils.isEmpty(payInfoImpli.getTimestamp()) ||
TextUtils.isEmpty(payInfoImpli.getSign())) {
if(payCallback != null) {
if (payCallback != null) {
payCallback.failed(WXErrCodeEx.CODE_ILLEGAL_ARGURE, WXErrCodeEx.getMessageByCode(WXErrCodeEx.CODE_ILLEGAL_ARGURE));
}
return;
......@@ -80,13 +83,24 @@ public class WXPay implements IPayStrategy<WXPayInfoImpl> {
initWXApi(activity.getApplicationContext(), payInfoImpli.getAppid());
}
if(!check()) {
if(payCallback != null) {
if (!check()) {
if (payCallback != null) {
payCallback.failed(WXErrCodeEx.CODE_UNSUPPORT, WXErrCodeEx.getMessageByCode(WXErrCodeEx.CODE_UNSUPPORT));
}
return;
}
int payModel = payInfoImpli.getPayModel();
if (payModel == 1) {
// 纯签约
WXOpenBusinessWebview.Req wreq = new WXOpenBusinessWebview.Req();
wreq.businessType = 12;//固定值
HashMap queryInfo = new HashMap<>();
queryInfo.put("pre_entrustweb_id", payInfoImpli.getPre_entrustweb_id());
wreq.queryInfo = queryInfo;
mWXApi.sendReq(wreq);
} else {
PayReq req = new PayReq();
req.appId = payInfoImpli.getAppid();
req.partnerId = payInfoImpli.getPartnerid();
......@@ -95,23 +109,23 @@ public class WXPay implements IPayStrategy<WXPayInfoImpl> {
req.nonceStr = payInfoImpli.getNonceStr();
req.timeStamp = payInfoImpli.getTimestamp();
req.sign = payInfoImpli.getSign();
mWXApi.sendReq(req);
}
}
/**
* 支付回调响应
*/
public void onResp(int errorCode, String errorMsg) {
if(sPayCallback == null) {
if (sPayCallback == null) {
return;
}
if(errorCode == BaseResp.ErrCode.ERR_OK) {
if (errorCode == BaseResp.ErrCode.ERR_OK) {
sPayCallback.success();
} else if(errorCode == BaseResp.ErrCode.ERR_COMM) {
} else if (errorCode == BaseResp.ErrCode.ERR_COMM) {
sPayCallback.failed(errorCode, errorMsg);
} else if(errorCode == BaseResp.ErrCode.ERR_USER_CANCEL) {
} else if (errorCode == BaseResp.ErrCode.ERR_USER_CANCEL) {
sPayCallback.cancel();
} else {
sPayCallback.failed(errorCode, errorMsg);
......
......@@ -35,6 +35,9 @@ public class WXPayInfoImpl implements IPayInfo {
private String appid;
private String nonceStr;
private String prepayId;
private String businessType;
private String pre_entrustweb_id;
private int payModel;
public String getSign() {
return sign;
......@@ -92,4 +95,27 @@ public class WXPayInfoImpl implements IPayInfo {
this.prepayId = prepayId;
}
public String getBusinessType() {
return businessType;
}
public void setBusinessType(String businessType) {
this.businessType = businessType;
}
public String getPre_entrustweb_id() {
return pre_entrustweb_id;
}
public void setPre_entrustweb_id(String pre_entrustweb_id) {
this.pre_entrustweb_id = pre_entrustweb_id;
}
public int getPayModel() {
return payModel;
}
public void setPayModel(int payModel) {
this.payModel = payModel;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment