Search code examples
iostelr

Payment Integration Using Telr


I am currently working on Telr Gateway. I have downloaded the Swift 4.2 version Telr SDK and checked the sample test.

My question is: Should I send XML Request or directly I can send like which is mentioned in sample?


Solution

    1. Drag and drop the TelrSDK.framework into Frameworks group.
    2. Then go to your project's Target and add Telr framework in Embedded frameworks and Linked frameworks.
    3. Now clean and build the project.

    Sample Payment Request.

    Import the TelrSDK Framework. Then create a payment request object and assign the request to telrController's paymentRequest property. Then push or present the telr view controller. After entering the card details, you'll get the response in the view controller with StoryboardID called ResultController which inherits the TelrResponseController.

    private func openTelrPaymentGateway() {
        paymentRequest = preparePaymentRequest()
        let telrVC = storyboard?.instantiateViewController(withIdentifier: "TelrController") as! TelrController
        telrVC.title = "Telr"
        telrVC.paymentRequest = paymentRequest!
        navigationController?.pushViewController(telrVC, animated: true)
    }
    
    private func preparePaymentRequest() -> PaymentRequest{
    
        let paymentReq = PaymentRequest()
        paymentReq.key = "YOUR KEY"
        paymentReq.store = "YOUR STORE ID"
        paymentReq.appId = "123456789"
        paymentReq.appName = "YOUR APP NAME"
        paymentReq.appUser = "123456"
        paymentReq.appVersion = "0.0.1"
        paymentReq.transTest = "1"
        paymentReq.transType = "auth"
        paymentReq.transClass = "paypage"
        paymentReq.transCartid = String(arc4random())
        paymentReq.transDesc = "Test API"
        paymentReq.transCurrency = "AED"
        paymentReq.transAmount = "\(totalAmount)"
        paymentReq.transLanguage = "en"
        paymentReq.billingEmail = EMAIL
        paymentReq.billingFName = "Hany"
        paymentReq.billingLName = "Sakr"
        paymentReq.billingTitle = "Mr"
        paymentReq.city = "Dubai"
        paymentReq.country = "AE"
        paymentReq.region = "Dubai"
        paymentReq.address = "line 1"
        paymentReq.billingPhone="8785643"
        return paymentReq
    
    }
    

    Once the request is processed, you'll get the response from TelrResponseController class.

    class PaymentGatewayVC: TelrResponseController {
    
        override func viewDidLoad() {
        super.viewDidLoad()
    
          print(message!)
          print(trace!)
          print(status!)
          print(avs!)
          print(code!)
          print(ca_valid!)
          print(cardCode!)
          print(cardLast4!)
          print(cvv!)
          print(tranRef!)
    
        }
    
    }
    

    Hope this helps you.