跳转到主要内容

先决条件

  • L1+ KYC 级别的用户
  • 已验证用户邮箱
  • 接受条款和条件

创建账户

POST /api/v2/savings
{
  "userId": "user-id",
  "acceptedTermsAndConditions": true
}

完整示例

const onboardToSavings = async (userId) => {
  // 检查用户 KYC 级别
  const user = await getUser(userId);
  
  if (user.accessLevel === 'L0') {
    throw new Error('用户必须先完成基本 KYC');
  }
  
  // 创建储蓄账户
  const savings = await fetch('/api/v2/savings', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      userId: userId,
      acceptedTermsAndConditions: true
    })
  }).then(r => r.json());
  
  console.log('储蓄账户已创建:', savings.id);
  
  // 获取存款说明
  const achInstructions = await fetch(
    `/api/v2/savings/${savings.id}/deposit-instructions/ACH`,
    {
      headers: {
        'Authorization': `Bearer ${token}`
      }
    }
  ).then(r => r.json());
  
  return {
    savingsAccountId: savings.id,
    depositInstructions: achInstructions
  };
};

下一步