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

在Stripe.net中调用AccountCreateOptions后如何获取Account对象

解决方法

你的核心问题是没有接收AccountService.Create()方法的返回值。Stripe.net的该方法会返回包含完整账户信息(包括目标Id)的Account对象,只需赋值给变量即可获取账户ID,进而生成开户流程链接。

步骤1:获取创建后的账户对象

修改原代码,接收返回的Account实例:

StripeConfiguration.ApiKey = "xxxx";
var options = new AccountCreateOptions
{
    Country = data.country,
    Email = data.businessEmail,
    BusinessType = "individual",
    Capabilities = new AccountCapabilitiesOptions()
    {
        CardPayments = new AccountCapabilitiesCardPaymentsOptions(){ Requested = true },
        Transfers = new AccountCapabilitiesTransfersOptions { Requested = true },
    },
    Controller = new AccountControllerOptions
    {
        Fees = new AccountControllerFeesOptions { Payer = "account" },
        Losses = new AccountControllerLossesOptions { Payments = "stripe" },
        StripeDashboard = new AccountControllerStripeDashboardOptions
        {
            Type = "full",
        },
        RequirementCollection = "stripe"
    },
};
var service = new AccountService();
// 接收返回的Account对象,从中提取ID
Account createdAccount = service.Create(options);
string accountId = createdAccount.Id; // 格式如acct_1Nv0FGQ9RKHgCVdK

步骤2:生成开户流程启动链接

拿到账户ID后,使用AccountLinkService创建开户引导链接:

var accountLinkOptions = new AccountLinkCreateOptions
{
    Account = accountId,
    RefreshUrl = "https://your-domain.com/refresh", // 流程中断后的跳转地址
    ReturnUrl = "https://your-domain.com/success", // 流程完成后的跳转地址
    Type = "account_onboarding" // 指定为开户流程类型
};

var accountLinkService = new AccountLinkService();
AccountLink accountLink = accountLinkService.Create(accountLinkOptions);

// 获取可直接使用的开户启动链接
string onboardingUrl = accountLink.Url;

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 13:09:57