Stripe API参考说明了有关身份验证的信息:
他们给出的例子如下:
require "stripe"
Stripe.api_key = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"
Run Code Online (Sandbox Code Playgroud)
该sk_test_BQokikJOvBiI2HlWgH4olfQ2密钥是在条纹的网页账户设置中找到.我知道这是我的应用程序与Stripe交谈的秘密api密钥.
但后来我阅读了有关Stripe Connect入门的文档:
When using our official API libraries, we recommend that you pass in the
access_token with every request, instead of setting the API key globally.
This is because the access_token used in any API request depends on the user
you're charging on behalf of.
Run Code Online (Sandbox Code Playgroud)
他们给出的例子是:
# Not recommended: setting global API key state
Stripe.api_key = ACCESS_TOKEN
Stripe::Customer.create(
:description => "example@stripe.com"
)
# Recommended: sending …Run Code Online (Sandbox Code Playgroud)