Here I am trying to implement stripe for payment gateway in .net mvc My View code is as below.
@{
ViewBag.Title = "Index";
}
<link type="text/css" rel="stylesheet" href="https://checkout.stripe.com/v3/checkout/button-qpwW2WfkB0oGWVWIASjIOQ.css">
<script src="/Scripts/jquery-1.7.1.js"></script>
<form action="/Home/Charge" method="POST">
<article>
<label>Amount: $5.00</label>
</article>
<script src="//checkout.stripe.com/v2/checkout.js"
class="stripe-button"
data-key="My Public key"
data-locale="auto"
data-description="Sample Charge"
data-amount="500">
</script>
</form>
The code in controller is as below.
public ActionResult Charge(string stripeEmail, string stripeToken)
{
var customers = new StripeCustomerService();
var charges = new StripeChargeService();
var customer = customers.Create(new StripeCustomerCreateOptions
{
Email = stripeEmail,
SourceToken = stripeToken
});
var charge = charges.Create(new StripeChargeCreateOptions
{
Amount = 500,//charge in cents
Description = "Sample Charge",
Currency = "usd",
CustomerId = customer.Id
});
return View();
}
And the secrete key which I have kept in Global.asax.cs file like
StripeConfiguration.SetApiKey("My Sescrete key");
After completing all this part i am runnng my application. when am reaching to
var customer = customers.Create(new StripeCustomerCreateOptions
{
Email = stripeEmail,
SourceToken = stripeToken
});
this part, then here i am getting the error as
Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
And when I am Installing Newtonsoft.Json with 9.0.1 version then again it start giving the same issue but for the Version=4.5.0.0 which arises at very biging in the gloabal.asax.cs file at below line.
WebApiConfig.Register(GlobalConfiguration.Configuration);