ios - 在“Stripe”集成时,类型“FundsVC”不符合 Swift 中的协议“STPAddCardViewControllerDelegate”
问题描述
我"Stripe"
在我的应用程序中使用支付网关..为此我已经在 Stripe 帐户中注册并获得了测试和密钥
我的代码是:
import Stripe
class FundsVC: UIViewController, STPAddCardViewControllerDelegate //here getting an error {
@IBAction func stripePaymentBtn(_ sender: Any) {
let config = STPPaymentConfiguration.shared()//here getting second error
config.requiredBillingAddressFields = .full
let viewController = STPAddCardViewController(configuration: config, theme: STPTheme.default())
viewController.delegate = self
let navigationController = UINavigationController(rootViewController: viewController)
present(navigationController, animated: true, completion: nil)
}
//MARK:- STPAdd Card Controller Delegate
func addCardViewControllerDidCancel(_ addCardViewController: STPAddCardViewController) {
dismiss(animated: true, completion: nil)
}
func addCardViewController(_ addCardViewController: STPAddCardViewController, didCreateToken token: STPToken, completion: @escaping STPErrorBlock) {
dismiss(animated: true, completion: nil)
}
}
请帮忙
错误
“WithdrawFundsVC”不符合协议“STPAddCardViewControllerDelegate”
无法调用非函数类型“STPPaymentConfiguration”的值
编辑
我已经更新了这样的代码:
func addCardViewControllerDidCancel(_ addCardViewController: STPAddCardViewController) {
dismiss(animated: true, completion: nil)
}
@objc
func addCardViewController(_ addCardViewController: STPAddCardViewController, didCreatePaymentMethod paymentMethod: STPPaymentMethod, completion: @escaping STPErrorBlock) {
dismiss(animated: true, completion: nil)
}
o/p 这里的完成按钮没有启用为什么?
解决方案
您正在关注与 stripe old pod 兼容的 stripe 实现的旧教程,但您使用的是最新的 stripe 版本。根据最新的 STPAddCardViewControllerDelegate文档,您应该需要这两种方法来确保其一致性
addCardViewControllerDidCancel(_:)
addCardViewController(_:didCreatePaymentMethod:completion:)
但你正在实施方法
addCardViewController(_:didCreateToken:completion:)
在最新版本中已弃用。您需要根据新版本更改您的实现。如果您仍想使用旧实现,请在您的 pod 文件中将 pod 版本修复为15.0.0。如果您遇到任何错误,请将 pod 版本更改为15.0.1。
推荐阅读
- php - 将 IF 语句添加到 PHP
- filter - 为什么我的 Jupyter Notebook 上没有交互元素?
- javascript - 坚持使用 D3.js – 使用多维数组构建一个在另一个之上的矩形
- r - 如何处理r中的变量未定义错误
- python-3.x - 我如何判断我的用户是否专注于终端?
- node.js - 将贝宝捕获和自定义订单保存到数据库
- jolt - 使用数组进行 JOLT 转换
- jenkins - 关于在jenkins中同时执行gradle项目的Spock集成测试的问题
- android - Facebook 受众网络竞价整合
- php - 插件 Joomla 3.x 登录后重定向 joomla 用户