QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

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


package com.tencent.mtt.qbpay;

import android.app.Activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.ViewGroup;
import android.webkit.ValueCallback;
import com.tencent.common.http.MttRequestBase;
import com.tencent.common.http.MttResponse;
import com.tencent.common.http.Requester;
import com.tencent.common.http.RequesterFactory;
import com.tencent.common.manifest.annotation.CreateMethod;
import com.tencent.common.manifest.annotation.ServiceImpl;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.ilive.opensdk.params.RtcMediaConstants;
import com.tencent.midas.api.APMidasPayAPI;
import com.tencent.midas.api.APMidasResponse;
import com.tencent.midas.api.IAPMidasPayCallBack;
import com.tencent.midas.api.request.APMidasGoodsRequest;
import com.tencent.mtt.account.base.IAccount;
import com.tencent.mtt.base.account.AccountConst;
import com.tencent.mtt.base.account.AccountInfo;
import com.tencent.mtt.base.account.facade.IOpenMonthRechargeRequest;
import com.tencent.mtt.base.account.facade.OpenPlatformMonthRechargeInfo;
import com.tencent.mtt.base.functionwindow.ActivityHandler;
import com.tencent.mtt.base.wup.GUIDManager;
import com.tencent.mtt.browser.business.IBusinessPayService;
import com.tencent.mtt.browser.business.OpenPlatformPayRechargeInfo;
import com.tencent.mtt.browser.business.PayRechargeResult;
import com.tencent.mtt.browser.openplatform.facade.IMonthRechargeResult;
import com.tencent.mtt.browser.openplatform.facade.IOpenPlatformService;
import com.tencent.mtt.browser.window.UrlParams;
import com.tencent.mtt.businesscenter.facade.IFrameworkDelegate;
import com.tencent.mtt.commercial.business.util.Utils;
import com.tencent.mtt.log.access.Logs;
import com.tencent.mtt.qbcontext.core.QBContext;
import com.tencent.mtt.qbinfo.QUAUtils;
import com.tencent.mtt.qbpay.bottombar.BottomBarHippyRootView;
import com.tencent.mtt.qbpay.vip.VipDebugHelper;
import com.tencent.mtt.qbpay.vip.VipStateHolder;
import com.tencent.mtt.sdkcontext.SDKContext;
import com.tencent.qqlive.module.videoreport.constants.ParamKey;
import com.xiaomi.mipush.sdk.Constants;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.zip.GZIPInputStream;
import org.json.JSONException;
import org.json.JSONObject;

@ServiceImpl(createMethod = CreateMethod.GET, service = IBusinessPayService.class)
public class BusinessPayService implements IBusinessPayService {

    static BusinessPayService f69623a;

    private ValueCallback<PayRechargeResult> f69624b;

    private HippyPageListener f69625c;

    private BottomBarHippyRootView f69626d;
    private Set<IBusinessPayService.IRechargeStateCallback> e = new HashSet();

    private String a(OpenPlatformMonthRechargeInfo openPlatformMonthRechargeInfo) {
        return ((((((((("qb://rechargeh5?https://pay.qq.com/h5/index.shtml?&qb_subscribe") + "&ru=qbback") + "&continousmonth=1") + "&service_name=" + openPlatformMonthRechargeInfo.f31759d) + "&appid=" + openPlatformMonthRechargeInfo.f31756a) + "&service=" + openPlatformMonthRechargeInfo.f31758c) + "&groupid=" + openPlatformMonthRechargeInfo.j) + "&aid=" + openPlatformMonthRechargeInfo.k) + "&continuous_month_type=" + openPlatformMonthRechargeInfo.l) + "&channel=" + openPlatformMonthRechargeInfo.i;
    }

