javascript - 如何使用 Asp.Net Core MVC 将订单的总金额发送到 Stripe Api
问题描述
我有一个在 Visual Studio 中开发的购物车项目我正在实现条带网关,但我不确定如何将订单的总金额发送到 Stripe,所有在线示例都显示输入的金额而不是收集购物的总数购物车从项目列表中,然后将总数发送到条带:
和
<div class="caption">
<div class="row">
<div class="col-md-6 col-xs-6">
<h3>Shopping Cart Payment</h3>
</div>
<div class="col-md-6 col-xs-6 price">
<h3>
@Model.Total.ToString("c")
</h3>
</div>
</div>
<p></p>
<div class="row">
<div class="col-md-6">
<a class="btn btn-primary btn-product"><span class="glyphicon glyphicon-thumbs-up"></span> Like</a>
</div>
<div class="col-md-6">
<button id="pay-button" type="submit" class="btn btn-success btn-product"><span class="glyphicon glyphicon-shopping-cart"></span> Pay with Card</button>
这是我在条带控制器中调用结帐的方法:
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,
}
我尝试了以下方法:
var amount = _appDbContext.ShoppingCartItems.Where(c => c.ShoppingCartId == ShoppingCartId)
.Select(c => 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,
}
我的疑问是如何将我的订单总金额过帐到 Stripe 以供客户使用信用卡付款?
解决方案
推荐阅读
- javascript - 序列化可观察的下一个函数调用
- postgresql - pg_dump 不设置 search_path
- c - 安装第 3 方库以在我的 C 程序中使用
- webstorm - 在浏览器和 WebStorm 中编程有什么区别?
- python-3.x - 虹膜 - iris.pandas 错误:“real_datetime”对象没有属性“纳秒”
- maven - maven中的repos没有jar文件吗?
- apache-spark - 如何在执行启动器中指定 spark 版本
- rxjs - 具有自定义创建逻辑的 RxJS BehaviorSubject
- c# - 为特定区域自定义 wpf 日历
- android - 如何获取当前播放音乐的详细信息?