我似乎无法解决此错误
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>
的HomeController
[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();
}
类型&#39; Stripe.StripeException&#39;的例外情况发生在Stripe.net.dll但未在用户代码中处理 没有这样的标记:tok_1BYf3F2eZvKYlo2C0MJgUKKD
发生了什么事?一些帮助请感谢
答案 0 :(得分:0)
&#34;当您尝试充值的令牌与您正在进行API调用的帐户不匹配时,通常不会出现此类令牌&#34; 错误。
我建议您仔细检查您正在使用的API keys,确保前端的可发布密钥和密钥在你的后端属于同一个帐户。
如果切换API密钥无法解决问题,您希望与Stripe取得联系,他们的支持可以查找令牌ID,并告诉您它无法正常工作的原因!< / p>