【问题标题】:How to retrieve the Stripe fee for a payment from a connected account (Node.js)如何从连接的帐户(Node.js)中检索付款的 Stripe 费用
【发布时间】:2020-12-02 06:29:56
【问题描述】:

我一直在阅读有关如何从给定付款here 中检索 Stripe 费用的文档:

// Set your secret key. Remember to switch to your live secret key in production!
// See your keys here: https://dashboard.stripe.com/account/apikeys
const stripe = require('stripe')('sk_test_xyz');

const paymentIntent = await stripe.paymentIntents.retrieve(
  'pi_1Gpl8kLHughnNhxyIb1RvRTu',
  {
    expand: ['charges.data.balance_transaction'],
  }
);

const feeDetails = paymentIntent.charges.data[0].balance_transaction.fee_details;

但是,我想检索支付给关联帐户的 Stripe 费用。如果我使用链接帐户的付款意图尝试上述代码,则会收到错误消息:

Error: No such payment_intent: 'pi_1Gpl8kLHughnNhxyIb1RvRTu'

但是,当我从 webhook 收到发布的数据时,我实际上可以看到列出的付款意图:

{ id: 'evt_1HFJfyLNyLwMDlAN7ItaNezN',
   object: 'event',
   account: 'acct_1FxPu7LTTTTMDlAN',
   api_version: '2019-02-11',
   created: 1597237650,
   data:
    { object:
       { id: 'pi_1Gpl8kLHughnNhxyIb1RvRTu',
         object: 'payment_intent',

有什么建议吗?

【问题讨论】:

    标签: node.js stripe-payments


    【解决方案1】:

    我想检索支付给已连接网络的 Stripe 费用 帐户。如果我尝试使用来自链接的付款意图的上述代码 帐户我收到错误:

    为了检索代表关联账户(使用direct Charge)进行的付款的 Stripe 费用,您需要通过在请求中指定特殊的 Stripe-Account 标头来作为关联账户发出检索请求。使用stripe-node 时,如果您传入account ID as part of the request options,我们将自动为您添加该标题。例如:

      const paymentIntent = await stripe.paymentIntents.retrieve(
        "pi_1HCSheKNuiVAYpc7siO5HkJC",
        {
          expand: ["charges.data.balance_transaction"],
        },
        {
          stripeAccount: "acct_1GDvMqKNuiVAYpc7",
        }
      );
    

    您可以在此处阅读有关代表条带节点和我们其他库中的已连接帐户发出请求的更多信息:https://stripe.com/docs/api/connected_accounts

    【讨论】:

      猜你喜欢
      • 2020-03-07
      • 1970-01-01
      • 2017-08-01
      • 1970-01-01
      • 2021-07-20
      • 2021-03-03
      • 1970-01-01
      • 2021-05-21
      • 2021-03-18
      相关资源
      最近更新 更多