【发布时间】:2016-07-07 22:12:40
【问题描述】:
我想在我的应用程序中集成 Paytm SDK。我有MerchantId and Merchant key。
但我没有那些网址。如何生成这些 URL?
【问题讨论】:
-
连同问题在这里发布您的代码,将尝试更新需要做的事情
我想在我的应用程序中集成 Paytm SDK。我有MerchantId and Merchant key。
但我没有那些网址。如何生成这些 URL?
【问题讨论】:
我将 PayTM sdk 集成到 swift 应用程序中,并且运行良好。
我卡住了大约 15 天的问题是 URL 生成:
checkSumGenerationURL 和 checkSumValidationURL。
之前我使用的是 PayTM 提供的网址,但由于这个原因,每次尝试付款都会失败。
所以这是最终的解决方案: 我和我的服务器团队坐在一起,然后决定在我们自己的服务器上处理它,然后尝试一下。
效果很好。
So here is final set of parameters you need to pass :
//Step 1: Create a default merchant config object
PGMerchantConfiguration *mc = [PGMerchantConfiguration defaultConfiguration];
//Step 2: If you have your own checksum generation and validation url set this here. Otherwise use the default Paytm urls
mc.checksumGenerationURL = @"generate checksum url by handling in own server";
mc.checksumValidationURL = @"generate checksum url by handling in own server";
//Step 3: Create the order with whatever params you want to add. But make sure that you include the merchant mandatory params
NSMutableDictionary *orderDict = [NSMutableDictionary new];
//Merchant configuration in the order object
orderDict[@"MID"] = @"abc1111";
orderDict[@"CHANNEL_ID"] = @"WAP";
orderDict[@"INDUSTRY_TYPE_ID"] = @"Education";
orderDict[@"WEBSITE"] = @"companyname";
//Order configuration in the order object
orderDict[@"TXN_AMOUNT"] = @"100";
orderDict[@"ORDER_ID"] = [Feepayment generateOrderIDWithPrefix:@"111"];
orderDict[@"REQUEST_TYPE"] = @"DEFAULT";
orderDict[@"CUST_ID"] = @"abc7777";
这里是 iOS Swift2.2(应用端)中的校验和生成方法
//调用这个方法 createCheckSumString(hashValue)
其中 hasValue 是您添加所有 PAYTM 参数的参数,它是一个字符串类型。
方法如下:
func createCheckSumString(input: String) -> String {
let cstr = input.cStringUsingEncoding(NSUTF8StringEncoding)
var data = NSData(bytes: cstr, length: input.length)
var digest = [UInt8](count: CC_SHA512_DIGEST_LENGTH, repeatedValue: 0)
// This is an iOS5-specific method.
// It takes in the data, how much data, and then output format, which in this case is an int array.
CC_SHA512(data.bytes, Int(data.length), digest)
var output = String(capacity: CC_SHA512_DIGEST_LENGTH * 2)
// Parse through the CC_SHA256 results (stored inside of digest[]).
for i in 0..<CC_SHA512_DIGEST_LENGTH {
output += String(format: "%02x", digest[i])
}
return output
}
注意- 导入 CommonDigest(在目标 c 中,我们以这种方式添加 #include <CommonCrypto/CommonDigest.h> 以便 CC_SHA512_DIGEST_LENGTH 起作用
随意分享 cmets。
【讨论】:
您只能从您的服务器生成校验和(适用于 SDK 2.0 和最新版本)。 Paytm 确实提供了用于生成校验和的 PHP 文件(java、python),您需要将其上传到您的服务器上。上传完成后更改商家密钥 - 进入 lib 文件夹并更新 config.paytm.php 文件中的密钥。 您可以从此处获取使用 PHP 文件和 android 代码生成校验和的参考 - http://www.blueappsoftware.in/android/blog/paytm-integration-sdk-2-1-android/
【讨论】: