亲朋打僵尸 v1.0版本的 MD5 值为:027c73d6bc1ac0a24f96eaed77a689a4
以下内容为反编译后的 XqtPay.java 源代码,内容仅作参考
package com.xqt.now.paysdk;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.text.TextUtils;
import android.util.Log;
import com.alipay.android.AlixDefine;
import com.alipay.sdk.cons.a;
import com.alipay.sdk.cons.c;
import com.ipaynow.plugin.api.IpaynowPlugin;
import com.ipaynow.plugin.utils.PreSignMessageUtil;
import com.switfpass.pay.MainApplication;
import com.switfpass.pay.activity.PayPlugin;
import com.switfpass.pay.bean.RequestMsg;
import com.switfpass.pay.service.GetPrepayIdResult;
import com.switfpass.pay.utils.Constants;
import com.switfpass.pay.utils.Util;
import com.switfpass.pay.utils.XmlUtils;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONObject;
public class XqtPay {
private static final String GETORDERMESSAGE_URL = "http://www.zhifuka.net/gateway/mbphonepay/mbphonepay.asp?";
private static final String NOW = "nowpay";
private static final String WFT = "wftpay";
private static Activity activity;
public static String consumerId;
private static XqtPayListener listener;
public static String mhtOrderAmt;
public static String mhtOrderDetail;
public static String mhtOrderName;
public static String mhtOrderNo;
public static String notifyUrl;
private static String paydata;
public static String sign;
public static String superid;
private static Transit transit;
private static String mhtOrderType = "01";
private static String mhtCurrencyType = "156";
private static String mhtOrderStartTime = new SimpleDateFormat("yyyyMMddHHmmss", Locale.CHINA).format(new Date());
private static String mhtOrderTimeOut = "3600";
private static String mhtCharset = "UTF-8";
private static String mhtReserved = "cps";
public static String payChannelType = "13";
public interface XqtPayListener {
void error(String str);
void success(String str);
}
public static void Transit(Activity activity2, XqtPayListener listener2) {
listener = listener2;
activity = activity2;
prePayMessage();
if (consumerId == null || mhtOrderNo == null || mhtOrderName == null || mhtOrderAmt == null || mhtOrderDetail == null || notifyUrl == null || sign == null || superid == null || mhtOrderType == null || mhtCurrencyType == null || mhtOrderStartTime == null || mhtOrderTimeOut == null || mhtCharset == null || mhtReserved == null) {
listener.error("{\"msg\":\"参数不完整\"}");
return;
}
MyAsyncTask asyncTask = new MyAsyncTask();
asyncTask.execute("http://www.zhifuka.net/gateway/mbphonepay/mbphonepay.asp?customerid=" + consumerId + "&superid=" + superid + "&sdcustomno=" + mhtOrderNo + "&orderAmount=" + mhtOrderAmt + "¬iceurl=" + notifyUrl + "&mhtOrderName=" + gettest(mhtOrderName) + "&mhtOrderType=" + mhtOrderType + "&mhtOrderDetail=" + gettest(mhtOrderDetail) + "&mhtOrderTimeOut=" + mhtOrderTimeOut + "&mhtOrderStartTime=" + mhtOrderStartTime + "&mhtCharset=" + mhtCharset + "&payChannelType=" + payChannelType + "&mhtReserved=" + mhtReserved + "&version=2&sign=" + sign);
}
public static Transit gson(String str) {
transit = new Transit();
String str1 = "{\"Transit\":[" + str + "]}";
try {
JSONObject job = new JSONObject(str1);
JSONArray jay = job.getJSONArray("Transit");
for (int i = 0; i < jay.length(); i++) {
JSONObject temp = (JSONObject) jay.get(i);
transit.setState(temp.getString("state"));
try {
transit.setSdk(temp.getString("sdk"));
if (temp.getString("sdk").equals(NOW)) {
transit.setAppId(temp.getString("appId"));
transit.setMhtCharset(temp.getString("mhtCharset"));
transit.setMhtCurrencyType(temp.getString("mhtCurrencyType"));
transit.setMhtOrderAmt(temp.getString("mhtOrderAmt"));
transit.setMhtOrderDetail(temp.getString("mhtOrderDetail"));
transit.setMhtOrderName(temp.getString("mhtOrderName"));
transit.setMhtOrderNo(temp.getString("mhtOrderNo"));
transit.setMhtOrderStartTime(temp.getString("mhtOrderStartTime"));
transit.setMhtOrderTimeOut(temp.getString("mhtOrderTimeOut"));
transit.setMhtOrderType(temp.getString("mhtOrderType"));
transit.setMhtReserved(temp.getString("mhtReserved"));
transit.setMhtSignature(temp.getString("mhtSignature"));
transit.setMhtSignType(temp.getString("mhtSignType"));
transit.setNotifyUrl(temp.getString("notifyUrl"));
transit.setPayChannelType(temp.getString("payChannelType"));
} else if (temp.getString("sdk").equals(WFT)) {
transit.setBody(temp.getString("body"));
transit.setService(temp.getString("service"));
transit.setVersion(temp.getString("version"));
transit.setMch_id(temp.getString("mch_id"));
transit.setNotify_url(temp.getString("notify_url"));
transit.setNonce_str(temp.getString("nonce_str"));
transit.setOut_trade_no(temp.getString(Constants.P_OUT_TRADE_NO));
transit.setMch_create_ip(temp.getString("mch_create_ip"));
transit.setTotal_fee(temp.getString("total_fee"));
transit.setDevice_info(temp.getString("device_info"));
transit.setLimit_credit_pay(temp.getString("limit_credit_pay"));
transit.setSign(temp.getString(AlixDefine.sign));
}
} catch (Exception e) {
e.printStackTrace();
}
try {
transit.setMsg(temp.getString(c.b));
} catch (Exception e2) {
e2.printStackTrace();
}
}
return transit;
} catch (Exception e3) {
e3.printStackTrace();
return null;
}
}
private static void prePayMessage() {
PreSignMessageUtil preSign = new PreSignMessageUtil();
preSign.consumerId = consumerId;
preSign.mhtOrderNo = mhtOrderNo;
preSign.payChannelType = payChannelType;
preSign.mhtOrderName = mhtOrderName;
preSign.mhtOrderType = mhtOrderType;
preSign.mhtCurrencyType = mhtCurrencyType;
preSign.mhtOrderAmt = mhtOrderAmt;
preSign.mhtOrderDetail = mhtOrderDetail;
preSign.mhtOrderTimeOut = mhtOrderTimeOut;
preSign.mhtOrderStartTime = mhtOrderStartTime;
preSign.notifyUrl = notifyUrl;
preSign.mhtCharset = mhtCharset;
preSign.mhtReserved = mhtReserved;
}
private static String gettest(String str) {
String result = "";
for (int i = 0; i < str.length(); i++) {
int chr1 = str.charAt(i);
if (chr1 >= 19968 && chr1 <= 171941) {
result = String.valueOf(result) + "\\u" + Integer.toHexString(chr1);
} else {
result = String.valueOf(result) + str.charAt(i);
}
}
return URLEncoder.encode(result);
}
public static String ServerToClient(String str) {
StringBuffer sb = new StringBuffer();
try {
URL url = new URL(str);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
while (true) {
String temp = in.readLine();
if (temp != null) {
sb.append(temp);
} else {
in.close();
return new String(sb.toString().getBytes(), "UTF-8");
}
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
static class MyAsyncTask extends AsyncTask<String, Void, String> {
MyAsyncTask() {
}
@Override
public String doInBackground(String... arg0) {
return XqtPay.ServerToClient(arg0[0]);
}
@Override
public void onPostExecute(String result) {
super.onPostExecute((MyAsyncTask) result);
try {
XqtPay.transit = XqtPay.gson(result);
if (XqtPay.transit.getState().equals(a.e)) {
if (XqtPay.transit.getSdk().equals(XqtPay.NOW)) {
XqtPay.paydata = "appId=" + XqtPay.transit.getAppId() + "&mhtCharset=" + XqtPay.transit.getMhtCharset() + "&mhtCurrencyType=" + XqtPay.transit.getMhtCurrencyType() + "&mhtOrderAmt=" + XqtPay.transit.getMhtOrderAmt() + "&mhtOrderDetail=" + XqtPay.transit.getMhtOrderDetail() + "&mhtOrderName=" + XqtPay.transit.getMhtOrderName() + "&mhtOrderNo=" + XqtPay.transit.getMhtOrderNo() + "&mhtOrderStartTime=" + XqtPay.transit.getMhtOrderStartTime() + "&mhtOrderTimeOut=" + XqtPay.transit.getMhtOrderTimeOut() + "&mhtOrderType=" + XqtPay.transit.getMhtOrderType() + "&mhtReserved=" + XqtPay.transit.getMhtReserved() + "¬ifyUrl=" + XqtPay.transit.getNotifyUrl() + "&payChannelType=" + XqtPay.transit.getPayChannelType();
IpaynowPlugin.setShowConfirmDialog(false);
XqtPay.listener.success(String.valueOf(XqtPay.paydata) + "&mhtSignature=" + XqtPay.transit.getMhtSignature() + "&mhtSignType=" + XqtPay.transit.getMhtSignType());
} else if (XqtPay.transit.getSdk().equals(XqtPay.WFT)) {
XqtPay.listener.error("{\"msg\":\"(忽略此提示)\"}");
new GetPrepayIdTask().execute(new Void[0]);
}
} else {
XqtPay.listener.error("{\"msg\":\"" + XqtPay.transit.getMsg() + "\",\"result\":" + result + "}");
}
} catch (Exception e) {
e.printStackTrace();
XqtPay.listener.error("{\"msg\":\"服务器内部错误\",\"result\":" + result + "}");
}
}
}
public static class GetPrepayIdTask extends AsyncTask<Void, Void, Map<String, String>> {
private String accessToken;
private ProgressDialog dialog;
public GetPrepayIdTask(String accessToken) {
this.accessToken = accessToken;
}
public GetPrepayIdTask() {
}
@Override
protected void onPreExecute() {
this.dialog = ProgressDialog.show(XqtPay.activity, "提示", "正在获取预支付订单...");
}
@Override
public void onPostExecute(Map<String, String> result) {
if (this.dialog != null) {
this.dialog.dismiss();
}
if (result == null || !result.get(c.a).equalsIgnoreCase("0")) {
XqtPay.listener.error("{\"msg\":\"获取prepayid失败\"}");
return;
}
RequestMsg msg = new RequestMsg();
msg.setMoney(Double.parseDouble(XqtPay.transit.getTotal_fee()));
msg.setTokenId(result.get("token_id"));
msg.setOutTradeNo(XqtPay.transit.getOut_trade_no());
msg.setTradeType(MainApplication.PAY_WX_WAP);
PayPlugin.unifiedH5Pay(XqtPay.activity, msg);
}
@Override
protected void onCancelled() {
super.onCancelled();
}
@Override
public Map<String, String> doInBackground(Void... params) {
String entity = getParams();
GetPrepayIdResult result = new GetPrepayIdResult();
byte[] buf = Util.httpPost("https://paya.swiftpass.cn/pay/gateway", entity);
if (buf == null || buf.length == 0) {
return null;
}
String content = new String(buf);
result.parseFrom(content);
try {
return XmlUtils.parse(content);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private String getParams() {
Map<String, String> params = new HashMap<>();
params.put("body", XqtPay.transit.getBody());
params.put("service", XqtPay.transit.getService());
params.put("version", XqtPay.transit.getVersion());
params.put("mch_id", XqtPay.transit.getMch_id());
params.put("notify_url", XqtPay.transit.getNotify_url());
params.put("nonce_str", XqtPay.transit.getNonce_str());
params.put(Constants.P_OUT_TRADE_NO, XqtPay.transit.getOut_trade_no());
params.put("mch_create_ip", XqtPay.transit.getMch_create_ip());
params.put("total_fee", XqtPay.transit.getTotal_fee());
params.put("device_info", XqtPay.transit.getDevice_info());
params.put("limit_credit_pay", XqtPay.transit.getLimit_credit_pay());
params.put(AlixDefine.sign, XqtPay.transit.getSign());
return XmlUtils.toXml(params);
}
}
public static String PayResult(Intent data) {
String respCode_now = data.getExtras().getString("respCode");
String respCode_wft = data.getExtras().getString("resultCode");
Log.e("HH", respCode_now);
if (respCode_now != null && respCode_wft == null) {
String respMsg = data.getExtras().getString("respMsg");
if (respCode_now.equals("00")) {
return "00";
}
if (respCode_now.equals("02")) {
return "02";
}
if (respCode_now.equals("01")) {
return "交易状态:失败\n原因:" + respMsg;
}
if (respCode_now.equals("03")) {
return "交易状态:未知\n原因:" + respMsg;
}
} else if (respCode_now == null && respCode_wft != null) {
if (!TextUtils.isEmpty(respCode_wft) && respCode_wft.equalsIgnoreCase("success")) {
return "00";
}
return "02";
}
return "NULL";
}
}