[英]Stripe IOS SDK not matching AllResponseFields?
我正在尝试对客户进行简单的计数检查,以查看他们是否需要在移至另一页之前添加源。 但是,我对STPCustomer对象的属性的调用与完整响应的信息不匹配。
我已经尝试清除客户缓存并重新加载客户,但是...仍然没有匹配项。
这是一个截断的基本代码。 该类具有STPPaymentContextDelegate附加。
private var customerContext = STPCustomerContext?
private var paymentContext = STPPaymentContext?
func setupStripe() {
self.paymentContext = STPPaymentContext(customerContext: self.customerContext!)
self.paymentContext?.hostViewController = self
self.paymentContext?.delegate = self
self.paymentView = STPPaymentMethodsViewController(configuration: STPPaymentConfiguration.shared(), theme: STPTheme.default(), customerContext: self.customerContext!, delegate: self)
}
func getCustomerSources() {
if let customer = customerContext.retrieveCustomer({ (customer, error) in
if customer != nil {
print(customer.sources.count)
print(customer.sources)
print(customer.allResponseFields)
}
})
}
当我在测试客户上运行getCustomerSources()
时,我期望:
1
[ba_1Dvf46LrBVaGM6Sq9qIYhOlJ]
AnyHashable("id"): cus_number, AnyHashable("email"): rosa_diaz@gmail.com, AnyHashable("default_source"): ba_1Dvf46LrBVaGM6Sq9qIYhOlJ, AnyHashable("created"): 1548220659, AnyHashable("description"): LiG8WbVhT8SVhta8LdfUuWzOwQn2, AnyHashable("livemode"): 0, AnyHashable("object"): customer, AnyHashable("sources"): {
data = (
{
"bank_name" = "STRIPE TEST BANK";
country = US;
currency = usd;
customer = "cus_EOQzwwGPjzopjS";
fingerprint = 1AQMB9nzeGSGXHst;
id = "ba_1Dvf46LrBVaGM6Sq9qIYhOlJ";
last4 = 6789;
metadata = {
};
object = "bank_account";
"routing_number" = 110000000;
status = verified;
}
);
"has_more" = 0;
object = list;
"total_count" = 1;
url = "/v1/customers/cus_EOQzwwGPjzopjS/sources";
}])
但是,我得到的是0
和[]
,而不是我的1
和ba_1Dvf46LrBVaGM6Sq9qIYhOlJ
。 但是 allResponseFields部分相同。
关于为什么STPCustomer对象属性返回的内容与实际响应告诉我的内容之间存在差异的任何想法?
如果不了解回调函数接收到的error
参数,很难说是怎么回事。 听起来好像在解析API响应时可能有错误,并且打印传递到您的retrieveCustomer
块中的error
应该使您对发生的事情有更好的了解。 如果错误仍然存在,我建议您联系support@stripe.com并提供详细信息,因为它们可以直接解决iOS应用问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.