如何在stripe checkout webforms(ASP.NET C#)中存储多个动态产品我尝试了很多,但都是静态的';它起作用了,但不是动态的?

如何在stripe checkout webforms(ASP.NET C#)中存储多个动态产品我尝试了很多,但都是静态的';它起作用了,但不是动态的?,c#,asp.net,checkbox,stripe-payments,payment-gateway,C#,Asp.net,Checkbox,Stripe Payments,Payment Gateway,代码如下:- 静态我用它工作得很好。。如何使用asp.net c动态存储产品# LineItems=新列表 { 对于(inti=0;i行[i][“价格”])*100, 数量=1, }, } }, 扩展API参考中显示的代码段,我们可以将Price='Price_123'替换为PriceData(),如下所示: var options=new SessionCreateOptions { 成功URL=”https://example.com/success", 取消URL=”https:

代码如下:- 静态我用它工作得很好。。如何使用asp.net c动态存储产品#

LineItems=新列表
{     
对于(inti=0;i行[i][“价格”])*100,
数量=1,
},
}
},

扩展API参考中显示的代码段,我们可以将
Price='Price_123'
替换为
PriceData
(),如下所示:

var options=new SessionCreateOptions
{
成功URL=”https://example.com/success",
取消URL=”https://example.com/cancel",
PaymentMethodTypes=新列表
{
“卡”,
},
LineItems=新列表
{
新的SessionLineItemOptions
{
PriceData=新的SessionLineItemPriceDataOptions
{
货币=“美元”,
UnitAmount=50000,
ProductData=新的SessionLineItemPriceDataProductDataOptions
{
Name=“某些产品名称”,
}
},
数量=2,
},
},
Mode=“付款”,
};
var service=newsessionservice();
服务。创建(选项);

您可以在中找到所有类型定义。

显示不起作用的动态代码。请检查此项。我不明白您所说的“静态”和“动态”是什么意思。你能解释清楚你的意思吗?也许通过向我们展示您在问题中的静态尝试和动态尝试,我们会更好地理解您的意思。谢谢您的建议,但我的问题是如何动态存储产品。静态的我理解,那么动态是什么意思?这里的答案是使用
price\u data
product\u data
在会话创建请求期间定义产品和价格。你能解释一下这没有提供什么吗?我从数据库中获取数据,我想在新的SessionLineItemOptions中使用for loop存储数据。当我在LineItems=new List之间使用for loop时,它会给我提供语法错误。当然,在请求之前,只需将其分离为一个步骤<代码>列表会话项=;SessionCreateOptions{LineItems=sessionItems,…}
 LineItems = new List<SessionLineItemOptions>
  {     
   for (int i = 0; i < dtOrder.Rows.Count; i++){  
    new SessionLineItemOptions
    {
       Name=dtOrder.Rows[i]["ProductName"].toString(),
        Currency="cad",
      Amount =Convert.toInt64(dtOrder>Rows[i]["Price"])*100,
      Quantity = 1,
    },
   }
  },
var options = new SessionCreateOptions
{
  SuccessUrl = "https://example.com/success",
  CancelUrl = "https://example.com/cancel",
  PaymentMethodTypes = new List<string>
  {
    "card",
  },
  LineItems = new List<SessionLineItemOptions>
  {
    new SessionLineItemOptions
    {
      PriceData = new SessionLineItemPriceDataOptions
      {
        Currency = "usd",
        UnitAmount = 50000,
        ProductData = new SessionLineItemPriceDataProductDataOptions
        {
          Name = "some product name",
        }
      },
      Quantity = 2,
    },
  },
  Mode = "payment",
};
var service = new SessionService();
service.Create(options);