在结账时为条纹产品添加描述
Add a description to a stripe product at checkout
我正在开发一个 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 支持,他们的回复是
In this particular case we do not have an option that allow you to add a description, but you are able to add the name with price_data parameter into the Checkout, Invoice Items, and Subscription Schedule APIs.
https://stripe.com/docs/api/subscription_items/create
https://stripe.com/docs/billing/prices-guide
他们提供了两篇文章的链接,我已阅读并重新阅读但不明白如何实施。如果有人能提供帮助,将不胜感激。
遗憾的是,计费门户不显示产品描述。
如果您想使用计费门户,则需要在产品名称中指定客户名称,例如[client name] Product #1
,这需要您为每个客户创建新的产品和价格。
您可以在结帐会话创建中执行此操作:
- https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-product_data-name
- https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data
或者,分别创建产品和价格:
我正在开发一个 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 支持,他们的回复是
In this particular case we do not have an option that allow you to add a description, but you are able to add the name with price_data parameter into the Checkout, Invoice Items, and Subscription Schedule APIs.
https://stripe.com/docs/api/subscription_items/create
https://stripe.com/docs/billing/prices-guide
他们提供了两篇文章的链接,我已阅读并重新阅读但不明白如何实施。如果有人能提供帮助,将不胜感激。
遗憾的是,计费门户不显示产品描述。
如果您想使用计费门户,则需要在产品名称中指定客户名称,例如[client name] Product #1
,这需要您为每个客户创建新的产品和价格。
您可以在结帐会话创建中执行此操作:
- https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-product_data-name
- https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data
或者,分别创建产品和价格: