龙将斩千 v5.5.5.39856版本的 MD5 值为:5c05b1d6f8d872ca3fe0343d6ff07caf

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


package com.anysdk.framework;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import androidx.core.app.NotificationCompat;
import com.anysdk.Util.SdkHttpListener;
import com.anysdk.Util.a;
import com.anysdk.Util.e;
import com.anysdk.Util.i;
import com.qiyukf.nimlib.sdk.msg.model.RecentSession;
import com.yaya.sdk.constants.Constants;
import cz.msebera.android.httpclient.cookie.ClientCookie;
import java.lang.reflect.Method;
import java.util.Hashtable;
import org.json.JSONException;
import org.json.JSONObject;

public class IAPDebug implements InterfaceIAP {
    protected static String TAG = "IAPDebug";
    private IAPDebug mAdapter;
    private Context mContext;
    private final String SIMSDK_LOGIN_URL = "https://sim.qudao.info/account/login";
    private final String SIMSDK_PAY_URL = "https://sim.qudao.info/api/pay/exec";
    private boolean isInited = false;
    private String mUApiKey = "";
    private String mUApiSecret = "";
    private String mServerUrl = "";
    private String mOrderId = "";
    private Hashtable<String, String> mGoodsInfo = null;

    public IAPDebug(Context context) {
        this.mContext = null;
        this.mAdapter = null;
        this.mContext = context;
        this.mAdapter = this;
        configDeveloperInfo(Wrapper.getDeveloperInfo());
    }

    protected static void LogD(String str) {
        try {
            PluginHelper.logD(TAG, str);
        } catch (Exception e) {
            PluginHelper.logE(TAG, str, e);
        }
    }

    protected static void LogE(String str, Exception exc) {
        try {
            PluginHelper.logE(TAG, str, exc);
        } catch (Exception e) {
            PluginHelper.logE(TAG, str, e);
        }
    }

