简体   繁体   English

如何在iOS PayTm集成中生成“checksumGenerationURL”和“checksumValidationURL”?

[英]How to generate “checksumGenerationURL” and “checksumValidationURL” in iOS PayTm integration?

I want to integrate Paytm SDK in my app. 我想在我的应用程序中集成Paytm SDK I have MerchantId and Merchant key . 我有MerchantId and Merchant key But i don't have those Urls. 但我没有那些网址。 How to generate those URLS? 如何生成这些URL?

I integrated PayTM sdk into swift application and its working fine . 我将PayTM sdk集成到快速应用程序中并且工作正常。

The issue where i got stuck about 15 days is the URL Generation : 我被困大约15天的问题是URL生成:

checkSumGenerationURL and checkSumValidationURL . checkSumGenerationURLcheckSumValidationURL

Earlier i was using PayTM provided url but due to this it gets failed every time trying to payment . 早些时候我使用的是PayTM提供的网址,但由于这个原因,每次尝试付款都会失败。

so here is the final solution : I sit with my server team and then decided to handle it in our own server then after try it . 所以这是最终的解决方案:我和我的服务器团队坐在一起然后决定在我们自己的服务器上处理它,然后尝试它。

It works great . 它很棒。

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";

Here is checksumgeneration method in iOS Swift2.2 (app side) 这是iOS Swift2.2中的校验和生成方法(应用程序端)

//Call this method createCheckSumString(hashValue) //调用此方法createCheckSumString(hashValue)

Where hasValue is the paramater in which you added all your PAYTM parameter , its a string type . 其中hasValue是你在其中添加了所有PAYTM参数的参数,它是一个字符串类型。

Here is method : 这是方法:

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
}

NOTE - import CommonDigest ( In objective c this way we add so #include <CommonCrypto/CommonDigest.h> so that CC_SHA512_DIGEST_LENGTH works Feel free to share comments. 注意 - 导入CommonDigest(在目标c中我们这样添加#include <CommonCrypto/CommonDigest.h>以便CC_SHA512_DIGEST_LENGTH工作随意分享注释。

You can generate checksum from your server only (it is for SDK 2.0 and latest version ). 您只能从服务器生成校验和(适用于SDK 2.0和最新版本)。 Paytm do provide PHP file (java, python too) for checksum generation that you need to upload on your server. Paytm确实为您需要在服务器上传的校验和生成提供PHP文件(java,python)。 once upload done then change the merchant key - go inside lib folder and update key on config.paytm.php file . 上传完成后再更改商家密钥 - 进入lib文件夹并更新config.paytm.php文件中的密钥。 You can get reference from here for checksum generation using PHP file and the android code - http://www.blueappsoftware.in/android/blog/paytm-integration-sdk-2-1-android/ 你可以从这里获得使用PHP文件和android代码生成校验和的参考 - http://www.blueappsoftware.in/android/blog/paytm-integration-sdk-2-1-android/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM