Search in sources :

Example 11 with PayTask

use of com.alipay.sdk.app.PayTask in project AgentWebX5 by Justson.

the class DefaultWebClient method isAlipay.

private boolean isAlipay(final android.webkit.WebView view, String url) {
    try {
        Activity mActivity = null;
        if ((mActivity = mWeakReference.get()) == null)
            return false;
        /**
         * 推荐采用的新的二合一接口(payInterceptorWithUrl),只需调用一次
         */
        if (mPayTask == null) {
            Class clazz = Class.forName("com.alipay.sdk.app.PayTask");
            Constructor<?> mConstructor = clazz.getConstructor(Activity.class);
            mPayTask = mConstructor.newInstance(mActivity);
        }
        final PayTask task = (PayTask) mPayTask;
        boolean isIntercepted = task.payInterceptorWithUrl(url, true, new H5PayCallback() {

            @Override
            public void onPayResult(final H5PayResultModel result) {
                final String url = result.getReturnUrl();
                if (!TextUtils.isEmpty(url)) {
                    AgentWebX5Utils.runInUiThread(new Runnable() {

                        @Override
                        public void run() {
                            view.loadUrl(url);
                        }
                    });
                }
            }
        });
        LogUtils.i(TAG, "alipay-isIntercepted:" + isIntercepted + "  url:" + url);
        return isIntercepted;
    } catch (Throwable ignore) {
        if (AgentWebX5Config.DEBUG) {
            ignore.printStackTrace();
        }
    }
    return false;
}
Also used : PayTask(com.alipay.sdk.app.PayTask) H5PayResultModel(com.alipay.sdk.util.H5PayResultModel) Activity(android.app.Activity) H5PayCallback(com.alipay.sdk.app.H5PayCallback)

Aggregations

PayTask (com.alipay.sdk.app.PayTask)11 Activity (android.app.Activity)5 DialogInterface (android.content.DialogInterface)4 Message (android.os.Message)4 H5PayResultModel (com.alipay.sdk.util.H5PayResultModel)3 AsyncTask (android.os.AsyncTask)2 H5PayCallback (com.alipay.sdk.app.H5PayCallback)2 BCPayResult (cn.beecloud.entity.BCPayResult)1 PayResult (com.litingzhe.justandroid.pay.utils.AliPayUtils.v1.PayResult)1 PayResultV2 (com.litingzhe.justandroid.pay.utils.AliPayUtils.v2.PayResultV2)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1