Created
October 17, 2012 00:18
-
-
Save MikeLarned/3902951 to your computer and use it in GitHub Desktop.
Stripe-RestSharp-Charge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [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