Paytm控制台在Swift 4中给出404错误

时间:2019-04-23 03:59:52

标签: ios swift paytm

我正在使用Swift 4在iOS中实现Paytm。我正在将请求的数据发送到paytm控制台,但是显示“ 404 Not Found”错误。 我正在将以下数据发送到paytm:

let merchantConfig = PGMerchantConfiguration.default()
merchantConfig?.checksumGenerationURL = "https://pguat.paytm.com/paytmchecksum/paytmCheckSumGenerator.jsp" 
merchantConfig?.checksumValidationURL = "https://pguat.paytm.com/paytmchecksum/paytmCheckSumVerify.jsp" 

let odrDict = NSMutableDictionary()

odrDict["CALLBACK_URL"] = "https://pguat.paytm.com/paytmchecksum/paytmCallback.jsp",
odrDict["CHANNEL_ID"] = "WAP",
odrDict["CUST_ID"] =  "30244",
odrDict["INDUSTRY_TYPE_ID"] = "Software",
odrDict["MID"] = self.MID
odrDict["ORDER_ID"] = "29",
odrDict["REQUEST_TYPE"] = "DEFAULT",
odrDict["TXN_AMOUNT"] = "200",
odrDict["WEBSITE"] = "WEB_STAGING"
odrDict["CHECKSUMHASH"] = "a/4w+QPWAEZXlNXg48Nr9OQoBYGDjj1lVbY4VPhAqi4pkadfcUFoY6UToaHNnND8pNoDCJRxYlFEirdsnowwMACKAXgTB3ScBBYorzipqQ=",
odrDict["MOBILE_NO"] = "7777777777"
odrDict["EMAIL"] = "demo@gmail.com"

print("odrDict",odrDict)

let order: PGOrder = PGOrder(params: odrDict as? [AnyHashable : Any])
let transactionController = PGTransactionViewController(transactionFor: order)
transactionController?.serverType = eServerTypeStaging
transactionController?.merchant = merchantConfig
transactionController?.delegate = self
self.showController(controller: transactionController!)

我不知道我在做什么错。每次我请求打开paytm控制台时,都显示找不到404。

1 个答案:

答案 0 :(得分:0)

     extension ABViewController: UIViewController {

        var custID = ""
        override func viewDidLoad() {

        super.viewDidLoad()

        self.setMerchant()


        custID =  custID.randomString(length: 20)
        print(custID)
      }

        func setMerchant() {


            merchant  = PGMerchantConfiguration.default()
            //user your checksum urls here or connect to paytm developer team for this or use default urls of paytm


            merchant.checksumGenerationURL = "http://test/Admin/paytm/generateChecksum.php";
            merchant.checksumValidationURL = "http://test/Admin/paytm/verifyChecksum.php";
        merchant.merchantID = "testI93673659336118";//paste here your merchant id  //mandatory
            merchant.website = "APPPROD";//mandatory
            merchant.industryID = "Retail109";//mandatory
            merchant.channelID = "WAP"; //provided by PG WAP //mandatory

            merchant.clientSSLCertPath = nil; //[[NSBundle mainBundle]pathForResource:@"Certificate" ofType:@"p12"];
            merchant.clientSSLCertPassword = nil; //@"password";
        }

        //MARK:- Create Payment
        func createPayment(checksumHash : String, orderID : String) {

            var orderDict = [AnyHashable : Any]()

            let txnAmt = self.amountTextField.text!
            print(txnAmt)

            orderDict["MID"] = "RentSe98692194807190"
            orderDict["CHANNEL_ID"] = "WAP"
            orderDict["INDUSTRY_TYPE_ID"] = "Retail109"
            orderDict["WEBSITE"] = "APPPROD"
            orderDict["TXN_AMOUNT"] = "50" as AnyObject
            orderDict["ORDER_ID"] = orderID
            orderDict["CHECKSUMHASH"] = checksumHash
            orderDict["CUST_ID"] = custID
            orderDict["EMAIL"] = "kj@gmail.com" as AnyObject
            orderDict["MOBILE_NO"] = "7777777777" as AnyObject
            orderDict["REQUEST_TYPE"] = "DEFAULT" as AnyObject
            orderDict["THEME"] = "merchant" as AnyObject
            orderDict["CALLBACK_URL"] = "https://pguat.paytm.com/paytmchecksum/paytmCallback.jsp" as AnyObject

            print(custID)
            let pgOrder = PGOrder(params: orderDict)

            let transaction = PGTransactionViewController.init(transactionFor: pgOrder)

            if eServerTypeStaging != eServerTypeNone {
                transaction!.serverType = eServerTypeProduction
                transaction!.merchant = merchant
                transaction!.delegate = self
                self.navigationController?.pushViewController(transaction!, animated: true)
            }
        }

        func validatePaytm(checksumHash : String, orderID: String) {

            var orderDict = [String : AnyObject]()

            orderDict["CHECKSUMHASH"] = checksumHash as AnyObject
            orderDict["ORDER_ID"] = orderID as AnyObject
        }

        //MARK:- Generate Checksum from our Server
        func paytmAPI() {

            let url = "http://mstoo.co.in/Admin/paytm/generateChecksum.php"

            let orderID = "".randomString(length: 20)
            print(orderID)

            let txnAmt = self.amountTextField.text!
            print(txnAmt)

            var orderDict = [String : AnyObject]()

            orderDict["MID"] = "RentSe98692194807190" as AnyObject
            orderDict["CHANNEL_ID"] = "WAP" as AnyObject
            orderDict["INDUSTRY_TYPE_ID"] = "Retail109" as AnyObject
            orderDict["WEBSITE"] = "APPPROD" as AnyObject
            orderDict["TXN_AMOUNT"] = txnAmt as AnyObject
            orderDict["ORDER_ID"] = orderID as AnyObject
            orderDict["CUST_ID"] = custID as AnyObject
            orderDict["EMAIL"] = "kj@gmail.com" as AnyObject
            orderDict["MOBILE_NO"] = "7777777777" as AnyObject
            orderDict["REQUEST_TYPE"] = "DEFAULT" as AnyObject
            orderDict["THEME"] = "merchant" as AnyObject
            orderDict["CALLBACK_URL"] = "https://pguat.paytm.com/paytmchecksum/paytmCallback.jsp" as AnyObject

            let imageArray = [UIImage]()

            Methods.sharedInstance.showLoader(object: self.view)

            WebServiceClass.uploadeImageToServer(urlName: url, params: orderDict, uploadedImage: imageArray, imageName: "") { (isTrue, response, errorMessage) in

                Methods.sharedInstance.hideLoader(object: self.view)

                if let jsonResult = response as? Dictionary<String, AnyObject> {

                    print(jsonResult)

                    self.paytmValidate(checksumhash: jsonResult["CHECKSUMHASH"] as? String ?? "", orderID: jsonResult["ORDER_ID"] as? String ?? "")
                } else {

                    self.showAlertWithoutCallBack(messageTitle: "MessageWhatHappen")
                }
            }
        }

        func paytmValidate(checksumhash: String,orderID: String) {

            let url = "http://test/Admin/paytm/verifyChecksum.php"

            var orderDict = [String : AnyObject]()

            orderDict["CHECKSUMHASH"] = checksumhash as AnyObject
            orderDict["ORDER_ID"] = orderID as AnyObject

            let imageArray = [UIImage]()

            WebServiceClass.uploadeImageToServer(urlName: url, params: orderDict, uploadedImage: imageArray, imageName: "") { (isTrue, response, errorMessage) in

                if let jsonResult = response as? Dictionary<String, AnyObject> {

                    print(jsonResult)

                    self.createPayment(checksumHash:checksumhash, orderID:orderID)
                } else {

                     print("MessageWhatHappen")
                }
            }
        }
    }

   extension ABViewController:  PGTransactionDelegate {

        func didFinishedResponse(_ controller: PGTransactionViewController!, response responseString: String!) {

            print("Transaction Finished")
            print(responseString)
            let Str = responseString
            let finalDictResponse = convertToDictionary(text: Str ?? "")
            print(finalDictResponse)
            if let myDict = finalDictResponse as Dictionary<String,AnyObject>? {
                self.addMoneyAPI(transectionID : myDict["TXNID"] as? String ?? "")
                self.removeController(controller: controller)
                showToast(message: "Finish Response")

            }
        }

        func didCancelTrasaction(_ controller: PGTransactionViewController!) {
            self.navigationController?.popViewController(animated: true)
            self.showToast(message: "Transaction Cancelled")
        }

        func errorMisssingParameter(_ controller: PGTransactionViewController!, error: Error!) {

            self.removeController(controller: controller)
            showToast(message: "Missing Parameters")
            DispatchQueue.main.async {
                self.removeController(controller: controller)
                self.navigationController?.popViewController(animated: true)
            }
            showAlert(title: "didCancelTrasaction", message: error.localizedDescription)
        }

        func didSucceedTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {

            print(response)
            self.showToast(message: "Transaction Successful")

        }

        func didFailTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {

            print(error)
            self.navigationController?.popToViewController(controller, animated: true)
            self.showToast(message: "Transaction Failed")
        }

        func didFinishCASTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {

            print(response)
        }

        func showController(controller: PGTransactionViewController) {

            if self.navigationController != nil {
                self.navigationController?.pushViewController(controller, animated: true)
            } else {
                self.navigationController?.pushViewController(controller, animated: true)
            }
        }

        func removeController(controller: PGTransactionViewController) {

            if self.navigationController != nil {
                print("Transcation Successful")

            } else {
                print("Transcation Successful")
            }
        }
    }