EasyPaymentKit
EasyPaymentKit 是什么?
EasyPaymentKit 是一种可定制的支付接受方式,附带预设的用户界面,可以接受信用卡、借记卡和银行账户。
如何使用 EasyPaymentKit?
EasyPaymentKit 可以通过 cocoapod 获得。在 podfile 中复制以下行以添加 pod
pod 'EasyPaymentKit'
运行以下命令来使用库
pod install
如果您项目中没有 podfile,则创建 podfile,可以通过 pod init 来创建。您也可以手动集成,将源文件添加到项目
示例使用
接收卡片
在您的视图控制器中添加以下代码片段以显示信用卡或借记卡视图
let viewController = SFCardVC.init()
viewController.theme.SFControllerPresentation = .full
viewController.theme.isNegetiveButtonVisible = false
viewController.delegate = self
self.present(viewController, animated: true, completion: nil)
请确保您已添加您的支付网关公钥以通过
SFConfiguartion.shared.publicKey = "YOUR_PUBLIC_KEY"
将 ViewController 遵从 SFPaymentInfoAble。示例方法有
func didCardCreated(with info: SFCardInfo) {
}
func didErrorWhileGeneratingToken(reason error: String) {
}
示例接受卡截图
接受/添加账户
在您的视图控制器中添加以下代码以显示信用或借记卡视图:SFConfiguartion.shared.publicKey = "YOUR_PUBLIC_KEY" let viewController = SFAccountVC.init() viewController.theme.isCardNameFieldVisible = true viewController.theme.SFControllerPresentation = .full viewController.theme.isNegetiveButtonVisible = false viewController.delegate = self self.present(viewController, animated: true, completion: nil)
将 ViewController 遵从 SFPaymentInfoAble。示例方法有
func didBankAccountCreated(with token:String){
}
func didErrorWhileGeneratingToken(reason error: String) {
}