萝莉来了 v1.2.1版本的 MD5 值为:6055c21e001561c5b114d0da5b392fcb

以下内容为反编译后的 Iydpay.java 源代码,内容仅作参考


package cn.iyd.iydpay_apk;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.RemoteException;
import android.telephony.TelephonyManager;
import android.util.Log;
import cn.cmgame.sdk.e.f;
import cn.iyd.iydpay_apk.IPay;
import cn.iyd.pay.alipay.AlixDefine;
import com.infinit.MultimodeBilling.tools.MyApplication;
import com.infinit.multimode_billing5.net.MultimodeConfig;
import com.tencent.mm.sdk.message.RMsgInfoDB;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import joy.sdk.JoyNetworkManager;
import mm.purchasesdk.PurchaseCode;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Iydpay extends IPay.Stub {
    public static final String PAY_ALIPAY = "alipay-mobile";
    private static final String[] PAY_CARD = {"easyown", "cucard", "ctcard", "jiuyou", "junnet", "netease", "qqcard", "sndacard", "sohu", "tianhong", "tianxia", "wanmei", "zhengtu", "zongyou"};
    public static final String PAY_CCB_ICBC = "ICBC-WAP";
    public static final String PAY_CCB_WAP = "CCB-WAP";
    public static final String PAY_CMBCHINA = "CMBCHINA-WAP";
    public static final String PAY_CMG = "cmg";
    public static final String PAY_CMGOL = "cmgol";
    public static final String PAY_HUAFUBAO = "umpay_huafubao";
    public static final String PAY_IYDPAY = "sms";
    public static final String PAY_MMIAP = "iap";
    public static final String PAY_TELE = "telecom_iap";
    public static final String PAY_UNION = "union_pay_huajian_buyu";
    public static final String PAY_VAC = "unicom_iap";
    public static final String PAY_YEEPAY = "other_prepaid_card";
    public static final String VERSION = "1.0.01";
    public static final String ip = "http://joy-app.punchbox.org/billing/services";
    public static final String ip_orderpay = "http://z.iyd.cn/mobile/webServer/openPay";
    public static final String server_ip = "http://joy-app.punchbox.org/billing/services/?method=billing.getPaymentMethod&is_filter=1";
    IydBuffer iydbuffer;
    IydNet iydnet;
    Context mContext;
    String mData;
    String mServer_notity_url = null;
    int mNotity_delay = 0;
    boolean usecache = false;

    public boolean isPrepaidCard(String type) {
        Log.d("test", "isPrepaidCard;" + type);
        if (type == null) {
            return false;
        }
        for (int i = 0; i < PAY_CARD.length; i++) {
            if (type.equals(PAY_CARD[i])) {
                return true;
            }
        }
        return false;
    }

    public Iydpay(Context context) {
        this.mContext = context;
        this.iydbuffer = new IydBuffer(this.mContext);
        this.iydnet = new IydNet(this.mContext);
        log("[ iydpay ] version:1.0.01");
    }

    private void log(String msg) {
        Log.i("Iydpay", msg);
    }

    public void setData(String data) {
        this.mData = data;
        if (this.mData != null) {
            try {
                JSONObject job = new JSONObject(this.mData);
                this.mServer_notity_url = job.optString("url");
                this.mNotity_delay = job.optInt("sendDelay", 0);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    public String getNotityUrl() {
        return this.mServer_notity_url;
    }

    public int getNotity_delay() {
        return this.mNotity_delay;
    }

    public String getPayType(String payid) {
        if (payid != null) {
            String[] ss = split(payid, "-");
            Log.d("test", "length:" + ss.length);
            if (ss == null || ss.length != 2) {
                return null;
            }
            String type = ss[0];
            Log.d("test", "type:" + type);
            if (type.equals(PAY_IYDPAY)) {
                return PAY_IYDPAY;
            }
            if (type.equals(PAY_ALIPAY)) {
                return PAY_ALIPAY;
            }
            if (type.equals(PAY_HUAFUBAO)) {
                return PAY_HUAFUBAO;
            }
            if (type.equals(PAY_YEEPAY)) {
                return PAY_YEEPAY;
            }
            if (type.equals(PAY_MMIAP)) {
                return PAY_MMIAP;
            }
            if (type.equals(PAY_CMG)) {
                return PAY_CMG;
            }
            if (type.equals(PAY_CMGOL)) {
                return PAY_CMGOL;
            }
            if (type.equals(PAY_VAC)) {
                return PAY_VAC;
            }
            if (type.equals(PAY_TELE)) {
                return PAY_TELE;
            }
            if (type.equals(PAY_UNION)) {
                return PAY_UNION;
            }
            if (type.equals(PAY_CCB_WAP)) {
                return PAY_CCB_WAP;
            }
            if (type.equals(PAY_CCB_ICBC)) {
                return PAY_CCB_ICBC;
            }
            if (type.equals(PAY_CMBCHINA)) {
                return PAY_CMBCHINA;
            }
            if (isPrepaidCard(type)) {
                return type;
            }
        }
        return null;
    }

    public String getPayData(String payid) {
        if (this.mData == null || payid == null) {
            return null;
        }
        Log.d("test", "mData:" + this.mData);
        String[] ss = split(payid, "-");
        if (ss == null || ss.length != 2) {
            return null;
        }
        try {
            JSONArray array = new JSONObject(this.mData).getJSONObject("productList").getJSONArray("billingInfo");
            String type = ss[0];
            int n = Integer.valueOf(ss[1]).intValue();
            for (int i = 0; i < array.length(); i++) {
                if (array.getJSONObject(i).getString("type").equals(type)) {
                    return array.getJSONObject(i).getJSONArray("product").getJSONObject(n).toString();
                }
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public JSONObject getPayList_JSON(String mData) {
        try {
            JSONObject job = new JSONObject(mData);
            JSONArray array = job.getJSONObject("productList").getJSONArray("billingInfo");
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("helpInfo", job.getJSONObject("productList").getString("helpInfo"));
            JSONArray jSONArray = new JSONArray();
            for (int i = 0; i < array.length(); i++) {
                JSONObject jSONObject2 = new JSONObject();
                String type = array.getJSONObject(i).getString("type");
                jSONObject2.put("type", type);
                jSONObject2.put("title", array.getJSONObject(i).getString("title"));
                jSONObject2.put("desc", array.getJSONObject(i).getString("desc"));
                jSONObject2.put("promo_mode", array.getJSONObject(i).optInt("promo_mode", 0));
                try {
                    jSONObject2.put("estimated_result_time", array.getJSONObject(i).getInt("estimated_result_time"));
                } catch (Exception e) {
                }
                JSONArray temp = array.getJSONObject(i).getJSONArray("product");
                JSONArray jarray = new JSONArray();
                for (int j = 0; j < temp.length(); j++) {
                    JSONObject obj = new JSONObject();
                    obj.put("id", String.valueOf(type) + "-" + j);
                    obj.put("title", temp.getJSONObject(j).optString("title"));
                    obj.put("unit", temp.getJSONObject(j).optString("unit"));
                    obj.put("desc", temp.getJSONObject(j).optString("desc"));
                    obj.put("price", temp.getJSONObject(j).optInt("price"));
                    obj.put("promo_title", temp.getJSONObject(j).optString("promo_title"));
                    obj.put("promo_token", temp.getJSONObject(j).optInt("promo_token"));
                    obj.put("currency", temp.getJSONObject(j).optString("currency"));
                    obj.put(f.gR, temp.getJSONObject(j).optInt(f.gR));
                    if (type.equals(PAY_IYDPAY)) {
                        obj.put("notice", temp.getJSONObject(j).optString("notice"));
                        if (temp.getJSONObject(j).optString("notice") != null && !temp.getJSONObject(j).optString("notice").equals("")) {
                            jSONObject2.put("notice", temp.getJSONObject(j).optString("notice"));
                        }
                    }
                    jarray.put(obj);
                }
                if (jarray.length() > 0) {
                    jSONObject2.put("product", jarray);
                    jSONArray.put(jSONObject2);
                }
            }
            jSONObject.put("billingInfo", jSONArray);
            return jSONObject;
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    private String getType() {
        ConnectivityManager cm = (ConnectivityManager) this.mContext.getSystemService("connectivity");
        NetworkInfo info = cm.getActiveNetworkInfo();
        if (info == null || !info.isAvailable()) {
            return null;
        }
        return info.getExtraInfo();
    }

    private String getUpgradeInfo(String jsonData) {
        try {
            JSONObject job = new JSONObject(this.mData).getJSONObject("softwareUpgradeInfo");
            int status = job.getInt("status");
            if (status == 0) {
                return null;
            }
            return job.toString();
        } catch (JSONException e) {
            e.printStackTrace();
            return null;
        }
    }

    List<NameValuePair> makeCommonParams(List<NameValuePair> params) {
        IydpayUser umanager = IydpayUser.getInstance(this.mContext);
        if (!umanager.checkRegist()) {
            return null;
        }
        String operator = null;
        try {
            TelephonyManager tm = (TelephonyManager) this.mContext.getSystemService("phone");
            tm.getSubscriberId();
            operator = tm.getNetworkOperator();
            tm.getSimSerialNumber();
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        if (params == null) {
            try {
                params = new ArrayList<>();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        params.add(new BasicNameValuePair("merchant_id", umanager.getMerchantId()));
        params.add(new BasicNameValuePair("user_id", umanager.getUser()));
        params.add(new BasicNameValuePair("userId", umanager.getUser()));
        params.add(new BasicNameValuePair("channel_type", umanager.getChannelType()));
        params.add(new BasicNameValuePair("channel_id", umanager.getChannelId()));
        ParamsAdd(params, "imsi", "");
        ParamsAdd(params, "serialnumber", "");
        ParamsAdd(params, "sys_imsi", "");
        ParamsAdd(params, "sys_sn", "");
        ParamsAdd(params, "imsi_1", "");
        ParamsAdd(params, "sn_1", "");
        ParamsAdd(params, "imsi_2", "");
        ParamsAdd(params, "sn_2", "");
        String apn = getType();
        ParamsAdd(params, "apn", apn);
        ParamsAdd(params, "operator", operator);
        params.add(new BasicNameValuePair("model", Build.MODEL));
        params.add(new BasicNameValuePair("os", "android"));
        params.add(new BasicNameValuePair("os_version", Build.VERSION.SDK));
        params.add(new BasicNameValuePair("clientVersion", system.getVersionName(this.mContext)));
        params.add(new BasicNameValuePair("brand", Build.MANUFACTURER));
        params.add(new BasicNameValuePair("model_name", Build.PRODUCT));
        params.add(new BasicNameValuePair(AlixDefine.IMEI, system.getIMEI(this.mContext)));
        params.add(new BasicNameValuePair("phonenumber", system.getTelnumber(this.mContext)));
        params.add(new BasicNameValuePair("bundle_id", "2147317f-6fd9-4056-8c45-a9418817826d"));
        params.add(new BasicNameValuePair("upgrade_version", VERSION));
        params.add(new BasicNameValuePair("presets", "true"));
        params.add(new BasicNameValuePair("appid", umanager.getAppId()));
        return params;
    }

    private String getPayList(String jsonData) {
        String carrier = null;
        try {
            JSONObject jsonobject = new JSONObject(jsonData);
            carrier = jsonobject.optString("carrier");
        } catch (JSONException e2) {
            e2.printStackTrace();
        }
        List<NameValuePair> params = makeCommonParams(null);
        params.add(new BasicNameValuePair("method", "billing.getPaymentMethod"));
        params.add(new BasicNameValuePair("v", "2"));
        ParamsAdd(params, "carrier", carrier);
        try {
            JSONObject obj = new JSONObject(jsonData);
            Iterator<?> it = obj.keys();
            while (it.hasNext()) {
                String name = it.next().toString();
                String value = obj.getString(name);
                params.add(new BasicNameValuePair(name, value));
            }
            String s = this.iydnet.httpPostResponse(server_ip, params);
            if (s == null) {
                return null;
            }
            String ss = sequence(s);
            return ss != null ? ss : s;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    private void ParamsAdd(List<NameValuePair> params, String key, String value, String def) {
        if (params != null) {
            if (value != null) {
                def = value;
            }
            params.add(new BasicNameValuePair(key, def));
        }
    }

    private void ParamsAdd(List<NameValuePair> params, String key, String value) {
        ParamsAdd(params, key, value, "");
    }

    private String sequence(String s) {
        try {
            JSONObject jsonobject = new JSONObject(s);
            JSONArray jsonarray_old = jsonobject.getJSONObject("productList").getJSONArray("billingInfo");
            int[][] index = (int[][]) Array.newInstance((Class<?>) Integer.TYPE, jsonarray_old.length(), 2);
            for (int i = 0; i < jsonarray_old.length(); i++) {
                index[i][0] = i;
                index[i][1] = jsonarray_old.getJSONObject(i).getInt("order_by");
            }
            for (int i2 = 0; i2 < index.length - 1; i2++) {
                int min = i2;
                for (int j = i2 + 1; j < index.length; j++) {
                    if (index[j][1] < index[min][1]) {
                        min = j;
                    }
                }
                int temp0 = index[i2][0];
                int temp1 = index[i2][1];
                index[i2][0] = index[min][0];
                index[i2][1] = index[min][1];
                index[min][0] = temp0;
                index[min][1] = temp1;
            }
            JSONArray jsonarray_new = new JSONArray();
            for (int i3 = 0; i3 < jsonarray_old.length(); i3++) {
                jsonarray_new.put(jsonarray_old.getJSONObject(index[i3][0]));
            }
            jsonobject.getJSONObject("productList").remove("billingInfo");
            jsonobject.getJSONObject("productList").put("billingInfo", jsonarray_new);
            return jsonobject.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    private String getNetType(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context.getSystemService("connectivity");
        NetworkInfo info = cm.getActiveNetworkInfo();
        return (info == null || !info.isAvailable()) ? "" : info.getExtraInfo();
    }

    private String[] split(String src, String s) {
        if (src == null || s == null) {
            return null;
        }
        int n = src.lastIndexOf(s);
        if (n > -1) {
            try {
                String[] str = {src.substring(0, n), src.substring(n + 1)};
                return str;
            } catch (Exception e) {
            }
        }
        String[] str2 = {src};
        return str2;
    }

    public void setCache(boolean b) {
        this.usecache = b;
    }

    @Override
    public String getPayment(String json) throws RemoteException {
        JSONObject job;
        JSONObject list;
        if (json == null) {
            return null;
        }
        try {
            job = new JSONObject(json);
        } catch (JSONException e) {
            e = e;
        }
        try {
            String cache = job.optString("cache", null);
            job.remove("cache");
            String data = job.optString("iydpay-data", null);
            job.remove("iydpay-data");
            if (data != null) {
                String uuid = UUID.randomUUID().toString();
                job.put("uuid", uuid);
            }
            String key = job.toString();
            setData(null);
            if (data != null && !data.equals("")) {
                setData(data);
            } else if (this.usecache || (cache != null && cache.equals("true"))) {
                setData(this.iydbuffer.getBuffer(key));
            }
            if (this.mData == null) {
                setData(getPayList(key));
                list = getPayList_JSON(this.mData);
                if (list != null) {
                    this.iydbuffer.putBuffer(key, this.mData);
                }
            } else {
                list = getPayList_JSON(this.mData);
                if (list != null && data != null) {
                    this.iydbuffer.putBuffer(key, this.mData);
                }
            }
            if (list == null) {
                return null;
            }
            JSONObject temp = new JSONObject();
            try {
                temp.put(AlixDefine.data, list);
                temp.put("key", key);
                return temp.toString();
            } catch (JSONException e2) {
                e2.printStackTrace();
                return null;
            }
        } catch (JSONException e3) {
            e = e3;
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public String getQueryResults(String json_param) throws RemoteException {
        try {
            JSONObject obj = new JSONObject(json_param);
            String uuid = obj.getString("receipt");
            String verify_nums = obj.optString("verify_nums", "0");
            JSONObject temp = new JSONObject(uuid);
            String receipt_data = temp.getString("receipt_data");
            String type = temp.getString("type");
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("method", "billing.verifyReceipt"));
            params.add(new BasicNameValuePair("type", type));
            params.add(new BasicNameValuePair("receipt_data", receipt_data));
            params.add(new BasicNameValuePair("verify_nums", verify_nums));
            String result = this.iydnet.httpPostResponse("http://joy-app.punchbox.org/billing/services", params);
            JSONObject json_result = new JSONObject(result);
            int status = json_result.getInt("status");
            String result_message = "";
            String result_tip1 = null;
            String result_tip2 = null;
            int result_status = PurchaseCode.QUERY_FROZEN;
            switch (status) {
                case 0:
                    result_status = 1;
                    result_message = json_result.getJSONArray("messages").getJSONObject(0).getString(RMsgInfoDB.TABLE);
                    result_tip1 = json_result.getJSONArray("messages").getJSONObject(0).optString("tip1", null);
                    result_tip2 = json_result.getJSONArray("messages").getJSONObject(0).optString("tip2", null);
                    break;
                case PurchaseCode.LOADCHANNEL_ERR:
                    result_status = 0;
                    result_message = json_result.getJSONArray("errors").getJSONObject(0).getString(RMsgInfoDB.TABLE);
                    result_tip1 = json_result.getJSONArray("errors").getJSONObject(0).optString("tip1", null);
                    result_tip2 = json_result.getJSONArray("errors").getJSONObject(0).optString("tip2", null);
                    break;
                case MultimodeConfig.ERROR_SOFT_PERMISSION_NETWORK_STATE:
                    result_status = 2;
                    result_message = json_result.getJSONArray("errors").getJSONObject(0).getString(RMsgInfoDB.TABLE);
                    result_tip1 = json_result.getJSONArray("errors").getJSONObject(0).optString("tip1", null);
                    result_tip2 = json_result.getJSONArray("errors").getJSONObject(0).optString("tip2", null);
                    break;
                case PurchaseCode.QUERY_FROZEN:
                    result_status = -1;
                    break;
            }
            JSONObject json = new JSONObject();
            json.put(RMsgInfoDB.TABLE, result_message);
            if (result_tip1 != null) {
                json.put("tip1", result_tip1);
            }
            if (result_tip2 != null) {
                json.put("tip2", result_tip2);
            }
            json.put("receipt", uuid);
            json.put("status", result_status);
            return json.toString();
        } catch (Exception ex) {
            ex.printStackTrace();
            return null;
        }
    }

    @Override
    public String payOrder(String json_param) throws RemoteException {
        List<NameValuePair> params = makeCommonParams(null);
        try {
            JSONObject obj = new JSONObject(json_param);
            String orderId = obj.getString("order_id");
            double orderPrice = obj.getDouble("order_price");
            ParamsAdd(params, "orderId", orderId);
            ParamsAdd(params, "orderPrice", new StringBuilder().append(orderPrice).toString());
            String result = this.iydnet.httpPostResponse(ip_orderpay, params);
            log("url:http://z.iyd.cn/mobile/webServer/openPay");
            log("params:" + params);
            log("result:" + result);
            JSONObject json_result = new JSONObject(result);
            String status = json_result.getString("status");
            String result_message = json_result.getString("msg");
            int result_status = PurchaseCode.QUERY_FROZEN;
            if (status != null && status.length() != 0) {
                result_status = MyApplication.RESULT_SUCCESS.equals(status) ? 1 : JoyNetworkManager.TYPE_UNKNOWN.equals(status) ? 2 : "fail".equals(status) ? 0 : -1;
            }
            JSONObject json = new JSONObject();
            json.put(RMsgInfoDB.TABLE, result_message);
            json.put("status", result_status);
            return json.toString();
        } catch (Exception ex) {
            ex.printStackTrace();
            return null;
        }
    }

    @Override
    public String getPackageName() throws RemoteException {
        return this.mContext.getPackageName();
    }

    @Override
    public String getActivityName() throws RemoteException {
        return "cn.iyd.iydpay_apk.IydpayActivity";
    }

    @Override
    public boolean iydpayInit(String merchant_id, String app_id, String user_id) throws RemoteException {
        IydpayUser umanager = IydpayUser.getInstance(this.mContext);
        umanager.setMerchantId(merchant_id);
        umanager.setAppId(app_id);
        umanager.getVersion();
        umanager.getChannelType();
        umanager.getChannelId();
        if (user_id != null && !user_id.equals("")) {
            umanager.setUser(user_id);
            return true;
        }
        umanager.initUser();
        return true;
    }

    @Override
    public boolean checkRegist() {
        return IydpayUser.getInstance(this.mContext).checkRegist();
    }
}