簡體   English   中英

Paytm SDK iOS快速集成

[英]Paytm sdk ios integration in swift

我設置了代理PGTransactionDelegate,但是它顯示了一個錯誤,例如視圖控制器不符合協議“ PGTransactionDelegate

碼:

橋接頭中的Paytm目標頭

#import "PaymentsSDK.h

視圖控制器中的委托方法

// On Successful Payment
func didSucceedTransaction(controller: PGTransactionViewController, response: [NSObject : AnyObject]) {             
    print(response)
    print("Deducted amount :Rs. \(response["TXNAMOUNT"]!)")
    self.removeController(controller)
}

// On Failure
func didFailTransaction(controller: PGTransactionViewController, error: NSError, response: [NSObject : AnyObject]) {
    print(response)
    if response.count == 0 {
        print(response.description)
    }
    else if error != 0 {
       print(error.localizedDescription)
    }
    self.removeController(controller)
}

//On Cancellation
func didCancelTransaction(controller: PGTransactionViewController, error: NSError, response: [NSObject : AnyObject]) {
    print("Transaction has been Cancelled")
    self.removeController(controller)    
}

func didFinishCASTransaction(controller: PGTransactionViewController, response: [NSObject : AnyObject]) { 
    print(response);   
}

如果您最近將代碼更新為swift3.0,則委托函數的語法可能會有所更改,請檢查一下。

請在Bridging-Header中更正Paytm目標標頭

#import“ PaymentsSDK.h”

如果您使用的是swift 3或swift 4,那么這些方法可以解決您的問題

// On Successful Payment
func didSucceedTransaction(_ controller: PGTransactionViewController!, response: [AnyHashable : Any]!) {
    printLog(log: response)
}

// On Failure
func didFailTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {
    printLog(log: response)
    printLog(log: error.localizedDescription)
}

//On Cancellation
func didCancelTransaction(_ controller: PGTransactionViewController!, error: Error!, response: [AnyHashable : Any]!) {
    printLog(log: response)
    root.navigationController?.popViewController(animated: true)
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM