You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native出租车应用:如何通过Stripe实现乘客直接向司机付款?

实现用户直接向司机付款的Stripe方案

要实现用户付款直接到司机账户,核心是用Stripe Connect,它专门解决平台类应用的资金分账问题。以下是具体实现步骤:

1. 为司机创建Stripe Connect账户

首先需要让每个司机注册Stripe Connect账户,推荐用Express账户(平台托管式,流程简单,符合网约车场景):

  • 你的后端调用Stripe的accounts.create接口,创建Express账户,返回账户链接(account_link)
  • 司机通过该链接完成身份验证(KYC)、绑定收款账户等操作
  • 完成后,在后端存储司机的Stripe account_id,后续转账依赖这个ID

示例后端代码(Node.js):

const stripe = require('stripe')('你的平台Secret Key');

const createDriverAccount = async () => {
  const account = await stripe.accounts.create({
    type: 'express',
    country: 'CN', // 根据司机所在地区调整
    email: 'driver@example.com',
    capabilities: {
      card_payments: { requested: true },
      transfers: { requested: true },
    },
  });

  const accountLink = await stripe.accountLinks.create({
    account: account.id,
    refresh_url: 'https://your-app.com/driver/refresh',
    return_url: 'https://your-app.com/driver/success',
    type: 'account_onboarding',
  });

  return { accountId: account.id, onboardingUrl: accountLink.url };
};

2. 用户付款时直接分账给司机

有两种主流方式,根据业务场景选择:

方式一:Destination Charges(实时分账)

用户付款时,直接将资金拆分到司机账户和平台账户(平台可收取手续费),适合服务完成后立即付款的场景:

  • 后端创建PaymentIntent时,指定transfer_data[destination]为司机的account_id,同时设置application_fee_amount作为平台手续费

示例代码:

const createPaymentIntent = async (amount, driverAccountId) => {
  const paymentIntent = await stripe.paymentIntents.create({
    amount: amount * 100, // Stripe用最小单位,比如人民币分
    currency: 'cny',
    payment_method_types: ['card'],
    transfer_data: {
      destination: driverAccountId, // 司机的Stripe账户ID
    },
    application_fee_amount: Math.round(amount * 0.1 * 100), // 10%手续费
  });

  return { clientSecret: paymentIntent.client_secret };
};

React Native端正常调用Stripe SDK,用返回的clientSecret完成支付即可,资金会实时分到司机和平台账户。

方式二:延迟转账(先收平台再转司机)

如果需要确认服务完成后再给司机打款,先将用户付款收到平台账户,之后调用转账接口:

  1. 先创建普通PaymentIntent,不指定transfer_data,资金进入平台账户
  2. 服务完成后,调用Stripe的Transfers API,将对应金额转到司机账户

示例转账代码:

const transferToDriver = async (amount, driverAccountId) => {
  const transfer = await stripe.transfers.create({
    amount: amount * 100,
    currency: 'cny',
    destination: driverAccountId,
  });
  return transfer;
};

关键注意事项

  • 司机的Connect账户必须完成身份验证(KYC),否则无法接收转账,可通过Stripe Dashboard或API检查账户状态
  • 不同地区的Stripe政策不同,比如手续费、转账限额等,需提前确认合规要求
  • 平台需要在Stripe Dashboard配置Connect相关设置,比如默认手续费、转账规则

内容的提问来源于stack exchange,提问作者Ali Akram

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 07:27:53