title: PayPal API Validation Error: Item amount must add up to specified amount subtotal (or total if amount details not specified)
body: <p>I'm currently having an error(as mentioned in the title). I don't know what's wrong or which line I'm having problems with. I'm sure all the values mentioned in the error are the same but it still pops up the same error.</p>
  
  <p>My aim is to make the all the values the same to solve the error.</p>
  
  <p>Here's the full description of my error: </p>
  
  <pre><code>{
    "name": "https://stackoverflow.com/VALIDATION_ERROR",
    "details": [
      {
        "field": "transactions[0]",
        "issue": "Item amount must add up to specified amount subtotal (or total if amount details not specified)"
      }
    ],
    "message": "Invalid request - see details",
    "information_link": "https://developer.paypal.com/docs/api/payments/#errors",
    "debug_id": "67a354f1a8fc7"
  }
  </code></pre>
  
  <p>Please help!</p>
  
  <p>Here are my codes for reference:</p>
  
  <pre><code>// scList has 2 values inside.
  List&lt;UserShoppingCartDAO&gt; scList = UserShoppingCartDAO.GetCartOfUser(uID);
  
  List&lt;Item&gt; itms = new List&lt;Item&gt;();
  ItemList itemList = new ItemList();
  decimal deliveryCharges = 0;
  string deliveryChargesStr = "";
  decimal postagePackingCost = 0;
  decimal examPaperPrice = 0;
  int quantityOfExamPapers = 0;
  decimal subtotal = 0;
  decimal total = 0;
  var transactionDetails = new Details();
  var transactionAmount = new Amount();
  Transaction tran = new Transaction();
  
  for (int iCounter = 0; iCounter &lt; scList.Count; iCounter++)
  {
      Product p = Product.getProduct(scList[iCounter].ProductID.ToString());
      deliveryCharges = p.price * 0.05m;
      deliveryChargesStr = deliveryCharges.ToString();
      postagePackingCost = 10m;
      examPaperPrice = p.price;
      quantityOfExamPapers = scList[iCounter].ProductQuantity;
      subtotal = (quantityOfExamPapers * examPaperPrice);
      total = subtotal + postagePackingCost;
  
      var examPaperItem = new Item();
      examPaperItem.name = p.productName;
      examPaperItem.currency = "SGD";
      examPaperItem.price = total.ToString();
      examPaperItem.sku = p.productID.ToString();
      examPaperItem.description = p.productDesc;
      examPaperItem.quantity = quantityOfExamPapers.ToString();
  
      itms.Add(examPaperItem);
      itemList.items = itms;
  
      //  var transactionDetails = new Detail
      transactionDetails.tax = "0";
      if (transactionDetails.shipping == null)
      {
          transactionDetails.shipping = postagePackingCost.ToString();
      }
      else
      {
          decimal total2 = decimal.Parse(transactionDetails.shipping) + postagePackingCost;
          transactionDetails.shipping = total2.ToString();
      }
  
      if (transactionDetails.subtotal == null)
      {
          transactionDetails.subtotal = subtotal.ToString();
      }
      else
      {
          decimal total2 = decimal.Parse(transactionDetails.subtotal) + subtotal;
          transactionDetails.subtotal = total2.ToString();
      }
  
      //transactionDetails.shipping = postagePackingCost.ToString();
      //transactionDetails.subtotal = subtotal.ToString("0.00");
  
      //    var transactionAmount = new Amount();
      transactionAmount.currency = "SGD";
  
      if (transactionAmount.total == null)
      {
          transactionAmount.total = total.ToString();
      }
      else
      {
          decimal total2 = decimal.Parse(transactionAmount.total) + total;
          transactionAmount.total = total2.ToString();
      }
  
      transactionAmount.details = transactionDetails;
  
      //   Transaction tran = new Transaction();
  
      tran.description = scList[0].ProductDescription;
      tran.invoice_number = Guid.NewGuid().ToString();
      tran.amount = transactionAmount;
  
      //    transaction.item_list = new List&lt;Item&gt;();
      tran.item_list = itemList;
      transactionList.Add(tran);
  }
  transactionList.Remove(transactionList[1]);
  //Authenticate with paypal
  var config = ConfigManager.Instance.GetProperties();
  var accessToken = new OAuthTokenCredential(config).GetAccessToken();
  
  //Get APIContent Object
  var apiContext = new APIContext(accessToken);
  
  var payer = new Payer();
  payer.payment_method = "paypal";
  
  var redirectUrls = new RedirectUrls();
  redirectUrls.cancel_url = "http://localhost60681/Cancel.aspx";
  redirectUrls.return_url = "http://localhost:60681/CompletePurchase.aspx";
  
  var payment = Payment.Create(apiContext, new Payment
  {
  
      intent = "sale",
      payer = payer,
      transactions = transactionList,
      redirect_urls = redirectUrls
  });
  
  Session["paymentId"] = payment.id;
  
  foreach (var link in payment.links)
  {
      if (link.rel.ToLower().Trim().Equals("approval_url"))
      {
          Response.Redirect(link.href);
      }
  }
  </code></pre>