> For the complete documentation index, see [llms.txt](https://docs.coda.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coda.co/https-coda-payments.gitbook.io-zhong-wen-coda-private-technical-documentation/codapay/webview-chang-jian-wen-ti.md).

# Webview常见问题

## 菲律宾GCASH，马来西亚Celcom等渠道出现拒绝访问页面

{% hint style="info" %}
📘 这些渠道只能在当地的IP地址下购买，无法从其他国家访问，测试时需要用VPN。
{% endhint %}

## 菲律宾webview点返回按钮页面报223，202，103等错误

Codapay部分页面不允许刷新，禁止webview返回刷新页面即可。可参考链接\[<https://blog.csdn.net/yushuangping/article/details/84957237>]

<figure><img src="https://files.readme.io/fdf9835-Snipaste_2022-06-22_14-45-45.png" alt=""><figcaption></figcaption></figure>

## “Back to Merchant” 按了没有反应

<figure><img src="https://files.readme.io/177e14d-Snipaste_2022-06-22_14-54-40.png" alt="" width="375"><figcaption></figcaption></figure>

这个支付完后跳转的页面其实是自动关闭的，只是在webview里页面调用windows.close()，系统发现当前只有一个窗口，导致windows.close()不起作用。

这时需要重写onCreateWindow() 和 onCloseWindow()函数：

{% tabs %}
{% tab title="Groovy" %}

```groovy
}@Override
            public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) {  //html中调用window.open()，会回调此函数
                DebugUtil.log("创建新窗口：" + isDialog + ";" + isUserGesture + ";"
                        + resultMsg);
                newWebView = new WebView(OAWebActivity.this); //新创建一个webview
                initWebView(newWebView);//初始化webview
                fl_web_activity.addView(newWebView); //把webview加载到activity界面上
                WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj; //以下的操作应该就是让新的webview去加载对应的url等操作。
                transport.setWebView(newWebView);
                resultMsg.sendToTarget();
                return true;
 
                // return super.onCreateWindow(view, isDialog, isUserGesture,
                // resultMsg);
            }

@Override
            public void onCloseWindow(WebView window) { //html中，用js调用.close(),会回调此函数
                super.onCloseWindow(window);
                DebugUtil.err("关闭当前窗口");
                if (newWebView != null) {
                    fl_web_activity.removeView(newWebView);
                }
```

{% endtab %}
{% endtabs %}

并在WebView中添加如下配置：

{% tabs %}
{% tab title="Groovy" %}

```groovy
WebSettings webSettings = wv.getSettings();
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持js调用window.open方法
webSettings.setSupportMultipleWindows(true);// 设置允许开启多窗口
webSettings.setJavaScriptEnabled(true);// 设置支持javascript
```

{% endtab %}
{% endtabs %}

## Dana 页面显示空白或“The network connection is unstable. Please try again later.”

打开DANA支付方式， 页面提示错误， 看到的现象是空白，实际页面比较大， 移动页面可以看到页面错误：“The network connection is unstable. Please try again later.”

<figure><img src="https://files.readme.io/d397f34-Snipaste_2022-06-28_18-28-03.png" alt="" width="375"><figcaption></figcaption></figure>

如果打开API容器是Android 的WebView，需要设置webView的WebSettings属性，代码如下

{% tabs %}
{% tab title="需要加的参数" %}

```groovy
package id.dana.app;

import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.WebView;

public class WebviewActivity extends AppCompatActivity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_webview);

        String url = "";

        WebView webView = findViewById(R.id.webview);

        webView.clearCache(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
            CookieManager.getInstance().removeAllCookies(null);
            CookieManager.getInstance().flush();
        } else {
            CookieSyncManager csm = CookieSyncManager.createInstance(this);
            csm.startSync();
            CookieManager cm=CookieManager.getInstance();
            cm.removeAllCookie();
            cm.removeSessionCookie();
            csm.stopSync();
            csm.sync();
        }

        webView.getSettings().setDomStorageEnabled(true);
        CookieManager.getInstance().setAcceptCookie(true);
        if (Build.VERSION.SDK_INT >= 21) {
            CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
        }
        webView.getSettings().setLoadsImagesAutomatically(true);
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setSupportZoom(true);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setUseWideViewPort(true);

        webView.loadUrl(url);

    }

}
```

{% endtab %}
{% endtabs %}

## Error 401 沙盒测试 Webview <401Authorization Required>

有些渠道在沙盒环境测试时，是在支付页面内导入你去我们的模拟器。 在这个时候这个模拟器页面会需要你输入username 和 password. 但是你用webview时需要做以下配置来输入username 和 password. 以下的 username 和 password 请改成模拟器的登入讯息username 和 password.

<figure><img src="https://files.readme.io/9b0cd94-Snipaste_2022-06-22_15-56-26.png" alt=""><figcaption></figcaption></figure>

{% tabs %}
{% tab title="参数参考" %}

```groovy
@Override
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
handler.proceed("username", "password");
}
```

{% endtab %}
{% endtabs %}

## 支付成功后，想返回APP的方式

1. 在自己APP内部打开支付页面，在支付完成后< back to merchant> 按钮跳转地址（重定向地址/页面）也是在App内部。
2. 若使用外浏览器打开支付页面，在支付完成打开跳转地址（重定向地址/页面）时是在外部浏览器中打开的，这时如果要跳转到App内部，需要通过（schema DeepLink）跳转

## Gopay iOS webview无法唤起 gopay app \ Unsupported Schema : gojek

<figure><img src="https://files.readme.io/239186f-image.png" alt="" width="375"><figcaption></figcaption></figure>

Gopay iOS系统 , 如果商家的应用程序是本机 iOS 应用程序，需要将 LSApplicationQueriesSchemes 键添加到应用程序的 Info.plist :

{% tabs %}
{% tab title="XML" %}

```xml
<key>LSApplicationQueriesSchemes</key>  
<array>  
<string>gojek</string>  
<string>gopay</string>  
<string>shopeeid</string>  
</array>
```

{% endtab %}
{% endtabs %}

这是为了确保允许从商家的应用程序到（外部）目标支付应用程序的深层链接deeplink。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.coda.co/https-coda-payments.gitbook.io-zhong-wen-coda-private-technical-documentation/codapay/webview-chang-jian-wen-ti.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
