简体   繁体   English

Paytm SDK iOS快速集成

[英]Paytm sdk ios integration in swift

I set the delegate PGTransactionDelegate but it's showing an error like view-controller does not conform with protocol " PGTransactionDelegate " 我设置了代理PGTransactionDelegate,但是它显示了一个错误,例如视图控制器不符合协议“ PGTransactionDelegate

code: 码:

Paytm target header in Bridging-Header 桥接头中的Paytm目标头

#import "PaymentsSDK.h

Delegate method in view-controller 视图控制器中的委托方法

// 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,则委托函数的语法可能会有所更改,请检查一下。

Please correct Paytm target header in Bridging-Header 请在Bridging-Header中更正Paytm目标标头

#import "PaymentsSDK.h" #import“ PaymentsSDK.h”

If you are using swift 3 or swift 4 then these method can resolve your problem 如果您使用的是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