0

我正面临这种错误:“PGTransactionViewController”没有成员“initTransactionForOrder”。谁能帮我解决一下。

func Pay_btn_Action(sender:UIButton!) {


    var mc: PGMerchantConfiguration = PGMerchantConfiguration.defaultConfiguration()
    mc.checksumGenerationURL = "https://pguat.paytm.com/paytmchecksum/paytmCheckSumGenerator.jsp"
    mc.checksumValidationURL = "https://pguat.paytm.com/paytmchecksum/paytmCheckSumVerify.jsp"

    var orderDict: [NSObject : AnyObject] = NSMutableDictionary() as [NSObject : AnyObject]

    orderDict["MID"] = "WorldP64425807474247"
    orderDict["CHANNEL_ID"] = "WAP"
    orderDict["INDUSTRY_TYPE_ID"] = "Retail"
    orderDict["WEBSITE"] = "worldpressplg"
    orderDict["TXN_AMOUNT"] = "1"
    orderDict["ORDER_ID"] = PaymentView.generateOrderIDWithPrefix("")
    orderDict["REQUEST_TYPE"] = "DEFAULT"
    orderDict["CUST_ID"] = "1234567890"

    var order: PGOrder = PGOrder(params: orderDict)

    PGServerEnvironment.selectServerDialog(self.tbl_Payment, completionHandler: {(type: ServerType) -> Void in

         var txnController: PGTransactionViewController = PGTransactionViewController.initTransactionForOrder(order) 

        if type != eServerTypeNone {
            txnController.serverType = type
            txnController.merchant = mc
            txnController.delegate = self
            self.showController(txnController)
        }
    })


}
4

2 回答 2

3

我不知道这个特定的库,但总的来说,如果它已经从 Objective-C 适应了 Swift,它应该是这样的:

PGTransactionViewController(transactionForOrder: order)
于 2016-03-18T15:54:15.053 回答
1

我已经解决了所有的问题。

func Pay_btn_Action(sender:UIButton!) {

//Step 1: Create a default merchant config object
    let mc: PGMerchantConfiguration = 
   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 = "https://pguat.paytm.com/paytmchecksum/paytmCheckSumGenerator.jsp"
    mc.checksumValidationURL = "https://pguat.paytm.com/paytmchecksum/paytmCheckSumVerify.jsp"

    //Step 3: Create the order with whatever params you want to add. But make sure that you include the merchant mandatory params
    var orderDict: [NSObject : AnyObject] = NSMutableDictionary() as [NSObject : AnyObject]

    orderDict["MID"] = "WorldP64425807474247"
     //Merchant configuration in the order object
    orderDict["CHANNEL_ID"] = "WAP"
    orderDict["INDUSTRY_TYPE_ID"] = "Retail"
    orderDict["WEBSITE"] = "worldpressplg"
     //Order configuration in the order object
    orderDict["TXN_AMOUNT"] = "5"
    orderDict["ORDER_ID"] = ViewController.generateOrderIDWithPrefix("")
    orderDict["REQUEST_TYPE"] = "DEFAULT"
    orderDict["CUST_ID"] = "1234567890"

    let order: PGOrder = PGOrder(params: orderDict)

    //Step 4: Choose the PG server. In your production build dont call selectServerDialog. Just create a instance of the
    //PGTransactionViewController and set the serverType to eServerTypeProduction
    PGServerEnvironment.selectServerDialog(self.view, completionHandler: {(type: ServerType) -> Void in

        let txnController = PGTransactionViewController.init(transactionForOrder: order)


        if type != eServerTypeNone {
            txnController.serverType = type
            txnController.merchant = mc
            txnController.delegate = self
            self.showController(txnController)
        }
    })


}

如果有人想要 Swift 2.1 Paytm 钱包集成代码到他们的 iOS 应用程序中,可以从这里下载整个项目。 关联

于 2016-04-20T07:15:40.690 回答