首页 > 解决方案 > 在结帐时为条纹产品添加描述

问题描述

我正在开发一个 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 参数的名称添加到 Checkout、Invoice Items 和 Subscription Schedule API。
https://stripe.com/docs/api/subscription_items/create
https://stripe.com/docs/billing/prices-guide

他们提供了两篇文章的链接,我已阅读并重新阅读但不了解如何实现它。如果有人可以提供帮助,将不胜感激。

标签: c#stripe-payments

解决方案


不幸的是,计费门户没有显示产品描述。

如果您想使用计费门户,那么您需要在产品名称中指定客户名称,例如[client name] Product #1,这将需要您为每个客户创建一个新产品和价格。

您可以在 Checkout Session 创建中执行此操作:

或者,分别创建产品和价格:


推荐阅读