TelrSDK 2.9.2

TelrSDK 2.9.2

Telr Sdk维护。



TelrSDK 2.9.2

  • Telr Sdk

TelrSDK- 更新

Version License Platform

我们的使命是建立连接,消除电子商务生态系统的碎片化。我们通过这些连接,使我们的客户无现金化,数字化接受支付的方式。使用这个链接开始。

入门

使用这个链接开始。

在Telr注册

使用这个链接找到在我们的系统中注册的步骤。

要求

Telr iOS SDK需要Xcode 11或更新的版本,并兼容针对iOS 9或更高版本的应用。我们支持macOS 10.15或更高版本的Catalyst。

自定义安装

使用此链接查找自定义API。

示例

要运行示例项目,先克隆存储库,然后在Example目录中运行pod install

安装

TelrSDK可通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中

pod 'TelrSDK', "2.9.1"

请确保使用以下代码导入您想要使用的SDK的位置

import TelrSDK

使用此方法设置商店的详细信息。请确保您使用自己的商店详细信息

let tabbyKEY:String = "pk_test_d878b6de-9f6f-4c2c-bc8c-fde1b249b9c4"

let KEY:String = " jT4F2^PjBp-n8jbr" // TODO fill key
let STOREID:String = "24717"  // TODO fill store id
let EMAIL:String = "[email protected]" // TODO fill email id

要调用支付页面,您可以使用两种方法中的任意一种

//Mark:-If you want to change the back button as custom back button on navigation
let customBackButton = UIButton(type: .custom)
customBackButton.setTitle("Back", for: .normal)
customBackButton.setTitleColor(.black, for: .normal)

//Mark:-Use this to push the telr payment page.
paymentRequest = preparePaymentRequest()
let telrController = TelrController()
telrController.delegate = self
telrController.customBackButton = customBackButton
telrController.paymentRequest = paymentRequest!
self.navigationController?.pushViewController(telrController, animated: true)

//Mark:-Use this to present the telr payment page.
paymentRequest = preparePaymentRequestSaveCard(lastresponse: cardDetails)
let telrController = TelrController()
telrController.delegate = self
telrController.paymentRequest = paymentRequest!
let nav = UINavigationController(rootViewController: telrController)
self.navigationController?.present(nav, animated: true, completion: nil)

用于从支付网关获取响应的代理方法

//Mark:-This call when the payment is cancelled by user
func didPaymentCancel()
//Mark:-This call when the payment is successful.
func didPaymentSuccess(response:TelrResponseModel)
//Mark:-This call when the payment is declined due to any reason.
func didPaymentFail(messge:String)

还要确认代理方法

extension ViewController:TelrControllerDelegate{
    
    
    //Mark:- This method will be called when user clicks on back button
    func didPaymentCancel() {
        print("didPaymentCancel")
        
    }
    
    //Mark:- This method will be called when the payment is completed successfully
    func didPaymentSuccess(response: TelrResponseModel) {
        
        print("didPaymentSuccess")
           
        print("month \(String(describing: response.month))")
           
        print("year \(String(describing: response.year))")
              
        print("Trace \(String(describing: response.trace))")
        
        print("Status \(String(describing: response.status))")
        
        print("Avs \(String(describing: response.avs))")
        
        print("Code \(String(describing: response.code))")
        
        print("Ca_valid \(String(describing: response.ca_valid))")
        
        print("Card Code \(String(describing: response.cardCode))")
        
        print("Card Last4 \(String(describing: response.cardLast4))")
        
        print("CVV \(String(describing: response.cvv))")
        
        print("TransRef \(String(describing: response.transRef))")
        
        //To save the card for future transactions, you will be required to store tranRef. 
        //When the customer will be attempting transaction using the previously used card tranRef will be used
        
        self.displaySavedCard()
      
      
    }
    
    //Mark:- This method will be called when user clicks on cancel button and the
    payment gets failed
    func didPaymentFail(messge: String) {
        print("didPaymentFail  \(messge)")
        
    }
    
   
        
}

已保存的卡片

(在本地使用用户默认设置时,屏蔽卡详情将在应用被删除时被删除)

//Mark:- This returns masked card details of saved card.
let savedCard = TelrResponseModel().getSavedCards()

在绑定支付请求时,请使用以下代码来使用不带CVV的已保存卡片

//Mark:- Set type assale’, class ascontand send previous transaction reference inrefparameter

paymentReq.transType = "sale"
paymentReq.transClass = "cont"
paymentReq.transRef = lastresponse.transRef ?? ""

在绑定支付请求时,请使用以下代码来使用带CVV的已保存卡片

//Mark:- Set type aspaypageand class asecomand send previous transaction reference infirstrefparameter


paymentReq.transType = "paypage"
paymentReq.transClass = "ecom"
paymentReq.transFirstRef = lastresponse.transFirstRef ?? ""

为已保存卡片和新卡片创建支付请求

//Mark:- Payment Request Builder
extension ViewController{
    
