I would like pass discount(Coupon) amount to Authorize .net in C#, when i pass discount amount in line items with negative value($-30), i am getting error. without discount code everything working fine
Example:
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
};
How can i achieve this?
You have a string input and must parse string to a number value :
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.