Search code examples
iosswiftpaytm

PayTM SDK : Transaction Failed


I am integrating PayTM in my app which is in ios (Swift) and I am facing issue which title is "Transaction Failed" and the message is "MissingKeys"

enter image description here

I have used following code

    merchant = PGMerchantConfiguration.default()!

    merchant.checksumGenerationURL = "http://getlook.in/cgi-bin/checksum_generate.cgi"
    merchant.checksumValidationURL = "http://getlook.in/cgi-bin/checksum_validate.cgi"

    merchant.clientSSLCertPath = nil
    merchant.clientSSLCertPassword = nil

    merchant.merchantID = "rriver57770575448885"
    merchant.website = "APP_STAGING"
    merchant.industryID = "Retail"
    merchant.channelID = "WAP"

    var orderDict = [String: String]()

    orderDict["MID"] = "rriver57770575448885" // Merchant ID
    orderDict["CHANNEL_ID"] = "WAP" // Channel Id
    orderDict["INDUSTRY_TYPE_ID"] = "Retail" // Industry Type

    orderDict["WEBSITE"] = "APP_STAGING"
    orderDict["TXN_AMOUNT"] = "10"; // amount to charge                      // mandatory
    orderDict["ORDER_ID"] = "\(Date().timeIntervalSince1970)";//change order id every time on new transaction
    orderDict["REQUEST_TYPE"] = "DEFAULT";// remain same
    orderDict["CUST_ID"] = "123456789027"; // change acc. to your database user/customers
    orderDict["MOBILE_NO"] = "8798987874";// optional
    orderDict["EMAIL"] = "[email protected]"; //optional

    let pgOrder = PGOrder(params: orderDict)

    let transaction = PGTransactionViewController.init(transactionFor: pgOrder)

    transaction?.serverType = eServerTypeProduction
    transaction?.merchant = merchant
    transaction?.loggingEnabled = true
    transaction?.delegate = self
    self.present(transaction!, animated: true, completion: nil)

please help!


Solution

  • In this code you have missed a parameter called chechSumHash. include that too.

    orderDict["CHECKSUMHASH"] = CheckSum;
    

    checkSumHash can be generated in the backend by the help of Paytm checksum generation kit. the checksum is a unique string which will change according to the parameter that we have send for checksum generation Api