StripeAPI.defaultPublishableKey 和 STPAPIClient.shared.publishableKey 有什么区别?

What is the difference between StripeAPI.defaultPublishableKey and STPAPIClient.shared.publishableKey?

我知道这似乎是一个简单的问题,但我没有在文档中找到任何答案。有人可以解释一下 StripeAPI.defaultPublishableKeySTPAPIClient.shared.publishableKey 之间的区别吗?它们什么时候使用,具体用于什么?

我是编码新手,非常感谢您的帮助! :)

StripeAPI 是导入其余 Stripe iOS SDK 的顶级 class。 The documentation explains the defaultPublishableKey property on StripeAPI:

Set this to your Stripe publishable API key, obtained from https://dashboard.stripe.com/apikeys. Set this as early as possible in your application’s lifecycle, preferably in your AppDelegate or SceneDelegate. New instances of STPAPIClient will be initialized with this value. @warning Make sure not to ship your test API keys to the App Store! This will log a warning if you use your test key in a release build.

另一方面,

STPAPIClient 是您用来发出 Stripe API 请求的 class/singleton。这个class上的shared属性是单例,那个单例上的publishableKey属性默认是StripeAPI.defaultPublishableKey的值。但是,如果您需要使用不同的密钥发出请求,您可以更改它,尽管这样做是一种不常见的边缘情况。

你可以read more about STPAPIClient, including the properties mentioned above in Stripe's documentation.