ruby 使用const为已连接的帐户添加stripe_account_id时出现CORS错误

zour9fqk  于 2023-08-04  发布在  Ruby
关注(0)|答案(1)|浏览(92)

我已经设置了Stripe付款请求按钮,当我手动添加stripeAccount时,一切正常:'acct_XXX...',则在该连接账户的 Jmeter 板上支付成功。
但是当我尝试把它放在payment_request_buttons.js的const中时:

const stripe_account_id = document.getElementById('stripe_account_id').value;

const stripe = Stripe('pk_test_XXX...'), {
  apiVersion: "2022-11-15",
  stripeAccount: stripe_account_id,
});

字符串
隐藏的输入:

<input id="stripe_account_id" type="hidden" value="<%= "'#{@user.stripe_account_id}'" %>">


我得到这个CORS错误:

No 'Access-Control-Allow-Origin' header is present


我不明白手动输入帐户和使用const有什么区别?
我刚刚在控制台中的条带链接中遇到了此错误:

{
"error": {
"message": "You did not provide an API key. You need to 
provide your API key in the Authorization header, using 
Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). 
See https://stripe.com/docs/api#authentication for details, 
or we can help at https://support.stripe.com/.",
"type": "invalid_request_error"
 }
}

wh6knrhe

wh6knrhe1#

我解决了这个错误。 当手动传递分条帐户时,您使用撇号“”,其中包含帐户号码,但当查看要分条的发布数据时,您会看到它们被删除:

_stripe_account: acct_xxx........... 

字符串
所以在我的Ruby代码中,我在值中添加了撇号,结果是:

value="<%= "'#{@user.stripe_account_id}'" %>">

_stripe_account: 'acct_xxx...........' 


发送导致错误。 我更新的没有撇号的Ruby代码:

value="<%= @user.stripe_account_id %>">


此数据位于Network > wallet-config > Payload > Form Data
这现在已经解决了CORS错误并正在工作。

相关问题