问题描述
我正试图为分行客户保存一张信用卡,但是,当我实施分行提供的测试卡时(42424242 ...),我收到消息:“您的卡已被拒绝”。
这是我试图解决的问题:
- 请确保使用我的测试密钥,而不是实时的
- 尝试过国际信用卡(因为我位于墨西哥)
- 确保我得到了临时密钥
- 尝试使用真实的信用卡进行实时测试,即使我除了输入信用卡而不要求收取任何费用外,我仍然收到消息“您的卡已被拒绝”
注意:我正在关注的教程使用了一种名为.createCardSources = true的方法,但是,我认为它已被贬值。
这是我的功能:
func setupStripeConfig() {
//2.) Create stripe payment configuration
let config = STPPaymentConfiguration.shared()
#warning(".createCard sources not appearing")
// config.createCardSources --> Doesn't show
config.requiredBillingAddressFields = .none
//1.)we need that customer context found in Stripe Api
//this will invoke the cloud function,generate the ephemeral key,pass it back and this customer context class will prefetch the stripe customer's @R_136_4045@ion from it's stripe object (say saved credit cards)
let customerContext = STPCustomerContext(keyProvider: StripeApi)
//3.)Now we need to create stripe payment context
paymentContext = STPPaymentContext(customerContext: customerContext,configuration: config,theme: .default())
//4.) Set payment context,payment amount
paymentContext.paymentAmount = self.stripetotal!
//5.)Set payment context & delegate
paymentContext.delegate = self
paymentContext.hostViewController = self
}
我正在接收临时密钥,所以这不应该成为问题,但是我还将代码放在这里:
import Foundation
import Stripe
import FirebaseFunctions
let StripeApi = _StripeApi()
class _StripeApi: NSObject,STPEphemeralKeyProvider {
func createCustomerKey(withAPIVersion apiVersion: String,completion: @escaping STPJSONResponseCompletionBlock) {
//data object
let data = [
"stripe_version": apiVersion,"customer_id": UserService.user.stripeId
]
print("API VERSION: \(apiVersion)")
print("CUSTOMER ID: \(UserService.user.stripeId)")
//This will invoke our cloud function
//you need to create a data object and then pass it to this function
Functions.functions().httpsCallable("createEphemeralKey").call(data) { (result,error) in
//ephemeral key should be found in result
if let error = error {
print("Error in StripeApi.swift \(error)")
//if we have an error we will need to pass completion (nil for json) and error for error
completion(nil,error)
return
}
guard let key = result?.data as? [String: Any] else {
completion(nil,nil)
return
}
//if we do get the key,we'll pass it over in completion and put nil for error
completion(key,nil)
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)