title: How to send the total amount of an order to Stripe Api using Asp.Net Core MVC
body: <p>I have a Shopping Cart project developed in Visual Studio I am implementing the stripe gateway but I am not sure how to send the total amount of an order to Stripe, all the examples online is showing the amount typed rather than collecting the total of the shopping cart from a list of items and then send the total to stripe:</p>
  
  <p><a href="https://i.stack.imgur.com/S1uYJ.png" rel="nofollow noreferrer">Order with Total to be sent to Stripe</a></p>
  
  <p>and </p>
  
  <p><a href="https://i.stack.imgur.com/QtFkg.png" rel="nofollow noreferrer">Stripe checkout without the total</a></p>
  
  <pre><code>  &lt;div class="caption"&gt;
              &lt;div class="row"&gt;
                  &lt;div class="col-md-6 col-xs-6"&gt;
                      &lt;h3&gt;Shopping Cart Payment&lt;/h3&gt;
                  &lt;/div&gt;
                  &lt;div class="col-md-6 col-xs-6 price"&gt;
                      &lt;h3&gt;                       
                          @Model.Total.ToString("c")
                      &lt;/h3&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                      &lt;p&gt;&lt;/p&gt;
                                      &lt;div class="row"&gt;
                                          &lt;div class="col-md-6"&gt;
                                              &lt;a class="btn btn-primary btn-product"&gt;&lt;span class="glyphicon glyphicon-thumbs-up"&gt;&lt;/span&gt; Like&lt;/a&gt;
                                          &lt;/div&gt;
                                          &lt;div class="col-md-6"&gt;
  
                                              &lt;button id="pay-button" type="submit" class="btn btn-success  btn-product"&gt;&lt;span class="glyphicon glyphicon-shopping-cart"&gt;&lt;/span&gt; Pay with Card&lt;/button&gt;
  </code></pre>
  
  <p>this is my method in the stripe controller to call the checkout: </p>
  
  <pre><code> public ActionResult Custom()
          {
              string stripePublishableKey = ConfigurationManager.AppSettings["stripePublishableKey"];
              var model = new CustomViewModel() { StripePublishableKey = stripePublishableKey, PaymentFormHidden = true };
              return View(model);
          }
  
          [HttpPost]
          [ValidateAntiForgeryToken()]
          public ActionResult Custom(CustomViewModel customViewModel, string token, int amount)
          {
              customViewModel.PaymentFormHidden = false;
              var chargeOptions = new ChargeCreateOptions()
              {
                  //required
                  **Amount = amount,**// how to add the total for the order here?** 
                  Currency = "euro",
                  Source = token,
  }
  </code></pre>
  
  <p>I tried the below: </p>
  
  <pre><code>var amount = _appDbContext.ShoppingCartItems.Where(c =&gt; c.ShoppingCartId == ShoppingCartId)
                      .Select(c =&gt; c.Pie.Price * c.Amount).Sum();
                  return total;
  
          [HttpPost]
          [ValidateAntiForgeryToken()]
          public ActionResult Custom(CustomViewModel customViewModel, string token)
          {
              customViewModel.PaymentFormHidden = false;
              var chargeOptions = new ChargeCreateOptions()
              {
                  //required
                  **Amount = amount,
                  Currency = "euro",
                  Source = token,
  }
  </code></pre>
  
  <p>My doubt is how do I post the total amount of my order to Stripe for the customer to pay with the credit card?</p>