您如何使用 Stripe.NET 预览比例分配? [英] How do you preview a proration using Stripe.NET?
本文介绍了您如何使用 Stripe.NET 预览比例分配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在按照 Stripe 文档中提供的示例使用 Stripe.NET 库来Previewing Proration尝试找出当客户从计划 A 升级到计划 B 时将收取的费用.
I'm following the example provided in the Stripe documentation on Previewing Proration using the Stripe.NET library to try to find the amount that will be charged when a customer upgrades from Plan A to Plan B.
但是,当我使用文档中的代码示例时,出现错误:
However, when I use the code sample in the documentation, I get an error:
UpcomingInvoiceOptions options = new UpcomingInvoiceOptions()
{
CustomerId = "cus_XXXXXXXXXXXXX",
SubscriptionProrationDate = DateTime.UtcNow,
SubscriptionItems = new List<InvoiceSubscriptionItemOptions>()
{
new InvoiceSubscriptionItemOptions()
{
Id = "si_XXXXXXXXXXXXXX", // Current Sub Item
PlanId = "plan_XXXXXXXXXXXX" // New plan
}
}
};
InvoiceService service = new InvoiceService();
var result = service.Upcoming(options);
最后一行抛出 Stripe.StripeException:没有订阅就不能更新订阅项目.
推荐答案
结果 options.SubscriptionId
是此操作的必填字段,如果您不调用 service.Get代码>第一.
Turns out options.SubscriptionId
is a required field for this action if you don't call service.Get
first.
以下代码产生正确的结果:
The following code produces the correct results:
UpcomingInvoiceOptions options = new UpcomingInvoiceOptions()
{
CustomerId = "cus_XXXXXXXXXXXXX",
SubscriptionId = "sub_XXXXXXXXXXXX",
SubscriptionProrationDate = DateTime.UtcNow,
SubscriptionItems = new List<InvoiceSubscriptionItemOptions>()
{
new InvoiceSubscriptionItemOptions()
{
Id = "si_XXXXXXXXXXXXXX", // Current Sub Item
PlanId = "plan_XXXXXXXXXXXX" // New plan
}
}
};
InvoiceService service = new InvoiceService();
var result = service.Upcoming(options);
这篇关于您如何使用 Stripe.NET 预览比例分配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文