stripe.payouts.create 上没有此类外部帐户

问题描述 投票:0回答:1

代码:

var accounts = await stripe.accounts.listExternalAccounts(userSensitiveData.stripe_account_id.S!, {
    object: 'bank_account'
})
console.log('accounts:', accounts)

const payout = await stripe.payouts.create({
    amount: combined[i].amount * 100, // Amount in the smallest currency unit (e.g., 10000 yen for 100 yen)
    currency: 'jpy',
    destination: userSensitiveData.stripe_bank_id.S,
    source_type: 'bank_account'
});

我可以通过 listExternalAccounts 查看银行帐户。

accounts: {
      object: 'list',
      data: [
        {
          id: 'ba_1QDbLrEAwtXI7T4QpEC3MaB0',
          object: 'bank_account',
          account: 'acct_1QDbLpEAwtXI7T4Q',
          account_holder_name: 'Tenna Churiki',
          account_holder_type: 'individual',
          account_type: 'futsu',
          available_payout_methods: [Array],
          bank_name: 'STRIPE TEST BANK',
          country: 'JP',
          currency: 'jpy',
          default_for_currency: true,
          fingerprint: 'cg0FOuoUMjAmco18',
          future_requirements: [Object],
          last4: '1234',
          metadata: {},
          requirements: [Object],
          routing_number: '1100000',
          status: 'new'
        }
      ],
      has_more: false,
      url: '/v1/accounts/acct_1QDbLpEAwtXI7T4Q/external_accounts'
    }

但是,如果没有这样的外部帐户,付款就会失败。

ERROR   Error: ji [Error]: No such external account: 'ba_1QDbLrEAwtXI7T4QpEC3MaB0'
        at Wi (file:///var/task/index.mjs:38:21669)
        at n.toJSON.then.zr.message (file:///var/task/index.mjs:38:30324)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
      type: 'StripeInvalidRequestError',
      raw: {
        code: 'resource_missing',
        doc_url: 'https://stripe.com/docs/error-codes/resource-missing',
        message: "No such external account: 'ba_1QDbLrEAwtXI7T4QpEC3MaB0'",
        param: 'destination',
        request_log_url: 'https://dashboard.stripe.com/test/logs/req_0n6k8JKCyEpUiW?t=1729817955',
        type: 'invalid_request_error',

从listExternalAccounts获取的银行账户不是外部账户吗? 我还尝试将帐户 ID 作为目的地传递,但也因相同的错误而失败。

stripe-payments
1个回答
0
投票

外部帐户存在于不同的 Stripe 帐户上,您可以通过定义要为其列出外部帐户的 Stripe 帐户来判断,即

userSensitiveData.stripe_account_id.S!

当您请求创建付款时,您还需要在外部账户所在的 Stripe 账户上发出请求。您需要使用 StripeAccount 标头来执行此操作。请参阅https://stripe.com/docs/connect/authentication

示例

  const payout = await stripe.payouts.create({
    amount: combined[i].amount * 100, // Amount in the smallest currency unit (e.g., 10000 yen for 100 yen)
    currency: 'jpy',
    destination: userSensitiveData.stripe_bank_id.S,
    source_type: 'bank_account'
  },
  {
    stripe_account: userSensitiveData.stripe_account_id.S!
  });
© www.soinside.com 2019 - 2024. All rights reserved.