【发布时间】:2017-12-14 03:02:53
【问题描述】:
我似乎无法解决这个错误
Credit.cshtml
<form action="@Url.Action("Charge", "Home")" method="POST">
<article>
<label>Amount: $5.00</label>
</article>
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_6pRNASCoBOKtIshFeQd4XMUh"
data-amount="1000"
data-name="My Project Name"
data-description="Premium Account (€10)"
data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
data-locale="auto"
data-zip-code="true"
data-currency="eur">
</script>
</form>
家庭控制器
[HttpPost]
//Parameters can contain stripeToken, stripeEmail, stripeName, stripeAddress submitted from Credit.cshtml form
public ActionResult Charge(string stripeToken, string stripeEmail)
{
Debug.WriteLine("stripe token is " + stripeToken);
Debug.WriteLine("stripe email is " + stripeEmail);
StripeConfiguration.SetApiKey("<!-- my secret key -->");
//Take the token submitted by the form
var token = stripeToken;
//Charge to the user card
var charges = new StripeChargeService();
var charge = charges.Create(new StripeChargeCreateOptions
{
Amount = 1000,
Currency = "sgd",
Description = "Example charge",
SourceTokenOrExistingSourceId = token
});
return View();
}
Stripe.net.dll 中出现“Stripe.StripeException”类型的异常,但未在用户代码中处理 没有这样的令牌:tok_1BYf3F2eZvKYlo2C0MJgUKKD
发生了什么?请帮忙谢谢
【问题讨论】:
标签: asp.net asp.net-mvc stripe-payments stripe.net