移除AliPay代码

This commit is contained in:
zlzw 2022-12-05 14:18:17 +08:00
parent 8d8cff8d1b
commit a489a6d00d
3 changed files with 219 additions and 217 deletions

View File

@ -76,7 +76,7 @@ public class Constants {
public static final String PAY_BUY_COIN_ALI = "Charge.getAliOrder"; public static final String PAY_BUY_COIN_ALI = "Charge.getAliOrder";
public static final String PAY_BUY_COIN_WX = "Charge.getWxOrder"; public static final String PAY_BUY_COIN_WX = "Charge.getWxOrder";
public static final String PACKAGE_NAME_ALI = "com.eg.android.AlipayGphone";//支付宝的包名 // public static final String PACKAGE_NAME_ALI = "com.eg.android.AlipayGphone";//支付宝的包名
public static final String PACKAGE_NAME_WX = "com.tencent.mm";//微信的包名 public static final String PACKAGE_NAME_WX = "com.tencent.mm";//微信的包名
public static final String PACKAGE_NAME_QQ = "com.tencent.mobileqq";//QQ的包名 public static final String PACKAGE_NAME_QQ = "com.tencent.mobileqq";//QQ的包名
public static final String LAT = "lat"; public static final String LAT = "lat";
@ -289,5 +289,6 @@ public class Constants {
public static String isSetRemarkText = "";//修改的备注信息 public static String isSetRemarkText = "";//修改的备注信息
public static boolean isShowLiveDialog = false;//是否在直播间打开单聊 public static boolean isShowLiveDialog = false;//是否在直播间打开单聊
public static int firstInto = 0;// public static int firstInto = 0;//
public static long runTime = System.currentTimeMillis();
} }

View File

@ -295,21 +295,21 @@ public class PayPresenter {
if (mActivity == null || TextUtils.isEmpty(mServiceNameAli)|| TextUtils.isEmpty(mAliCallbackUrl)) { if (mActivity == null || TextUtils.isEmpty(mServiceNameAli)|| TextUtils.isEmpty(mAliCallbackUrl)) {
return; return;
} }
if (!CommonAppConfig.isAppExist(Constants.PACKAGE_NAME_ALI)) { // if (!CommonAppConfig.isAppExist(Constants.PACKAGE_NAME_ALI)) {
ToastUtil.show(R.string.coin_ali_not_install); // ToastUtil.show(R.string.coin_ali_not_install);
return; // return;
} // }
if (TextUtils.isEmpty(mAliPartner) || TextUtils.isEmpty(mAliSellerId) || TextUtils.isEmpty(mAliPrivateKey)) { if (TextUtils.isEmpty(mAliPartner) || TextUtils.isEmpty(mAliSellerId) || TextUtils.isEmpty(mAliPrivateKey)) {
ToastUtil.show(Constants.PAY_ALI_NOT_ENABLE); ToastUtil.show(Constants.PAY_ALI_NOT_ENABLE);
return; return;
} }
AliPayBuilder builder = new AliPayBuilder(mActivity, mAliPartner, mAliSellerId, mAliPrivateKey); // AliPayBuilder builder = new AliPayBuilder(mActivity, mAliPartner, mAliSellerId, mAliPrivateKey);
builder.setMoney(money); // builder.setMoney(money);
builder.setGoodsName(goodsName); // builder.setGoodsName(goodsName);
builder.setCallbackUrl(mAliCallbackUrl); // builder.setCallbackUrl(mAliCallbackUrl);
builder.setOrderParams(StringUtil.contact(mServiceNameAli, orderParams)); // builder.setOrderParams(StringUtil.contact(mServiceNameAli, orderParams));
builder.setPayCallback(mPayCallback); // builder.setPayCallback(mPayCallback);
builder.pay(); // builder.pay();
} }

View File

