如何使用.NET使用目标参数创建带区电荷

时间:2019-01-21 17:12:51

标签: c# asp.net-core stripe-payments

使用Stripe,可以使用destination parameter转发费用。 此Stripe文档包含几种语言的示例,但不包括C#/。NET。

Stripe API reference确实有创建费用的示例,并提到了可选的Destination参数作为Dictionary。这个字典参数是什么样的?

.NET API创建费用参考:

var options = new ChargeCreateOptions
{
    Amount = 2000,
    Currency = "usd",
    Description = "Charge for jenny.rosen@example.com",
    SourceId = "tok_visa" // obtained with Stripe.js,
};
var service = new ChargeService();
Charge charge = service.Create(options);

1 个答案:

答案 0 :(得分:0)

它看起来像这样:

var chargeOptions = new ChargeCreateOptions()
{
    Amount = 2000,
    Currency = "usd",
    SourceId = "tok_visa",
    Destination = new ChargeDestinationCreateOptions{
        Amount = 100,
        Account = "acct_1DjoxfIPiUij0fru"
    }
};

ChargeService chargeService = new ChargeService();
Charge charge = chargeService.Create(chargeOptions);

https://github.com/stripe/stripe-dotnet/blob/v22.7.0/src/Stripe.net/Services/Charges/ChargeCreateOptions.cs#L45-L49