安卓APP请求创建支付订单
<ol>
<li>
<p>编写OrderActivity.java,添加新的方法</p>
<pre><code class="language-java">@JavascriptInterface
public void wapPay(String code){
OrderActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("http://192.168.99.100:8080/renren-fast/app/unionpay/wapPayPage?code="+code);
intent.setData(content_url);
startActivity(intent);
}
});
}</code></pre>
</li>
<li>修改order.js文件,添加上银联付款的点击事件
<pre><code class="language-javascript">//这里是银联支付的代码
$.ajax({
url:url.unionpay.wapPayOrder,
type:"post",
dataType:"json",
contentType:"application/json",
beforeSend:function(request){
request.setRequestHeader("token",localStorage.getItem("token"))
},
data:JSON.stringify({
"orderId":orderId
}),
success:function(resp){
let code=resp.code
window.order.wapPay(code)
}
})</code></pre></li>
</ol>