我想在C#中将折扣(优惠券)金额传递给授权.net, 当我在负值($ - 30)的订单项中通过折扣金额时,我收到错误。没有折扣代码一切正常
示例:
1 Item1 10 N US $24.95 US $249.50
Discount: US $-30.00
Total: US $219.50
var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), // charge the card
amount = order.LineItems.Sum(od => od.UnitPrice * od.Quantity),
lineItems = lineItems,
order = new orderType { invoiceNumber = order.Orderid, description = order.OrderDescription },
customer = new customerDataType { id = order.customerdetails.Customerid, email = order.customerdetails.CustomerEmail },
currencyCode = order.CurrencyCode
};
我怎样才能实现这个目标?
答案 0 :(得分:-1)
您有一个字符串输入,必须将字符串解析为数字值:
string input = "1 Item1 10 N US $24.95 US $249.50";
string[] array = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
decimal amount = decimal.Parse(array[7], System.Globalization.NumberStyles.Currency);
decimal discount = amount - 30;