我已经在我的Android应用程序中集成了Paytm Payment Gateway。但是他们的文档中提到的生产模式的回调URL并未将我重定向到带有响应的应用程序。 它只是打开一个页面,显示重定向到我的应用程序,然后什么也没有发生,并且在按返回按钮时会弹出一个对话框,询问是否取消交易,即使交易成功也是如此。 他们的文档中提到的url在下面给出,这是行不通的。还有其他一些回调URL可以使用吗?
https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=$orderid
使用的代码是:
RequestQueue requestQueue= Volley.newRequestQueue(UpiPayment.this);
StringRequest stringRequest=new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject=new JSONObject(response);
if(jsonObject.has("CHECKSUMHASH")){
String CHECKSUMHASH=jsonObject.getString("CHECKSUMHASH");
PaytmPGService paytmPGService=PaytmPGService.getProductionService();
HashMap<String, String> paramMap = new HashMap<String,String>();
paramMap.put( "MID" , mid);
paramMap.put( "ORDER_ID" , orderId);
paramMap.put( "CUST_ID" , customerId);
paramMap.put( "CHANNEL_ID" , "WAP");
paramMap.put( "TXN_AMOUNT" , amount);
paramMap.put( "WEBSITE" , "DEFAULT");
paramMap.put( "INDUSTRY_TYPE_ID" , "Retail");
paramMap.put( "CALLBACK_URL", callbackUrl);
paramMap.put("CHECKSUMHASH",CHECKSUMHASH);
PaytmOrder order=new PaytmOrder(paramMap);
paytmPGService.initialize(order,null);
paytmPGService.startPaymentTransaction(UpiPayment.this, true, true, new PaytmPaymentTransactionCallback() {
@Override
public void onTransactionResponse(Bundle inResponse) {
Toast.makeText(UpiPayment.this, "Payment Transaction response " + inResponse.toString(), Toast.LENGTH_LONG).show();
if(inResponse.getString("STATUS").equals("TXN_SUCCESS")){
Toast.makeText(UpiPayment.this, "payment successful", Toast.LENGTH_SHORT).show();
}
}
@Override
public void networkNotAvailable() {
Toast.makeText(getApplicationContext(), "Network connection error: Check your internet connectivity", Toast.LENGTH_LONG).show();
}
@Override
public void clientAuthenticationFailed(String inErrorMessage) {
Toast.makeText(getApplicationContext(), "Authentication failed: Server error" + inErrorMessage.toString(), Toast.LENGTH_LONG).show();
}
@Override
public void someUIErrorOccurred(String inErrorMessage) {
Toast.makeText(getApplicationContext(), "UI Error " + inErrorMessage , Toast.LENGTH_LONG).show();
}
@Override
public void onErrorLoadingWebPage(int iniErrorCode, String inErrorMessage, String inFailingUrl) {
Toast.makeText(getApplicationContext(), "Unable to load webpage " + inErrorMessage.toString(), Toast.LENGTH_LONG).show();
}
@Override
public void onBackPressedCancelTransaction() {
Toast.makeText(getApplicationContext(), "Transaction cancelled" , Toast.LENGTH_LONG).show();
}
@Override
public void onTransactionCancel(String inErrorMessage, Bundle inResponse) {
Toast.makeText(getApplicationContext(), "Unable to load webpage " + inResponse.toString(), Toast.LENGTH_LONG).show();
}
});
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(UpiPayment.this, "Something went wrong", Toast.LENGTH_SHORT).show();
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> paramMap = new HashMap<String,String>();
paramMap.put( "MID" , mid);
paramMap.put( "ORDER_ID" , orderId);
paramMap.put( "CUST_ID" , customerId);
paramMap.put( "CHANNEL_ID" , "WAP");
paramMap.put( "TXN_AMOUNT" , amount);
paramMap.put( "WEBSITE" , "DEFAULT");
paramMap.put( "INDUSTRY_TYPE_ID" , "Retail");
paramMap.put( "CALLBACK_URL", callbackUrl);
return paramMap;
}
};
requestQueue.add(stringRequest);