Skip to content

Instantly share code, notes, and snippets.

@MikeLarned
Created October 17, 2012 00:17
Show Gist options
  • Select an option

  • Save MikeLarned/3902945 to your computer and use it in GitHub Desktop.

Select an option

Save MikeLarned/3902945 to your computer and use it in GitHub Desktop.
Stripe-RestSharp-Charge
[HttpPost]
public JsonResult SubmitCharge(string token, int amount)
{
const string baseUrl = "https://api.stripe.com/";
const string endPoint = "v1/charges";
var apiKey = ConfigurationManager.AppSettings.Get("StripeSecretKey");
var client = new RestClient(baseUrl) { Authenticator = new HttpBasicAuthenticator(apiKey, "") };
var request = new RestRequest(endPoint, Method.POST);
request.AddParameter("card", token);
request.AddParameter("amount", amount);
request.AddParameter("currency", "usd");
var response = client.Execute(request);
return Json(new { code = response.StatusCode, content = response.Content });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment