【发布时间】:2016-06-08 20:34:20
【问题描述】:
我对 MVC 有点陌生。但我已经走了很长一段路。我将 PayPal MVC API 集成到我的项目中,当我将多个商品放入购物车并查看商品列表时,我意识到仅填充了数组中的最新商品。
我一直在尝试玩这个,但我很容易不知道在 PayPal 的项目列表中添加多个项目时我缺少什么。
PaymentWithCreditCard() 中有这部分:
//create and item for which you are taking payment
//if you need to add more items in the list
//Then you will need to create multiple item objects or use some loop to instantiate object
var item = new Item();
foreach (var cartitem in cookieCarts)
{
item.name = cartitem.Fullname;
item.currency = "USD";
item.price = cartitem.Price;
item.quantity = cartitem.Qty.ToString();
item.sku = cartitem.Sku;
var intPrice = Int32.Parse(cartitem.Price);
subtotal = subtotal + intPrice;
}
//Now make a List of Item and add the above item to it
//you can create as many items as you want and add to this list
var itms = new List<Item>();
itms.Add(item);
var itemList = new ItemList();
itemList.items = itms;
我不确定如何将我的 forloop 添加到项目列表中
【问题讨论】:
标签: c# asp.net-mvc paypal