Java 如何在android应用程序中集成paytm钱包?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30069644/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to integrate paytm wallet in android application?
提问by Ajinkya Patil
I want to integrate paytm wallet in my android application. I found lots of suggestions and documentation on Google but nothing worked. If there is any documentation, code samples or useful suggestions that you know please let me know. Thanks in advance.
我想在我的 android 应用程序中集成 paytm 钱包。我在 Google 上找到了很多建议和文档,但没有任何效果。如果您知道任何文档、代码示例或有用的建议,请告诉我。提前致谢。
采纳答案by Ganesh Katikar
Note: Below is for version 1.0, now paytm updated their sdk, so you need to change that accordingly.
Go to link :
注意:以下是1.0版本,现在paytm更新了他们的sdk,所以你需要相应地改变它。
转到链接:
http://paywithpaytm.com/developer/
http://paywithpaytm.com/developer/
and download Android+SDK
并下载Android+SDK
put below code in your function or where you want to start paytm stuff.
把下面的代码放在你的函数中或者你想开始 paytm 的地方。
private int randomInt = 0;
private PaytmPGService Service = null;
Random randomGenerator = new Random();
randomInt = randomGenerator.nextInt(1000);
//for testing environment
Service = PaytmPGService.getStagingService();
//for production environment
/*Service = PaytmPGService.getProductionService();*/
/*PaytmMerchant constructor takes two parameters
1) Checksum generation url
2) Checksum verification url
Merchant should replace the below values with his values*/
PaytmMerchant Merchant = new PaytmMerchant("https://pguat.paytm.com/merchant-chksum/ChecksumGenerator","https://pguat.paytm.com/merchant-chksum/ValidateChksum");
//below parameter map is required to construct PaytmOrder object, Merchant should replace below map values with his own values
Map<String, String> paramMap = new HashMap<String, String>();
//these are mandatory parameters
paramMap.put("REQUEST_TYPE", "DEFAULT");
paramMap.put("ORDER_ID", String.valueOf(randomInt));
//MID provided by paytm
paramMap.put("MID", "id provided by paytm");
paramMap.put("CUST_ID", "CUST123");
paramMap.put("CHANNEL_ID", "WAP");
paramMap.put("INDUSTRY_TYPE_ID", "Retail");
paramMap.put("WEBSITE", "paytm");
paramMap.put("TXN_AMOUNT", "1");
paramMap.put("THEME", "merchant");
PaytmOrder Order = new PaytmOrder(paramMap);
Service.initialize(Order, Merchant,null);
Service.startPaymentTransaction(activity, false, false, new PaytmPaymentTransactionCallback() {
@Override
public void onTransactionSuccess(Bundle bundle) {
app.getLogger().error("Transaction Success :" + bundle);
}
@Override
public void onTransactionFailure(String s, Bundle bundle) {
app.getLogger().error("Transaction Failure :" + s + "\n" + bundle);
}
@Override
public void networkNotAvailable() {
app.getLogger().error("network unavailable :");
}
@Override
public void clientAuthenticationFailed(String s) {
app.getLogger().error("clientAuthenticationFailed :" + s);
}
@Override
public void someUIErrorOccurred(String s) {
app.getLogger().error("someUIErrorOccurred :" + s);
}
@Override
public void onErrorLoadingWebPage(int i, String s, String s2) {
app.getLogger().error("errorLoadingWebPage :" + i + "\n" + s + "\n" + s2);
}
});
}
Also another thing is you need to declare one activity in AndroidManifest.xml file:
还有一件事是您需要在 AndroidManifest.xml 文件中声明一个活动:
<activity
android:name="com.paytm.pgsdk.PaytmPGActivity"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden"/>
Hope above code sample will help u lot. Also another thing is when you download Android+SDK you will get one jar file pgsdk.jar file that you need to add in your project and MainActivity.java class file for our reference. Enjoy!!!
希望上面的代码示例会对你有很大帮助。还有一件事是,当您下载Android+SDK 时,您将获得一个jar 文件pgsdk.jar 文件,您需要将其添加到您的项目和MainActivity.java 类文件中以供我们参考。享受!!!
Note: ChecksumGenerator and ValidateChksum urls are for just testing purpose which is provided by paytm development support team. You need to generate it on your own server for redirecting respective url.
注意:ChecksumGenerator 和 ValidateChksum url 仅用于测试目的,由 paytm 开发支持团队提供。您需要在自己的服务器上生成它以重定向相应的 url。