使用Telr进行付款集成

时间:2019-02-01 14:58:57

标签: ios telr

我目前正在Telr Gateway上工作。我已经下载了Swift 4.2版本的Telr SDK,并检查了示例测试。

我的问题是:应该发送XML请求还是直接发送XML请求?

1 个答案:

答案 0 :(得分:2)

  1. TelrSDK.framework拖放到Frameworks组中。
  2. 然后转到项目的目标并在嵌入式框架和链接框架中添加Telr框架。
  3. 现在清理并构建项目。

样品付款请求。

导入TelrSDK框架。然后创建一个付款请求对象,并将请求分配给telrController的paymentRequest属性。然后推或显示telr视图控制器。输入卡片详细信息后,您将在视图控制器中获得名为ResultController的StoryboardID的响应,该故事板ID继承了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

}

处理完请求后,您将获得TelrResponseController类的响应。

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!)

    }

}

希望这对您有所帮助。