2

当我们两次单击事务取消按钮时,应用程序崩溃了,我们得到了

-[PGTransactionViewController cancelCallback:response:],/Users/pradeep/_Projects/Paytm/pgsdk/PaymentsSDK/PaymentsSDK/PGTransactionViewController.m:217 2016-04-25 16:31:25.228 MyDemo[4669:92001] 中的断言失败 ** * 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“没有设置委托?...你打算如何回调?”

代码

 ///PaymentGateway With OrderID
  func initiatePaymentGatewayWithOrderID() {

      //Step 1: Create a default merchant config object
      let pgMerchantConfiguration = PGMerchantConfiguration.defaultConfiguration()
      //Step 2: If you have your own checksum generation and validation url set this here. Otherwise use the default Paytm urls


      //prod/staging urls are decided based on the build configuration, go to Url.swift and check the host url configuration
      pgMerchantConfiguration.checksumGenerationURL = Url.paytmChecksumGenerationURL
      pgMerchantConfiguration.checksumValidationURL = Url.paytmChecksumValidationURL

      //Step 3: Create the order with whatever params you want to add. But make sure that you include the merchant mandatory params
      var orderDict = [String : AnyObject]()
      orderDict["MID"] = self.slotTestCenter?.mID
      orderDict["CHANNEL_ID"] = self.slotTestCenter?.channelID
      orderDict["INDUSTRY_TYPE_ID"] = self.slotTestCenter?.industryTypeID
      orderDict["WEBSITE"] = self.slotTestCenter?.website
      //Order configuration in the order object
      orderDict["TXN_AMOUNT"] = self.slotTestCenter?.txnAmount
      orderDict["ORDER_ID"] = self.slotTestCenter?.orderId
      orderDict["REQUEST_TYPE"] = "DEFAULT";
      orderDict["CUST_ID"] = self.slotTestCenter?.custID
      orderDict["EMAIL"] = self.slotTestCenter?.email
      orderDict["MOBILE_NO"] = self.slotTestCenter?.mobileNo
      debugLog(orderDict)
      let order = PGOrder(params: orderDict)
      debugLog(order)
      self.txnController = PGTransactionViewController(transactionForOrder: order)
      //A staging server is a mix between production and development; you get to test your app as if it were in production


        self.txnController!.serverType = eServerTypeStaging

      // Set the merchant configuration for the transaction.
      self.txnController!.merchant = pgMerchantConfiguration
      // A delegate object should be set to handle the responses coming during the transaction
      self.txnController!.delegate = self
      self.navigationController?.pushViewController(self.txnController!, animated: true)

  }

  //Called when a transaction is Canceled by User. response dictionary will be having details about Canceled Transaction.
  func didCancelTransaction(controller: PGTransactionViewController!, error: NSError!, response: [NSObject : AnyObject]!) {
    if self.txnController != nil {
      //Access AbcViewController in navigation stack and pop
      for viewController in self.navigationController!.viewControllers as [UIViewController] {
        if viewController.isKindOfClass(AbcViewController) {
          self.navigationController?.popToViewController(viewController, animated: false)
          return
        }

 }
    }
  }

有人有解决方案吗?

4

0 回答 0