条带错误:提交令牌到后端错误,未解决的标识符错误



我正在 iOS 上做一个条纹项目。我按照 stripe 网站上的入门指南进行了初步测试。

对于iOS应用程序,他们的SDK具有内置addCardViewController。所以我只是将代码复制并粘贴到我的ViewController文件中。但是,现在我遇到了一个错误,即未解析的标识符submitToBackEnd

谁能告诉我可能的问题是什么?

下面我添加了我使用的代码:

func addCardViewController(_ addCardViewController: STPAddCardViewController, didCreateToken token: STPToken, completion: @escaping STPErrorBlock) {
submitTokenToBackend(token, completion: { (error: Error?) in
if let error = error {
// Show error in add card view controller
completion(error)
}
else {
// Notify add card view controller that token creation was handled successfully
completion(nil)
// Dismiss add card view controller
dismiss(animated: true)
}
})
}

这是因为您缺少submitTokenToBackend函数声明。Stripe 文档假设您自己编写。(这里在代码块 https://stripe.com/docs/mobile/ios/custom#stpapiclient--stpcardparams 之后提到(

实现差异很大,具体取决于您用于将请求从应用发送到后端的内容。它不完全相同,但您可以查看标准示例的这一部分,了解它大致的工作原理:

https://github.com/stripe/stripe-ios/blob/master/Example/Standard%20Integration%20(Swift(/MyAPIClient.swift#L25

最新更新