【发布时间】:2021-12-25 15:04:50
【问题描述】:
我正在开发一个 C# 应用程序,应用程序用户将为他们的客户购买订阅。由于他们将购买多个订阅,我需要向产品添加描述(客户名称),以便它与价格一起显示在计费门户中。我当前的结帐代码工作正常,相关部分在这里:
var options = new Stripe.Checkout.SessionCreateOptions
{
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Price = priceId,
Quantity = 1
},
},
PaymentMethodTypes = new List<string>
{
"card",
},
Mode = "subscription",
SuccessUrl = string.Concat("https://", domain, "/success/", hhid, "?session_id={CHECKOUT_SESSION_ID}"),
CancelUrl = string.Concat("https://", domain),
Customer = customerId,
SubscriptionData = new SessionSubscriptionDataOptions()
{
Metadata = new Dictionary<string, string>()
{
{ "userId", userId.ToString() }
}
}
};
if (!string.IsNullOrEmpty(user.PaymentCustomerId))
options.Customer = user.PaymentCustomerId;
var service = new Stripe.Checkout.SessionService();
Stripe.Checkout.Session session = await service.CreateAsync(options);
Response.Headers.Add("Location", session.Url);
我联系了 Stripe 支持,他们的回复是
在这种特殊情况下,我们没有允许您添加描述的选项,但您可以将带有 price_data 参数的名称添加到结帐、发票项目和订阅计划 API。
https://stripe.com/docs/api/subscription_items/create
https://stripe.com/docs/billing/prices-guide
他们提供了两篇文章的链接,我已阅读并重新阅读但不了解如何实现它。如果有人可以提供帮助,将不胜感激。
【问题讨论】:
标签: c# stripe-payments