    private func preparePaymentRequest() -> PaymentRequest{
    
    
        let paymentReq = PaymentRequest()
    
        paymentReq.key = KEY
   
        paymentReq.store = STOREID
    
        paymentReq.appId = "123456789"
   
        paymentReq.appName = "TelrSDK"
    
        paymentReq.appUser = "123456"
    
        paymentReq.appVersion = "0.0.1"
    
        paymentReq.transTest = "1"//0
   
        paymentReq.transType = "paypage"
   
        paymentReq.transClass = "ecom"
    
        paymentReq.transCartid = String(arc4random())
    
        paymentReq.transDesc = "Test API"
    
        paymentReq.transCurrency = "AED"
    
        paymentReq.transAmount = amountTxt.text!
    
        paymentReq.billingEmail = EMAIL
        
        paymentReq.billingPhone = "8888888888"
    
        paymentReq.billingFName = self.firstNameTxt.text!
    
        paymentReq.billingLName = self.lastNameTxt.text!
    
        paymentReq.billingTitle = "Mr"
    
        paymentReq.city = "Dubai"
    
        paymentReq.country = "AE"
    
        paymentReq.region = "Dubai"
    
        paymentReq.address = "line 1"
        
        paymentReq.zip = "414202"
    
        paymentReq.language = "en"
    
        return paymentReq

    }
    
    private func preparePaymentRequestSaveCard(lastresponse:TelrResponseModel) -> PaymentRequest{

     
        let paymentReq = PaymentRequest()
     
        paymentReq.key = lastresponse.key ?? ""
     
        paymentReq.store = lastresponse.store ?? ""
     
        paymentReq.appId = lastresponse.appId ?? ""
     
        paymentReq.appName = lastresponse.appName ?? ""
     
        paymentReq.appUser = lastresponse.appUser ?? ""
     
        paymentReq.appVersion = lastresponse.appVersion ?? ""
     
        paymentReq.transTest = lastresponse.transTest ?? ""
        
//        //Mark:- Without CVV
//
//        paymentReq.transType = "sale"
//
//        paymentReq.transClass = "cont"
        
//        paymentReq.transRef = lastresponse.transRef ?? ""
        
        
        //Mark:- With CVV

        paymentReq.transType = "paypage"

        paymentReq.transClass = "ecom"
        
        paymentReq.transFirstRef = lastresponse.transFirstRef ?? ""
        
        //
        
        paymentReq.transCartid = String(arc4random())
     
        paymentReq.transDesc = lastresponse.transDesc ?? ""
     
        paymentReq.transCurrency = lastresponse.transCurrency ?? ""
     
        paymentReq.billingFName = lastresponse.billingFName ?? ""
     
        paymentReq.billingLName = lastresponse.billingLName ?? ""
     
        paymentReq.billingTitle = lastresponse.billingTitle ?? ""
     
        paymentReq.city = lastresponse.city ?? ""
     
        paymentReq.country = lastresponse.country ?? ""
     
        paymentReq.region = lastresponse.region ?? ""
     
        paymentReq.address = lastresponse.address ?? ""
        
        paymentReq.zip = lastresponse.zip ?? ""
     
        paymentReq.transAmount = amountTxt.text!
            
        paymentReq.billingEmail = lastresponse.billingEmail ?? ""
     
        paymentReq.billingPhone = lastresponse.billingPhone ?? ""
     
        paymentReq.language = "en"
     
        return paymentReq

     }


}

授权响应

字段 描述
状态 授权状态。A表示已授权交易。H也指已授权交易,但交易已被挂起。任何其他值表示请求无法处理。
代码 如果交易已授权,则包含发卡行的授权代码。否则包含一个代码,表示交易无法处理的原因。
消息 授权或处理错误消息。
tranref 为该请求分配给支付网关的交易参考。
cvv CVV检查结果:Y = CVV匹配正常 N = CVV不匹配 X = 未检查CVV E = 错误,无法检查CVV
avs AVS检查结果:Y = AVS匹配正常 P = 部分匹配(例如,仅邮政编码) N = AVS不匹配 X = 未检查AVS E = 错误,无法检查AVS
cardcode 用于指示交易中使用的卡片类型的代码。请参阅文档末尾的代码表以获取卡片代码列表。
cardlast4 交易中使用的卡号的最后4位。这适用于所有支付类型(包括托管支付页面方法),但 excludes PayPal。

测试卡片

这些卡号可用于测试您与支付网关的集成。这些卡号不适用于真实交易。

卡号 类型 CVV MPI
4111 1111 1111 1111 Visa 123
4444 3333 2222 1111 Visa 123
4444 4244 4444 4440 Visa 123
4444 4444 4444 4448 Visa 123
4012 8888 8888 1881 Visa 123
5105 1051 0510 5100 Mastercard 123
5454 5454 5454 5454 Mastercard 123
5555 5555 5555 4444 Mastercard 123
5555 5555 5555 5557 Mastercard 123
5581 5822 2222 2229 Mastercard 123
5641 8209 0009 7002 Maestro UK 123
6767 0957 4000 0005 Solo 123
3434 343434 34343 American Express 1234
3566 0020 2014 0006 JCB 123

作者

Telr SDK, [email protected]

许可证

TelrSDK遵循MIT许可证。有关更多信息,请参阅LICENSE文件。