我正在寻找正确的区域,错误的焦点。PaymentDetails 对象包含项目所在的 PaymentDetailsItem 数组,代码需要整理,但如果其他人需要它,应该给出总体思路。
PaymentDetailsType[] pmtDetails = new PaymentDetailsType[1];
pmtDetails[0] = new PaymentDetailsType();
var pmtIndex = 0;
PaymentDetailsItemType[] items = new PaymentDetailsItemType[cartItems.Count];
foreach (var item in cartItems)
{
var i = new PaymentDetailsItemType()
{
Name = item.productName,
Number = item.productID.ToString(),
Quantity = item.quantity.ToString(),
Amount = new BasicAmountType(){ currencyID = CurrencyCodeType.GBP, Value = item.productPrice.ToString() }
};
items[pmtIndex] = i;
pmtIndex++;
}
//reqDetails.p
//reqDetails.PaymentDetails = pmtDetails;
//hOrderTotal.Value
//
pmtDetails[0].PaymentDetailsItem = items;
pmtDetails[0].OrderTotal = new BasicAmountType() { currencyID = CurrencyCodeType.GBP, Value = HttpContext.Current.Session["_OrderTotalLessShippingAmount"].ToString() };
reqDetails.PaymentDetails = pmtDetails;