@ -22,213 +22,214 @@ import java.util.Map;
/** /**
* Created by cxf on 2017/9/21. * Created by cxf on 2017/9/21.
* 禁用支付宝
*/ */
@Deprecated
public class AliPayBuilder { public class AliPayBuilder {
//
private Activity mActivity; // private Activity mActivity;
private String mPartner;// 商户ID // private String mPartner;// 商户ID
private String mSellerId; // 商户收款账号 // private String mSellerId; // 商户收款账号
private String mPrivateKey; // 商户私钥pkcs8格式 // private String mPrivateKey; // 商户私钥pkcs8格式
private String mPayInfo;//支付宝订单信息 包括 商品信息订单签名签名类型 // private String mPayInfo;//支付宝订单信息 包括 商品信息订单签名签名类型
private String mGoodsName;//商品名称 // private String mGoodsName;//商品名称
private String mMoney;//要支付的金额 // private String mMoney;//要支付的金额
private String mOrderParams;//订单获取订单需要的参数 // private String mOrderParams;//订单获取订单需要的参数
private String mCallbackUrl;//支付宝充值回调地址 // private String mCallbackUrl;//支付宝充值回调地址
private PayHandler mPayHandler; // private PayHandler mPayHandler;
//
public AliPayBuilder(Activity activity, String partner, String sellerId, String privateKey) { // public AliPayBuilder(Activity activity, String partner, String sellerId, String privateKey) {
mActivity = new WeakReference<>(activity).get(); // mActivity = new WeakReference<>(activity).get();
mPartner = partner; // mPartner = partner;
mSellerId = sellerId; // mSellerId = sellerId;
mPrivateKey = privateKey; // mPrivateKey = privateKey;
} // }
//
public AliPayBuilder setMoney(String money) { // public AliPayBuilder setMoney(String money) {
mMoney = money; // mMoney = money;
return this; // return this;
} // }
//
public AliPayBuilder setGoodsName(String goodsName) { // public AliPayBuilder setGoodsName(String goodsName) {
mGoodsName = goodsName; // mGoodsName = goodsName;
return this; // return this;
} // }
//
public AliPayBuilder setOrderParams(String orderParams) { // public AliPayBuilder setOrderParams(String orderParams) {
mOrderParams = orderParams; // mOrderParams = orderParams;
return this; // return this;
} // }
//
//
public AliPayBuilder setPayCallback(PayCallback callback) { // public AliPayBuilder setPayCallback(PayCallback callback) {
mPayHandler = new PayHandler(callback); // mPayHandler = new PayHandler(callback);
return this; // return this;
} // }
//
public void setCallbackUrl(String callbackUrl) { // public void setCallbackUrl(String callbackUrl) {
mCallbackUrl = callbackUrl; // mCallbackUrl = callbackUrl;
} // }
//
/** // /**
* 从服务器端获取订单号,即下单 // * 从服务器端获取订单号,即下单
*/ // */
public void pay() { // public void pay() {
if (TextUtils.isEmpty(mOrderParams) || TextUtils.isEmpty(mMoney) || TextUtils.isEmpty(mGoodsName)|| TextUtils.isEmpty(mCallbackUrl)) { // if (TextUtils.isEmpty(mOrderParams) || TextUtils.isEmpty(mMoney) || TextUtils.isEmpty(mGoodsName)|| TextUtils.isEmpty(mCallbackUrl)) {
return; // return;
} // }
CommonHttpUtil.getAliOrder(mOrderParams, new HttpCallback() { // CommonHttpUtil.getAliOrder(mOrderParams, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
String orderInfo = createAliOrder(obj.getString("orderid"));//商品信息
String sign = getOrderSign(orderInfo);//订单签名
if (TextUtils.isEmpty(sign)) {
ToastUtil.show("商户私钥错误,订单签名失败");
return;
}
sign = urlEncode(sign);
String signType = "sign_type=\"RSA\"";//签名类型
mPayInfo = orderInfo + "&sign=\"" + sign + "\"&" + signType;
L.e("支付宝订单信息----->" + mPayInfo);
invokeAliPay();
}
}
@Override
public boolean showLoadingDialog() {
return true;
}
@Override
public Dialog createLoadingDialog() {
return DialogUitl.loadingDialog(mActivity);
}
});
}
/**
* 根据订单号和商品信息生成支付宝格式的订单信息
*
* @param orderId 服务器返回的订单号
* @return
*/
private String createAliOrder(String orderId) {
// 合作者身份ID
String orderInfo = "partner=" + "\"" + mPartner + "\"";
// 卖家支付宝账号
orderInfo += "&seller_id=" + "\"" + mSellerId + "\"";
// 商户网站唯一订单号
orderInfo += "&out_trade_no=" + "\"" + orderId + "\"";
// 商品名称
orderInfo += "&subject=" + "\"" + mGoodsName + "\"";
// 商品详情
orderInfo += "&body=" + "\"" + mGoodsName + "\"";
// 商品金额
orderInfo += "&total_fee=" + "\"" + mMoney + "\"";
// 服务器异步通知页面路径 //服务器异步通知页面路径 参数 notify_url如果商户没设定则不会进行该操作
orderInfo += "&notify_url=" + "\"" + mCallbackUrl + "\"";
// 接口名称 固定值
orderInfo += "&service=\"mobile.securitypay.pay\"";
// 支付类型 固定值
orderInfo += "&payment_type=\"1\"";
// 参数编码 固定值
orderInfo += "&_input_charset=\"utf-8\"";
// 设置未付款交易的超时时间
// 默认30分钟一旦超时该笔交易就会自动被关闭
// 取值范围1m15d
// m-分钟h-小时d-1c-当天无论交易何时创建都在0点关闭
// 该参数数值不接受小数点如1.5h可转换为90m
orderInfo += "&it_b_pay=\"30m\"";
// 支付宝处理完请求后当前页面跳转到商户指定页面的路径可空
orderInfo += "&return_url=\"m.alipay.com\"";
// 调用银行卡支付需配置此参数参与签名 固定值
// orderInfo += "&paymethod=\"expressGateway\"";
return orderInfo;
}
/**
* 根据订单信息生成订单的签名
*
* @param orderInfo 订单信息
* @return
*/
private String getOrderSign(String orderInfo) {
return SignUtils.sign(orderInfo, mPrivateKey);
}
/**
* 对订单签名进行urlencode转码
*
* @param sign 签名
* @return
*/
private String urlEncode(String sign) {
try {
sign = URLEncoder.encode(sign, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return sign;
}
/**
* 调用支付宝sdk
*/
private void invokeAliPay() {
// new Thread(new Runnable() {
// @Override // @Override
// public void run() { // public void onSuccess(int code, String msg, String[] info) {
//// PayTask alipay = new PayTask(mActivity); // if (code == 0 && info.length > 0) {
// //执行支付这是一个耗时操作最后返回支付的结果用handler发送到主线程 // JSONObject obj = JSON.parseObject(info[0]);
//// Map<String, String> result = alipay.payV2(mPayInfo, true); // String orderInfo = createAliOrder(obj.getString("orderid"));//商品信息
//// L.e("支付宝返回结果----->" + result); // String sign = getOrderSign(orderInfo);//订单签名
//// if (mPayHandler != null) { // if (TextUtils.isEmpty(sign)) {
//// Message msg = Message.obtain(); // ToastUtil.show("商户私钥错误,订单签名失败");
//// msg.obj = result; // return;
//// mPayHandler.sendMessage(msg); // }
//// } // sign = urlEncode(sign);
//// } // String signType = "sign_type=\"RSA\"";//签名类型
// }).start(); // mPayInfo = orderInfo + "&sign=\"" + sign + "\"&" + signType;
} // L.e("支付宝订单信息----->" + mPayInfo);
// invokeAliPay();
// }
private static class PayHandler extends Handler { // }
//
private PayCallback mPayCallback; // @Override
// public boolean showLoadingDialog() {
public PayHandler(PayCallback payCallback) { // return true;
mPayCallback = new WeakReference<>(payCallback).get(); // }
} //
// @Override
@Override // public Dialog createLoadingDialog() {
public void handleMessage(Message msg) { // return DialogUitl.loadingDialog(mActivity);
if (mPayCallback != null) { // }
@SuppressWarnings("unchecked") //
Map<String, String> result = (Map<String, String>) msg.obj; //
if ("9000".equals(result.get("resultStatus"))) { // });
mPayCallback.onSuccess(); // }
} else { //
mPayCallback.onFailed(); // /**
} // * 根据订单号和商品信息生成支付宝格式的订单信息
} // *
mPayCallback = null; // * @param orderId 服务器返回的订单号
} // * @return
} // */
// private String createAliOrder(String orderId) {
// // 合作者身份ID
// String orderInfo = "partner=" + "\"" + mPartner + "\"";
//
// // 卖家支付宝账号
// orderInfo += "&seller_id=" + "\"" + mSellerId + "\"";
//
// // 商户网站唯一订单号
// orderInfo += "&out_trade_no=" + "\"" + orderId + "\"";
//
// // 商品名称
// orderInfo += "&subject=" + "\"" + mGoodsName + "\"";
//
// // 商品详情
// orderInfo += "&body=" + "\"" + mGoodsName + "\"";
//
// // 商品金额
// orderInfo += "&total_fee=" + "\"" + mMoney + "\"";
//
// // 服务器异步通知页面路径 //服务器异步通知页面路径 参数 notify_url如果商户没设定则不会进行该操作
// orderInfo += "&notify_url=" + "\"" + mCallbackUrl + "\"";
//
// // 接口名称 固定值
// orderInfo += "&service=\"mobile.securitypay.pay\"";
//
// // 支付类型 固定值
// orderInfo += "&payment_type=\"1\"";
//
// // 参数编码 固定值
// orderInfo += "&_input_charset=\"utf-8\"";
//
// // 设置未付款交易的超时时间
// // 默认30分钟一旦超时该笔交易就会自动被关闭
// // 取值范围1m15d
// // m-分钟h-小时d-1c-当天无论交易何时创建都在0点关闭
// // 该参数数值不接受小数点如1.5h可转换为90m
// orderInfo += "&it_b_pay=\"30m\"";
//
// // 支付宝处理完请求后当前页面跳转到商户指定页面的路径可空
// orderInfo += "&return_url=\"m.alipay.com\"";
//
// // 调用银行卡支付需配置此参数参与签名 固定值
// // orderInfo += "&paymethod=\"expressGateway\"";
//
// return orderInfo;
// }
//
// /**
// * 根据订单信息生成订单的签名
// *
// * @param orderInfo 订单信息
// * @return
// */
// private String getOrderSign(String orderInfo) {
// return SignUtils.sign(orderInfo, mPrivateKey);
// }
//
// /**
// * 对订单签名进行urlencode转码
// *
// * @param sign 签名
// * @return
// */
// private String urlEncode(String sign) {
// try {
// sign = URLEncoder.encode(sign, "UTF-8");
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// }
// return sign;
// }
//
// /**
// * 调用支付宝sdk
// */
// private void invokeAliPay() {
//// new Thread(new Runnable() {
//// @Override
//// public void run() {
////// PayTask alipay = new PayTask(mActivity);
//// //执行支付这是一个耗时操作最后返回支付的结果用handler发送到主线程
////// Map<String, String> result = alipay.payV2(mPayInfo, true);
////// L.e("支付宝返回结果----->" + result);
////// if (mPayHandler != null) {
////// Message msg = Message.obtain();
////// msg.obj = result;
////// mPayHandler.sendMessage(msg);
////// }
////// }
//// }).start();
// }
//
//
// private static class PayHandler extends Handler {
//
// private PayCallback mPayCallback;
//
// public PayHandler(PayCallback payCallback) {
// mPayCallback = new WeakReference<>(payCallback).get();
// }
//
// @Override
// public void handleMessage(Message msg) {
// if (mPayCallback != null) {
// @SuppressWarnings("unchecked")
// Map<String, String> result = (Map<String, String>) msg.obj;
// if ("9000".equals(result.get("resultStatus"))) {
// mPayCallback.onSuccess();
// } else {
// mPayCallback.onFailed();
// }
// }
// mPayCallback = null;
// }
// }
} }