2.2.3 唤起 App 支付

优质
小牛编辑
115浏览
2023-12-01

当用户接入变现猫的产品需要唤起自身系统中的支付页面时,唤起所在App客户端的支付界面。

实现方式:

  • 使用JavaScriptInterface接口,添加如下代码:

1.参数设置:

在免登陆参数中设置(此参数不参与签名):redirectPayUrl=redirectPayUrl

2.App客户端设置

//android WebView相关设置

mWebView.addJavascriptInterface(new JsInterface(this), "bianxianmao");
webSettings.setJavaScriptEnabled(true);

//实现JsInterface

private class JsInterface {
private Context mContext;
public JsInterface(Context context) {
    this.mContext = context;
}
@JavascriptInterface
public void onRechargeClick(String redirectUrl) {
//打印原生js返回的请求参数 Log.i("onRechargeClick","redirectUrl="+redirectUrl);
//唤起app支付
}
}