    public void addPayment(final String str, final float f) {
        final Context context = this.mContext;
        PluginWrapper.runOnMainThread(new Runnable() {
            @Override
            public void run() {
                try {
                    AlertDialog.Builder builder = new AlertDialog.Builder(context);
                    builder.setTitle(context.getResources().getIdentifier("plugin_pay", "string", IAPDebug.this.mContext.getPackageName()));
                    builder.setMessage(context.getResources().getIdentifier("plugin_pay_content", "string", IAPDebug.this.mContext.getPackageName()));
                    DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            switch (i) {
                                case -2:
                                    IAPDebug.this.payResult(2, "the pay has been canceled");
                                    return;
                                case -1:
                                    IAPDebug.this.pay(str, f);
                                    return;
                                default:
                                    return;
                            }
                        }
                    };
                    builder.setPositiveButton(IAPDebug.this.mContext.getResources().getIdentifier("plugin_pay", "string", IAPDebug.this.mContext.getPackageName()), onClickListener);
                    builder.setNegativeButton(IAPDebug.this.mContext.getResources().getIdentifier("plugin_cancel", "string", IAPDebug.this.mContext.getPackageName()), onClickListener).create();
                    builder.show();
                } catch (Exception e) {
                    IAPDebug.LogE("Error during payment", e);
                    IAPDebug.this.payResult(1, "Pay failed");
                }
            }
        });
    }

    private void configDeveloperInfo(Hashtable<String, String> hashtable) {
        PluginWrapper.runOnMainThread(new Runnable() {
            @Override
            public void run() {
                if (IAPDebug.this.isInited) {
                    return;
                }
                IAPDebug.this.isInited = true;
                IAPDebug.this.payResult(5, "init success");
            }
        });
    }

    public void getOrderId(Hashtable<String, String> hashtable) {
        Hashtable<String, String> orderInfo = IAPWrapper.getOrderInfo(hashtable, UserDebug.getSimUserId());
        if (orderInfo == null) {
            payResult(4, "something is null");
            return;
        }
        orderInfo.put("order_type", "999");
        LogD("orderInfo:" + orderInfo.toString());
        final float parseFloat = Float.parseFloat(orderInfo.get("money"));
        IAPWrapper.getPayOrderId(this.mContext, orderInfo, new SdkHttpListener() {
            @Override
            public void onError() {
                IAPDebug.this.payResult(3, null);
            }

            @Override
            public void onResponse(String str) {
                IAPDebug.LogD(str);
                try {
                    JSONObject jSONObject = new JSONObject(str);
                    String string = jSONObject.getString(NotificationCompat.CATEGORY_STATUS);
                    if (string == null || !string.equals("ok")) {
                        IAPDebug.this.payResult(1, null);
                        return;
                    }
                    JSONObject jSONObject2 = jSONObject.getJSONObject("data");
                    IAPDebug.this.mOrderId = jSONObject2.getString("order_id");
                    IAPDebug.this.addPayment(IAPDebug.this.mOrderId, parseFloat);
                } catch (JSONException e) {
                    e.printStackTrace();
                    IAPDebug.this.payResult(1, null);
                }
            }
        });
    }

    public boolean networkReachable() {
        boolean z = false;
        try {
            NetworkInfo activeNetworkInfo = ((ConnectivityManager) this.mContext.getSystemService("connectivity")).getActiveNetworkInfo();
            if (activeNetworkInfo != null) {
                z = activeNetworkInfo.isAvailable();
            }
        } catch (Exception e) {
            LogE("Fail to check network status", e);
        }
        LogD("NetWork reachable : " + z);
        return z;
    }

    public void pay(String str, float f) {
        Hashtable hashtable = new Hashtable();
        hashtable.put("user_id", UserDebug.getSimUserId());
        hashtable.put("session_id", UserDebug.getSimSessionId());
        hashtable.put("cp_order_id", str);
        hashtable.put("callback", a.d);
        hashtable.put("amount", String.valueOf(f));
        hashtable.put("server_url", "https://sim.qudao.info/api/pay/exec");
        i.c(this.mContext, hashtable, new SdkHttpListener() {
            @Override
            public void onError() {
                IAPDebug.this.payResult(3, "");
            }

            @Override
            public void onResponse(String str2) {
                PluginHelper.logD("onResponse", str2);
                try {
                    String string = new JSONObject(str2).getString(Constants.ERRREPORTREQ_ERRMSG);
                    if (string == null || !string.equals("success")) {
                        IAPDebug.this.payResult(1, "");
                    } else {
                        IAPDebug.this.payResult(0, "");
                    }
                } catch (JSONException e) {
                    IAPDebug.this.payResult(1, "");
                }
            }
        });
    }

    public void payLogin() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this.mContext);
        builder.setTitle(getResourceId("plugin_login_title", "string"));
        final View inflate = LayoutInflater.from(this.mContext).inflate(getResourceId("plugin_login", "layout"), (ViewGroup) null);
        builder.setView(inflate);
        DialogInterface.OnClickListener onClickListener = new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                IAPDebug iAPDebug;
                int i2;
                String str;
                switch (i) {
                    case -2:
                        UserDebug.setLoginState(false);
                        iAPDebug = IAPDebug.this;
                        i2 = 2;
                        str = "";
                        break;
                    case -1:
                        EditText editText = (EditText) inflate.findViewById(IAPDebug.this.getResourceId("txt_username", Constants.HELLOINFO_ID));
                        EditText editText2 = (EditText) inflate.findViewById(IAPDebug.this.getResourceId("txt_password", Constants.HELLOINFO_ID));
                        if (!editText.getText().toString().isEmpty() && !editText2.getText().toString().isEmpty()) {
                            IAPDebug.this.userLogin(editText.getText().toString(), editText2.getText().toString(), new ILoginCallback() {
                                @Override
                                public void onFailed(int i3, String str2) {
                                    UserDebug.setLoginState(false);
                                    IAPDebug.this.payResult(1, str2);
                                }

                                @Override
                                public void onSuccessed(int i3, String str2) {
                                    UserDebug.setLoginState(true);
                                    IAPDebug.this.startPay();
                                }
                            });
                            return;
                        }
                        iAPDebug = IAPDebug.this;
                        i2 = 1;
                        str = "username or password is empty";
                        break;
                    default:
                        return;
                }
                iAPDebug.payResult(i2, str);
            }
        };
        builder.setPositiveButton(getResourceId("plugin_login", "string"), onClickListener);
        builder.setNegativeButton(getResourceId("plugin_cancel", "string"), onClickListener).create();
        builder.setCancelable(false);
        builder.show();
    }

    public void payResult(int i, String str) {
        IAPWrapper.onPayResult(this.mAdapter, i, str);
        LogD("payResult : " + i + " msg : " + str);
    }

    public void userLogin(String str, String str2, final ILoginCallback iLoginCallback) {
        Hashtable hashtable = new Hashtable();
        hashtable.put("username", str);
        hashtable.put("password", str2);
        hashtable.put("server_url", "https://sim.qudao.info/account/login");
        i.c(this.mContext, hashtable, new SdkHttpListener() {
            @Override
            public void onError() {
                iLoginCallback.onFailed(5, "");
            }

            @Override
            public void onResponse(String str3) {
                PluginHelper.logD("onResponse", str3);
                try {
                    JSONObject jSONObject = new JSONObject(str3);
                    String string = jSONObject.getString(Constants.ERRREPORTREQ_ERRMSG);
                    if (string == null || !string.equals("success")) {
                        iLoginCallback.onFailed(5, "");
                        return;
                    }
                    JSONObject jSONObject2 = jSONObject.getJSONObject("data");
                    PluginHelper.logD("data", jSONObject2.toString());
                    UserDebug.setSimUserInfo(jSONObject2.getString("user_id"), jSONObject2.getString("session_id"));
                    Hashtable hashtable2 = new Hashtable();
                    hashtable2.put("channel", "simsdk");
                    hashtable2.put("server_url", IAPDebug.this.mServerUrl);
                    hashtable2.put("session_id", UserDebug.getSimSessionId());
                    hashtable2.put("user_id", UserDebug.getSimUserId());
                    UserWrapper.getAccessToken(IAPDebug.this.mContext, hashtable2, new SdkHttpListener() {
                        @Override
                        public void onError() {
                            iLoginCallback.onFailed(5, "");
                        }

                        @Override
                        public void onResponse(String str4) {
                            PluginHelper.logD("onResponse", str4);
                            try {
                                JSONObject jSONObject3 = new JSONObject(str4);
                                String string2 = jSONObject3.getString(NotificationCompat.CATEGORY_STATUS);
                                if (string2 == null || !string2.equals("ok")) {
                                    iLoginCallback.onFailed(5, "");
                                    return;
                                }
                                String optString = jSONObject3.optString(RecentSession.KEY_EXT);
                                if (optString == null) {
                                    optString = "";
                                }
                                iLoginCallback.onSuccessed(2, optString);
                            } catch (JSONException e) {
                                iLoginCallback.onFailed(5, "");
                            }
                        }
                    });
                } catch (JSONException e) {
                    iLoginCallback.onFailed(5, "");
                }
            }
        });
    }

    @Override
    public String getOrderId() {
        LogD("getOrderId() invoked!");
        return this.mOrderId;
    }

    @Override
    public String getPluginId() {
        LogD("getPluginId() invoked!");
        return "999999";
    }

    @Override
    public String getPluginVersion() {
        LogD("getPluginVersion() invoked!");
        return PluginWrapper.VERSION;
    }

    public int getResourceId(String str, String str2) {
        return this.mContext.getResources().getIdentifier(str, str2, this.mContext.getPackageName());
    }

    @Override
    public String getSDKVersion() {
        LogD("getSDKVersion() invoked!");
        return PluginWrapper.VERSION;
    }

    public boolean isFunctionSupported(String str) {
        LogD("isFunctionSupported(" + str + ")invoked!");
        for (Method method : getClass().getMethods()) {
            if (method.getName().equals(str)) {
                return true;
            }
        }
        return false;
    }

    public boolean isLogined() {
        return UserDebug.getLoginState();
    }

    @Override
    public void payForProduct(Hashtable<String, String> hashtable) {
        LogD("payForProduct(" + hashtable.toString() + ") invoked ");
        this.mGoodsInfo = hashtable;
        PluginWrapper.runOnMainThread(new Runnable() {
            @Override
            public void run() {
                if (!IAPDebug.this.networkReachable()) {
                    IAPDebug.this.payResult(3, "Network error!");
                    return;
                }
                if (IAPDebug.this.mGoodsInfo == null) {
                    IAPDebug.this.payResult(1, "info is null");
                } else if (IAPDebug.this.isLogined()) {
                    IAPDebug.this.startPay();
                } else {
                    IAPDebug.this.payLogin();
                }
            }
        });
    }

    @Override
    public void setDebugMode(boolean z) {
        LogD("setDebugMode(" + z + ") invoked!");
    }

    public void showDialog(final String str, final String str2) {
        final Context context = this.mContext;
        PluginWrapper.runOnMainThread(new Runnable() {
            @Override
            public void run() {
                new AlertDialog.Builder(context).setTitle(IAPDebug.this.getResourceId(str, "string")).setMessage(IAPDebug.this.getResourceId(str2, "string")).setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                    }
                }).create().show();
            }
        });
    }

    public void startPay() {
        if (!a.c.contains("youxiplus.cn")) {
            getOrderId(this.mGoodsInfo);
            return;
        }
        try {
            Hashtable<String, String> channelInfo = Wrapper.getChannelInfo();
            Hashtable hashtable = new Hashtable();
            hashtable.put("uapi_key", channelInfo.get("uApiKey"));
            new e(this.mContext).a(new SdkHttpListener() {
                @Override
                public void onError() {
                    IAPDebug.this.payResult(1, "get EE domain onError");
                }

                @Override
                public void onResponse(String str) {
                    try {
                        PluginHelper.logD("getEEDomain", str);
                        JSONObject jSONObject = new JSONObject(str);
                        String str2 = (String) jSONObject.opt(NotificationCompat.CATEGORY_STATUS);
                        if (str2 == null || !str2.equals("0")) {
                            IAPDebug.this.payResult(1, str);
                            return;
                        }
                        String str3 = (String) jSONObject.opt(ClientCookie.DOMAIN_ATTR);
                        if (str3 == null || str3.equals("")) {
                            IAPDebug.this.payResult(1, "please go to Client to set up the enterprise edition of the domain name");
                            return;
                        }
                        a.a = i.a(a.a, str3);
                        a.d = i.a(a.d, str3);
                        IAPDebug.this.getOrderId(IAPDebug.this.mGoodsInfo);
                    } catch (Exception e) {
                        PluginHelper.logE("getEEDomain", e.toString());
                        IAPDebug.this.payResult(1, "getEEDomain" + e.toString());
                    }
                }
            }, hashtable, a.c);
        } catch (Exception e) {
            PluginHelper.logE(TAG, "", e);
            payResult(1, "get EE domain fail");
        }
    }
}