【发布时间】:2021-01-10 11:09:36
【问题描述】:
第 1 步:
CustomerSession.initCustomerSession
第 2 步:
CustomerSession.getInstance().retrieveCurrentCustomer
第 3 步:
我得到了客户(测试环境):{"hasMore":false,"id":"cus_I4xevY1VmbpCGL","sources":[],"totalCount":0,"url":"/v1/customers /cus_I4xevY1VmbpCGL/sources"}
但来源是空的,尽管在条纹仪表板中我可以看到付款方式(卡)已保存。
【问题讨论】:
-
customer.sources在最新的 API 版本中被删除:stripe.com/docs/upgrades#2020-08-27(它通常也已被弃用,您应该使用 PaymentMethods,例如 stripe.dev/stripe-android/stripe/com.stripe.android/…) -
如果您确实需要它,您应该使用比最新版本更旧的 API 版本创建您的临时密钥,因为它是您在后端创建临时密钥时设置的版本,它决定了 API 版本 CustomerSession使用,我想。
-
customer.sources 也只返回旧卡对象,我认为这可能是这里的问题。真正的解决方案是像我提到的那样使用
customerSession.getPaymentMethods,这就是实现您的用例的方法。sources是遗留的,你应该忽略它。 -
你说得对……我用过