Примите следующий код:
const stripe = window.Stripe('pk_xxx', { stripeAccount: 'acct_xxx' });
const elements = stripe.elements();
const card = elements.create('card');
stripe.createToken(card);
Успешно выполняется 3 из 4 возможных установок (тестовая среда, выполняющая вызовы полосы 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