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

React Native与Node.js项目集成PayPal/Stripe:实现付款直连商家

平台型电商直连卖家账户的支付集成方案

针对你的React Native + Node.js电商APP需求,以下是PayPal和Stripe两种支付网关的实现方案,核心是通过平台商户功能将资金直接划转至对应卖家账户:


PayPal 实现方案

前置准备

  • 平台需注册PayPal for Marketplaces,完成平台资质审核。
  • 为每个入驻卖家创建/绑定PayPal商户账户,获取并存储卖家的merchant_id。

Node.js 后端核心代码

创建订单时指定收款卖家的商户ID,资金将直接进入该账户:

const paypal = require('@paypal/checkout-server-sdk');
// 初始化PayPal客户端(使用平台的API密钥)
const client = new paypal.core.PayPalHttpClient(new paypal.core.SandboxEnvironment('CLIENT_ID', 'CLIENT_SECRET'));

// 创建订单接口
async function createPayPalOrder(req, res) {
  const { totalAmount, sellerMerchantId } = req.body;
  const request = new paypal.orders.OrdersCreateRequest();
  request.prefer('return=representation');
  request.requestBody({
    intent: 'CAPTURE',
    purchase_units: [{
      amount: {
        currency_code: 'USD',
        value: totalAmount.toString()
      },
      payee: {
        merchant_id: sellerMerchantId // 指定收款的卖家商户ID
      }
    }]
  });

  try {
    const order = await client.execute(request);
    res.json({ id: order.result.id });
  } catch (err) {
    res.status(500).json({ error: err.message });
  }
}

支付完成后,调用订单捕获接口,资金会直接进入卖家账户,无需经过平台账户。

React Native 前端

使用官方react-native-paypal库,传入后端生成的订单ID发起支付,流程与普通PayPal支付一致,无需额外修改。


Stripe 实现方案

前置准备

  • 开通Stripe Connect,为每个卖家创建Connected Account(推荐Express类型,快速接入),获取并存储卖家的account_id。

Node.js 后端核心代码

创建PaymentIntent时指定卖家的Connected Account ID,支付成功后自动划转资金:

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

// 创建支付Intent接口
async function createStripePaymentIntent(req, res) {
  const { totalAmount, sellerAccountId } = req.body;
  try {
    const paymentIntent = await stripe.paymentIntents.create({
      amount: Math.round(totalAmount * 100), // Stripe使用最小货币单位
      currency: 'usd',
      transfer_data: {
        destination: sellerAccountId // 指定收款的卖家Connected Account ID
      },
      // 可选:设置平台手续费
      application_fee_amount: Math.round(totalAmount * 100 * 0.05) // 5%手续费
    });
    res.json({ clientSecret: paymentIntent.client_secret });
  } catch (err) {
    res.status(500).json({ error: err.message });
  }
}

React Native 前端

使用@stripe/stripe-react-native库,通过后端返回的clientSecret初始化支付组件,完成支付流程即可,资金划转逻辑由Stripe自动处理。


关键注意事项

  • 两种方案都需要平台完成支付网关的平台业务资质审核,确保符合监管要求。
  • 卖家需完成PayPal/Stripe的实名认证,否则无法接收资金。
  • 平台需维护卖家账户与对应merchant_id/account_id的关联关系,确保订单与卖家正确绑定。

内容的提问来源于stack exchange,提问作者Dhiraj Borse

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 14:15:30