AptoPCISDK
示例
要运行示例项目,请克隆仓库,然后首先从示例目录运行pod install
。
需求
安装
AptoPCISDK可通过CocoaPods获取。要安装它,只需将以下行添加到Podfile中
pod 'AptoPCISDK'
使用PCI SDK
要使用PCI SDK,只需实例化一个PCIView并将其添加到您的视图层次结构中。
view.addSubview(pciView)
pciView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
pciView.topAnchor.constraint(equalTo: topConstraint, constant: 40),
pciView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 20),
pciView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -20),
pciView.heightAnchor.constraint(equalToConstant: 240),
])
然后使用initialize方法初始化SDK
pciView.initialise(apiKey: "API_KEY",
userToken: "USER_TOKEN",
cardId: "CARD_ID",
lastFour: "1234",
environment: "sandbox")
注意:environment
参数的有效值是sandbox
和production
。
要显示卡的最后四位数字,使用以下代码片段:
pciView.lastFour()
要显示卡的完整数据,使用以下代码片段:
pciView.reveal()
PCI SDK将验证用户(如有需要)并显示卡片数据。
自定义PCI SDK
PCI SDK的外观和感觉可以通过不同的方式自定义
显示/隐藏元素
您可以选择PCI SDK显示哪些元素。有三个元素可以显示或隐藏
- 卡号(PAN)
- 安全码(CVV)
- 有效期
您还可以定义各种组件的CSS样式,包括
- IFrame(容器)
- 卡号字段
- 安全码字段
- 有效期字段
元素样式化
要自定义PCI外观和感觉,您可以使用以下代码片段
pciView.showPan = true
pciView.showCvv = false
pciView.showExp = false
pciView.styles = [
"container": "color: red",
"content": [
"pan": "color: blue",
"cvv": "color: yellow",
"exp": "color: green"
]
]
文本自定义
要自定义在警报中显示的不同文本,您可以使用以下属性
pciView.alertTexts = [
"inputCode.message": "What's your secret code?",
"inputCode.okAction": "Ok",
"inputCode.cancelAction": "Cancel",
"wrongCode.message": "Invalid code",
"wrongCode.okAction": "Ok"
]
作者
Pau Teruel, [email protected]
许可
AptoPCISDK在MIT许可下可用。更多信息请参阅LICENSE文件。