    private void a(APMidasGoodsRequest aPMidasGoodsRequest, AccountInfo accountInfo, OpenPlatformPayRechargeInfo openPlatformPayRechargeInfo) {
        StringBuilder sb;
        StringBuilder sb2;
        String str = "";
        if (accountInfo.mType == 1) {
            aPMidasGoodsRequest.openKey = accountInfo.skey;
            aPMidasGoodsRequest.sessionId = "uin";
            aPMidasGoodsRequest.sessionType = "skey";
            sb = new StringBuilder();
            sb.append("qqbrowser_m_qq-2001-android-2011-");
            sb.append(TextUtils.isEmpty(openPlatformPayRechargeInfo.e) ? "0000" : openPlatformPayRechargeInfo.e);
            if (!TextUtils.isEmpty(openPlatformPayRechargeInfo.h)) {
                sb2 = new StringBuilder();
                sb2.append(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
                sb2.append(openPlatformPayRechargeInfo.h);
                str = sb2.toString();
            }
        } else if (accountInfo.mType == 4) {
            aPMidasGoodsRequest.openKey = accountInfo.access_token;
            aPMidasGoodsRequest.sessionId = "openid";
            aPMidasGoodsRequest.sessionType = "kp_accesstoken";
            sb = new StringBuilder();
            sb.append("qqbrowser_m_qq-2001-android-2011-");
            sb.append(TextUtils.isEmpty(openPlatformPayRechargeInfo.e) ? "0000" : openPlatformPayRechargeInfo.e);
            if (!TextUtils.isEmpty(openPlatformPayRechargeInfo.h)) {
                sb2 = new StringBuilder();
                sb2.append(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
                sb2.append(openPlatformPayRechargeInfo.h);
                str = sb2.toString();
            }
        } else {
            aPMidasGoodsRequest.openKey = accountInfo.getQQorWxToken();
            aPMidasGoodsRequest.sessionId = "hy_gameid";
            aPMidasGoodsRequest.sessionType = "wc_actoken";
            sb = new StringBuilder();
            sb.append("qqbrowser_m_wx-2001-android-2011-");
            sb.append(TextUtils.isEmpty(openPlatformPayRechargeInfo.e) ? "0000" : openPlatformPayRechargeInfo.e);
            if (!TextUtils.isEmpty(openPlatformPayRechargeInfo.h)) {
                sb2 = new StringBuilder();
                sb2.append(Constants.ACCEPT_TIME_SEPARATOR_SERVER);
                sb2.append(openPlatformPayRechargeInfo.h);
                str = sb2.toString();
            }
        }
        sb.append(str);
        aPMidasGoodsRequest.pf = sb.toString();
    }

    private void a(IBusinessPayService.IQueryVipStatusCallback iQueryVipStatusCallback, int i) {
        if (iQueryVipStatusCallback != null) {
            iQueryVipStatusCallback.a(i);
        }
    }

    public static synchronized BusinessPayService getInstance() {
        BusinessPayService businessPayService;
        synchronized (BusinessPayService.class) {
            if (f69623a == null) {
                f69623a = new BusinessPayService();
            }
            businessPayService = f69623a;
        }
        return businessPayService;
    }

    protected void a(IBusinessPayService.IQueryVipStatusCallback iQueryVipStatusCallback) {
        Requester requester = RequesterFactory.getRequester();
        MttRequestBase mttRequestBase = RequesterFactory.getMttRequestBase();
        mttRequestBase.setUrl("https://mem.kde.qq.com/cgi-bin/member/getmember");
        mttRequestBase.setMethod((byte) 1);
        mttRequestBase.setRequestType(MttRequestBase.REQUEST_NORMAL);
        mttRequestBase.addHeader("Content-Type", "application/json");
        try {
            AccountInfo currentUserInfo = ((IAccount) SDKContext.getInstance().getService(IAccount.class)).getCurrentUserInfo();
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("guid", GUIDManager.a().f());
            jSONObject.put("openId", currentUserInfo.openid);
            jSONObject.put("openIdType", (int) currentUserInfo.mType);
            jSONObject.put("qbid", currentUserInfo.qbId);
            jSONObject.put("qua", QUAUtils.a());
            jSONObject.put("accessToken", currentUserInfo.access_token);
            jSONObject.put(ParamKey.REPORT_KEY_OS, 1);
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("business", 0);
            jSONObject2.put("base", jSONObject);
            mttRequestBase.setPostData(jSONObject2.toString());
            MttResponse execute = requester.execute(mttRequestBase);
            int intValue = execute.getStatusCode().intValue();
            Logs.e("BusinessPayService", "queryVipStatus getStatusCode " + intValue);
            if (intValue == 200) {
                a(iQueryVipStatusCallback, execute);
            } else {
                a(iQueryVipStatusCallback, intValue);
            }
        } catch (Exception e) {
            Logs.e("BusinessPayService", "queryVipStatus e " + e);
            a(iQueryVipStatusCallback, -1);
        }
    }

    protected void a(IBusinessPayService.IQueryVipStatusCallback iQueryVipStatusCallback, MttResponse mttResponse) throws IOException, JSONException {
        JSONObject optJSONObject;
        BufferedReader bufferedReader = new BufferedReader("gzip".equals(mttResponse.getContentEncoding()) ? new InputStreamReader(new GZIPInputStream(mttResponse.getInputStream())) : new InputStreamReader(mttResponse.getInputStream()));
        StringBuilder sb = new StringBuilder();
        while (true) {
            String readLine = bufferedReader.readLine();
            if (readLine == null) {
                break;
            } else {
                sb.append(readLine);
            }
        }
        JSONObject jSONObject = new JSONObject(sb.toString());
        int optInt = jSONObject.optInt("code");
        JSONObject optJSONObject2 = jSONObject.optJSONObject("data");
        int optInt2 = (optJSONObject2 == null || (optJSONObject = optJSONObject2.optJSONObject(RtcMediaConstants.RtcRolesType.USER)) == null) ? 0 : optJSONObject.optInt("status");
        Logs.c("BusinessPayService", "queryVipStatus resultJson code = " + optInt + ", status = " + optInt2);
        if (optInt != 0) {
            a(iQueryVipStatusCallback, optInt);
            return;
        }
        boolean z = optInt2 == 1;
        VipDebugHelper.a();
        VipStateHolder.f69631a.a(z);
        if (iQueryVipStatusCallback != null) {
            iQueryVipStatusCallback.a(z);
        }
    }

    public void a(HippyPageListener hippyPageListener) {
        this.f69625c = hippyPageListener;
    }

    @Override
    public void closePayDialog() {
        Logs.c("BusinessPayService", "closePayDialog");
        HippyPageListener hippyPageListener = this.f69625c;
        if (hippyPageListener != null) {
            hippyPageListener.a();
        }
    }

    @Override
    public boolean getCachedVipState() {
        return VipStateHolder.f69631a.b();
    }

    @Override
    public void hidePayBottomBar() {
        BottomBarHippyRootView bottomBarHippyRootView = this.f69626d;
        if (bottomBarHippyRootView == null || !(bottomBarHippyRootView.getParent() instanceof ViewGroup)) {
            return;
        }
        ((ViewGroup) this.f69626d.getParent()).removeView(this.f69626d);
        this.f69626d = null;
    }

    @Override
    public void initVipState() {
        VipStateHolder.f69631a.a();
        queryVipStatus(null);
    }

    @Override
    public void payDialogOnResult(PayRechargeResult payRechargeResult) {
        Logs.c("BusinessPayService", "payDialogOnResult-code:" + payRechargeResult.f36090a);
        ValueCallback<PayRechargeResult> valueCallback = this.f69624b;
        if (valueCallback != null) {
            valueCallback.onReceiveValue(payRechargeResult);
        }
        for (IBusinessPayService.IRechargeStateCallback iRechargeStateCallback : this.e) {
            if (payRechargeResult.f36090a == 0) {
                iRechargeStateCallback.a();
            } else {
                iRechargeStateCallback.a(payRechargeResult.f36090a);
            }
        }
    }

    @Override
    public void queryVipStatus(final IBusinessPayService.IQueryVipStatusCallback iQueryVipStatusCallback) {
        BrowserExecutorSupplier.postForBackgroundTasks(new BrowserExecutorSupplier.BackgroundRunable() {
            @Override
            public void doRun() {
                BusinessPayService.this.a(iQueryVipStatusCallback);
            }
        });
    }

    @Override
    public void registerRechargeStateCallback(IBusinessPayService.IRechargeStateCallback iRechargeStateCallback) {
        this.e.add(iRechargeStateCallback);
    }

    @Override
    public void requestContinuousPayMonth(OpenPlatformMonthRechargeInfo openPlatformMonthRechargeInfo) {
        String a2 = a(openPlatformMonthRechargeInfo);
        Logs.c("BusinessPayService", "requestContinuousPayMonth-payUrl=" + a2 + ";--rechargeInfo=" + openPlatformMonthRechargeInfo);
        ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(new UrlParams(a2).d(true));
    }

    @Override
    public void requestPay(final ValueCallback<PayRechargeResult> valueCallback, OpenPlatformPayRechargeInfo openPlatformPayRechargeInfo) {
        try {
            Logs.c("BusinessPayService", "requestPay-rechargeInfo=" + openPlatformPayRechargeInfo);
            String str = TextUtils.isEmpty(openPlatformPayRechargeInfo.f) ? "release" : openPlatformPayRechargeInfo.f;
            APMidasGoodsRequest aPMidasGoodsRequest = new APMidasGoodsRequest();
            aPMidasGoodsRequest.offerId = openPlatformPayRechargeInfo.f36086a;
            aPMidasGoodsRequest.goodsTokenUrl = openPlatformPayRechargeInfo.f36089d;
            aPMidasGoodsRequest.acctType = "common";
            aPMidasGoodsRequest.tokenType = 1;
            if (!TextUtils.isEmpty(openPlatformPayRechargeInfo.f36087b)) {
                aPMidasGoodsRequest.saveValue = openPlatformPayRechargeInfo.f36087b;
            }
            aPMidasGoodsRequest.isCanChange = false;
            AccountInfo currentUserInfo = ((IAccount) SDKContext.getInstance().getService(IAccount.class)).getCurrentUserInfo();
            aPMidasGoodsRequest.openId = currentUserInfo.getQQorWxId();
            aPMidasGoodsRequest.pfKey = "pfKey";
            aPMidasGoodsRequest.zoneId = "1";
            a(aPMidasGoodsRequest, currentUserInfo, openPlatformPayRechargeInfo);
            if (!TextUtils.isEmpty(openPlatformPayRechargeInfo.g)) {
                aPMidasGoodsRequest.mpInfo.drmInfo = "month_group=" + openPlatformPayRechargeInfo.g;
            }
            Activity b2 = ActivityHandler.b().m().b();
            APMidasPayAPI.init(b2, aPMidasGoodsRequest);
            APMidasPayAPI.setEnv(str);
            APMidasPayAPI.setLogEnable(true);
            APMidasPayAPI.closeAll();
            Logs.c("BusinessPayService", "offerId: " + aPMidasGoodsRequest.offerId + " openId: " + aPMidasGoodsRequest.openId + " openKey: " + aPMidasGoodsRequest.openKey + " sessionId: " + aPMidasGoodsRequest.sessionId + " sessionType: " + aPMidasGoodsRequest.sessionType + " zoneId: " + aPMidasGoodsRequest.zoneId + " pf: " + aPMidasGoodsRequest.pf + " pfkey: " + aPMidasGoodsRequest.pfKey + " sessionId: " + aPMidasGoodsRequest.sessionId + " acctType: " + aPMidasGoodsRequest.acctType + " goodsTokenUrl: " + aPMidasGoodsRequest.goodsTokenUrl);
            APMidasPayAPI.launchPay(b2, aPMidasGoodsRequest, new IAPMidasPayCallBack() {
                @Override
                public void MidasPayCallBack(APMidasResponse aPMidasResponse) {
                    PayRechargeResult payRechargeResult = new PayRechargeResult();
                    payRechargeResult.f36090a = aPMidasResponse.resultCode;
                    payRechargeResult.f36092c = aPMidasResponse.realSaveNum;
                    payRechargeResult.f36091b = aPMidasResponse.resultMsg;
                    valueCallback.onReceiveValue(payRechargeResult);
                }

                @Override
                public void MidasPayNeedLogin() {
                    PayRechargeResult payRechargeResult = new PayRechargeResult();
                    payRechargeResult.f36090a = -3;
                    payRechargeResult.f36092c = 0;
                    payRechargeResult.f36091b = "need login";
                    valueCallback.onReceiveValue(payRechargeResult);
                }
            });
        } catch (Exception e) {
            PayRechargeResult payRechargeResult = new PayRechargeResult();
            payRechargeResult.f36090a = -4;
            payRechargeResult.f36091b = e.getMessage();
            valueCallback.onReceiveValue(payRechargeResult);
        }
    }

    @Override
    public void requestPayMonth(ValueCallback<IMonthRechargeResult> valueCallback, OpenPlatformMonthRechargeInfo openPlatformMonthRechargeInfo) {
        try {
            Logs.c("BusinessPayService", "requestPayMonth-rechargeInfo=" + openPlatformMonthRechargeInfo);
            IOpenPlatformService iOpenPlatformService = (IOpenPlatformService) QBContext.getInstance().getService(IOpenPlatformService.class);
            Activity currentActivity = Utils.getCurrentActivity();
            if (currentActivity == null) {
                Logs.e("BusinessPayService", "requestPayMonth-err-activity is null");
                return;
            }
            IOpenMonthRechargeRequest monthRechargeRequest = iOpenPlatformService.getMonthRechargeRequest(currentActivity);
            AccountInfo currentUserInfo = ((IAccount) SDKContext.getInstance().getService(IAccount.class)).getCurrentUserInfo();
            openPlatformMonthRechargeInfo.m = (TextUtils.isEmpty(openPlatformMonthRechargeInfo.m) || !openPlatformMonthRechargeInfo.m.equals(AccountConst.QUICK_LOGIN_QQ)) ? "wechat" : APMidasPayAPI.PAY_CHANNEL_QQWALLET;
            monthRechargeRequest.a(valueCallback, openPlatformMonthRechargeInfo, currentUserInfo);
        } catch (Exception e) {
            Logs.e("BusinessPayService", "requestPayMonth-exception:" + e.getMessage());
        }
    }

    @Override
    public void showPayBottomBar(ViewGroup viewGroup) {
        Logs.c("BusinessPayService", "showPayBottomBar");
        BottomBarHippyRootView bottomBarHippyRootView = this.f69626d;
        if (bottomBarHippyRootView != null && (bottomBarHippyRootView.getParent() instanceof ViewGroup)) {
            ((ViewGroup) this.f69626d.getParent()).removeView(this.f69626d);
        }
        this.f69626d = new BottomBarHippyRootView(Utils.getCurrentActivity());
        viewGroup.addView(this.f69626d, new ViewGroup.LayoutParams(-1, -1));
    }

    @Override
    public void showPayDialog(String str, ValueCallback<PayRechargeResult> valueCallback) {
        Logs.c("BusinessPayService", "showPayDialog-hippUrl=" + str);
        try {
            this.f69624b = valueCallback;
            Bundle bundle = new Bundle();
            bundle.putString("jump_url", str);
            ((IFrameworkDelegate) QBContext.getInstance().getService(IFrameworkDelegate.class)).doLoad(new UrlParams("qb://business_pay_dialog?layoutfromtop=true").a(bundle).d(false));
        } catch (Exception e) {
            Logs.e("BusinessPayService", "showPayDialog-exception:" + e.getMessage());
        }
    }

    @Override
    public void unregisterRechargeStateCallback(IBusinessPayService.IRechargeStateCallback iRechargeStateCallback) {
        this.e.remove(iRechargeStateCallback);
    }
}