如何在条带节点中使用多个条带密钥? [英] How to use multiple Stripe secret keys with stripe-node?

查看:35
本文介绍了如何在条带节点中使用多个条带密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 stripe-node 库.我需要与多个条带帐户进行交互,每个帐户都有自己的密钥.最好的方法是什么?

I'm using stripe-node library. I need to interact with several stripe accounts, each one with their own secret key. What's the best way to do that?

有没有办法为每个请求指定密钥,例如:

Is there a way to specify the secret key for each request, like:

stripe.charges.create({
  auth: secret_key_1,
  ...
});
stripe.charges.create({
  auth: secret_key_2,
  ...
});

我想到的一种解决方法是简单地为每个帐户实例化一个单独的条带实例.

One workaround I thought of is simply instantiating a separate stripe instance for each account.

推荐答案

正如 中所述文档您可以像这样在每个请求的基础上设置 api_key:

As it states in the documentation you can set the api_key on a per-request basis like this:

stripe.charges.retrieve("ch_1AqjPcJWCk4FIh3mWQ3Hvmvi", {
  api_key: "sk_test_nra5nLtBVqMvXCoYROwWQFRG"
});

唯一的另一种选择是拥有其他答案中已经提到的多个实例.

The only other alternative is to have multiple instances as already mentioned in other answers.

这篇关于如何在条带节点中使用多个条带密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