【发布时间】:2018-10-30 03:00:39
【问题描述】:
假设以下代码:
const stripe = window.Stripe('pk_xxx', { stripeAccount: 'acct_xxx' });
const elements = stripe.elements();
const card = elements.create('card');
stripe.createToken(card);
它在 4 种可能的设置中的 3 种成功(测试环境进行 LIVE 条带调用,测试环境进行 TEST 条带调用,实时环境进行 LIVE 条带调用),但在实时环境中进行 TEST 条带调用时则失败。
失败并出现 403 错误和以下响应:
{
"error": {
"code": "secret_key_required",
"doc_url": "https://stripe.com/docs/error-codes/secret-key-required",
"message": "This API call cannot be made with a publishable API key. Please use a secret API key. You can find a list of your API keys at https://dashboard.stripe.com/account/apikeys.",
"type": "invalid_request_error"
}
}
JS 调用如何需要密钥?每个人都会看到它。
这是 HTTP 请求:
card[number]: 4242424242424242
card[cvc]: 242
card[exp_month]: 04
card[exp_year]: 24
card[address_zip]: 42424
guid: 282d554c-4271-4730-9df4-ad142b19a812
muid: 722e4d63-4df0-40db-8d60-100f841d1718
sid: d5f44fce-9835-497b-a4dd-766894b4c23a
payment_user_agent: stripe.js/3b5fc4c8; stripe-js-v3/3b5fc4c8
referrer: https://app.myowndomain.com/
key: pk_test_xxx (also tried the pk_live_xxx - no difference)
_stripe_account: acct_xxx
【问题讨论】:
标签: stripe-payments