为银行账户信息创建令牌 Stripe [英] Create token for bank account information Stripe
问题描述
我正在尝试创建一个 ios 应用程序,该应用程序使用 Stripe 安全地收集用户的银行帐户信息(目的是向用户付款).Stripe 建议我在 STPBankAccountParams
实例中收集银行信息.这还不错:
I am trying to create an ios app which safely collects a user's bank account information (with the intention of paying the user) using Stripe. Stripe recommends that I collect the bank information in an instance of STPBankAccountParams
. This is not too bad:
var bankAccount = STPBankAccountParams()
bankAccount.routingNumber = routingNumber
bankAccount.accountNumber = accountNumber
...
Stripe 建议您在发送到后端之前,出于安全目的对 bankAccount
进行标记.他们建议您使用此功能:
Stripe then recommends that you tokenize the bankAccount
for security purposes before sending to backend. They recommend you use this function:
func createToken(withBankAccount bankAccount: STPBankAccountParams, completion: STPTokenCompletionBlock? = nil)
关于这个函数的文档有点稀疏:文档
The documentation on this function is a bit sparse: Docs
我不确定如何在我的代码中运行这个函数.我想使用此函数并获取令牌,但我对如何在代码中执行此操作缺乏了解.我想运行类似的东西:
I am not sure how to run this function in my code. I want to use this function and get the token, but I lack understanding on how to do that in code. I want to run something like:
token = createToken(withBankAccount: bankAccount)
当然,我尝试过的那些和其他事情还没有奏效.有没有人有在 Stripe 中运行 createTokenWithBankAccount()
函数的经验?
But of course that and other things I have tried have not worked yet. Does anyone have experience running the createTokenWithBankAccount()
function in Stripe?
推荐答案
MadProgrammer 的回答非常接近,但实际上并没有奏效.我确实和 Stripe 的一位代表谈过.作为参考,他推荐了以下代码,这似乎有效:
MadProgrammer's answer was very close, but did not actually work. I did talk with a representative from Stripe. For reference, he recommended the following code, which seems to work:
STPAPIClient.shared().createToken(withBankAccount: bankAccount) { (token, error) in
if let error = error {
print(error)
}
else {
print(token)
}
}
这篇关于为银行账户信息创建令牌 Stripe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!