【发布时间】:2014-05-13 18:46:36
【问题描述】:
我在我的 android 应用程序中使用支付网关。我正在使用 webview 加载支付页面。我提供了一个指向支付网关的重定向 URL,确认支付后 webview 将被重定向到该 URL。银行的确认(成功/失败)将发回此 URL。我可以将我的 webview 重定向到此 URL,以向客户显示交易成功。我需要获取发送到重定向 URL 的 POST 数据。如果交易成功,我需要在我的应用程序中下订单。我目前正在做的是,我正在检查重定向 url 是否是成功的交易。我想知道是否有任何其他方法可以用来检查我的交易状态?这是我的代码,
mWebview = (WebView)findViewById(R.id.webView1);
mWebview.getSettings().setJavaScriptEnabled(true); // enable javascript
mWebview.getSettings().setAppCacheEnabled(false);
mWebview.getSettings().setLoadWithOverviewMode(true);
mWebview.getSettings().setUseWideViewPort(true);
mWebview.getSettings().setBuiltInZoomControls(true);
mWebview.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
pd.show();
}
@Override
public void onPageFinished(WebView view, String url) {
pd.dismiss();
String webUrl = mWebview.getUrl();
Log.i("RETURN URL", "RETURN URL IS "+webUrl);
if(url.equals("http://www.mydomain.in/trxn_complete")) //This is my method.But I think its ugly one
{
AlertDialog alertDialog = new AlertDialog.Builder(OnlinePaymentActivity.this).create();
alertDialog.setMessage("Transaction successful.Press OK to continue");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// TODO Add your code for the button here.
//Transaction success, So place order
new Orderitems(OnlinePaymentActivity.this).execute();
}
});
alertDialog.show();
}
}
});
mWebview .loadUrl("http://263.134.260.173/gateway/epi/fts?ttype="+type+"&tempTxnId="+tempTxnId+"&token="+token+"&txnStage="+txnStage);
}
【问题讨论】:
-
你的问题解决了吗?
-
如果您找到了解决方案,请告诉我。
标签: android post webview payment-gateway