next.js STRIPE,收款,然后支付给IBAN

z8dt9xmd  于 2023-08-04  发布在  其他
关注(0)|答案(1)|浏览(77)

我有应用程序,用户将支付一些钱,也用户将支付平台费.我在STRIPE有账户,平台费会打到STRIPE账户。全价将转到IBAN帐户。我收到错误:
StripeInvalidRequestError:无此目的地:1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
你能告诉我为什么我得到这个错误吗?是否有错误的IBAN格式,或者我应该使用不同的付款方式?谢谢你的帮助

const handler = async (req, res) => {

  const Price = req.body.Price * 100
  const id = req.body.id

  const fees = (Price * 15) / 100

  const item = await Product.findById(id) // I am getting product, all good

  console.log('item iban', item.iban) //  SK1111111111111111111111

  const session = await stripe.checkout.sessions.create({
    payment_method_types: ['card'],
    line_items: [
      {
        name: item.name,
        amount: Price,
        currency: 'EUR',
        quantity: 1,
      },
    ],

     payment_intent_data: {
      application_fee_amount: fees,
      transfer_data: {
        destination: item.iban || null
      }
    },  

    success_url: process.env.STRIPE_SUCCESS_URL,
    cancel_url: process.env.STRIPE_CANCEL_URL,
  });

     console.log(session)    
   
}

export default handler

字符串

jvlzgdj9

jvlzgdj91#

您遇到的错误,
"StripeInvalidRequestError:无此目的地:'SK11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
提示您在transfer_data对象中提供的目标IBAN可能存在问题。
transfer_data对象中的destination字段需要一个有效的银行帐户ID或令牌,用于将平台费用转移到的连接帐户。但是,在您的代码中,您似乎直接将连接帐户的IBAN作为目标传递。这可能是错误的原因。
要解决此问题,您需要为连接的帐户(平台费用将转移到的Stripe帐户)创建令牌或银行帐户ID。您不能直接使用IBAN。
以下是如何为已连接的帐户创建银行帐户令牌:

      • 检索连接的帐户ID:**在创建令牌之前,请确保您已从Stripe帐户中检索到正确的连接帐户ID。
      • 创建银行账户令牌:**使用Stripe API为已连接的账户创建银行账户令牌。您可以使用Stripe Node.js
const connectedAccountId = 'acct_XXXXXXXXXXXX'; // Replace this with the actual connected account ID
const bankAccountToken = await stripe.tokens.create({
  bank_account: {
    country: 'SK',
    currency: 'eur',
    account_holder_name: 'Account Holder Name', // Replace with actual account holder name
    account_holder_type: 'individual',
    iban: 'SK1111111111111111111111', // Replace with actual IBAN
  },
}, {
  stripeAccount: connectedAccountId,
});

字符串

      • 在transfer_data中使用银行账户令牌:**现在您已经拥有了银行账户令牌,您可以将其用作transfer_data对象中的目标
const session = await stripe.checkout.sessions.create({
  // ... other session parameters ...

  payment_intent_data: {
    application_fee_amount: fees,
    transfer_data: {
      destination: bankAccountToken.id,
    },
  },

  // ... other session parameters ...
});

相关问题