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

如何实现类似Zomato或亚马逊平台的Escrow托管功能?

实现Escrow资金托管功能(仿Zomato/亚马逊模式)

一、Zomato/亚马逊的核心托管逻辑

  • 买家支付的资金不会直接打给卖家,而是先进入平台专属的托管账户(Escrow Account)
  • 平台确认商品/服务已成功交付(比如亚马逊物流签收、Zomato用户确认收餐)后,触发资金划转流程
  • 扣除平台佣金(若有),将剩余资金划转至卖家账户
  • 若出现退款纠纷,资金将留在托管账户,待纠纷解决后再做处理

二、用Stripe实现Escrow托管(Node.js)

Stripe的Connect功能原生支持托管场景,核心是结合PaymentIntent与转账API实现资金暂存与划转:

1. 创建卖家Connect账户

先为卖家创建Express类型的Connect账户(适合平台托管场景):

const stripe = require('stripe')('你的Stripe密钥');

// 创建卖家Connect账户
const createSellerAccount = async () => {
  const account = await stripe.accounts.create({
    type: 'express',
    country: 'IN',
    email: 'seller@example.com',
    capabilities: {
      transfers: { requested: true },
    },
  });
  return account.id;
};

2. 处理买家支付,资金暂存托管

创建PaymentIntent时,可先不指定卖家账户,或设置延迟转账,将资金暂存平台:

// 创建支付Intent,资金暂存平台托管
const createPaymentIntent = async (amount, sellerAccountId) => {
  const paymentIntent = await stripe.paymentIntents.create({
    amount: amount * 100, // Stripe以分为单位
    currency: 'inr',
    application_fee_amount: (amount * 0.1) * 100, // 扣除10%平台佣金
    // 先不设置destination,后续手动触发转账
  });
  return paymentIntent.client_secret;
};

3. 确认交付后,划转资金给卖家

当确认交付完成,调用转账API将资金打给卖家:

// 触发资金划转至卖家账户
const transferToSeller = async (amount, sellerAccountId) => {
  const transfer = await stripe.transfers.create({
    amount: (amount * 0.9) * 100, // 扣除佣金后的金额
    currency: 'inr',
    destination: sellerAccountId,
  });
  return transfer;
};

三、用Razorpay实现Escrow托管(Node.js)

Razorpay的Route功能专门针对资金拆分与托管场景设计,操作更贴合印度本土支付环境:

1. 配置卖家账户信息

先创建卖家联系人和资金账户:

const razorpay = require('razorpay')({
  key_id: '你的Razorpay Key ID',
  key_secret: '你的Razorpay Key Secret',
});

// 创建卖家联系人
const createSellerContact = async () => {
  const contact = await razorpay.contacts.create({
    name: '卖家名称',
    email: 'seller@example.com',
    contact: '9999999999',
    type: 'seller',
    reference_id: 'seller_001',
  });
  return contact.id;
};

// 创建卖家资金账户(关联银行账户)
const createSellerFundAccount = async (contactId) => {
  const fundAccount = await razorpay.fundAccounts.create({
    contact_id: contactId,
    account_type: 'bank_account',
    bank_account: {
      ifsc: 'HDFC0001234',
      account_number: '1234567890',
      name: '卖家名称',
    },
  });
  return fundAccount.id;
};

2. 创建订单并开启托管

创建订单时设置资金托管规则,让资金暂存:

// 创建订单,开启资金托管
const createRazorpayOrder = async (amount, sellerFundAccountId) => {
  const order = await razorpay.orders.create({
    amount: amount * 100, // Razorpay以派萨为单位
    currency: 'INR',
    receipt: 'order_receipt_001',
    route: {
      transfers: [
        {
          account: sellerFundAccountId,
          amount: (amount * 0.9) * 100, // 扣除10%佣金后的金额
          currency: 'INR',
          on_hold: true, // 开启托管
        },
      ],
    },
  });
  return order.id;
};

3. 确认交付后,释放托管资金

确认交付完成后,手动释放托管资金给卖家:

// 释放托管资金至卖家账户
const releaseEscrowFunds = async (paymentId, transferId) => {
  const release = await razorpay.payments.transfers.release({
    payment_id: paymentId,
    transfer_id: transferId,
    amount: (amount * 0.9) * 100,
    currency: 'INR',
  });
  return release;
};

四、通用注意事项

  • 合规性:资金托管需符合当地金融监管要求(如印度RBI规定),确保平台具备相应资质
  • 纠纷处理:需设计退款、纠纷仲裁流程,避免托管资金的违规操作
  • 状态同步:将支付、托管、转账的状态实时同步至业务数据库,确保流程可追溯
  • 错误处理:在API调用中添加异常捕获,处理支付失败、转账失败等异常情况

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.05 15:18:17