Skip to content

Instantly share code, notes, and snippets.

@shagamemnon
Last active September 19, 2017 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shagamemnon/dfa272aae27f3cb05c9bddcd16d9d675 to your computer and use it in GitHub Desktop.
Save shagamemnon/dfa272aae27f3cb05c9bddcd16d9d675 to your computer and use it in GitHub Desktop.
Example C# HTTP Request
namespace MyNamespace {
public class MyRequest {
private async Task<bool> Request () {
// Replace MY_TOKEN with a test token object id
string url = "https://api.stripe.com/v1/charges?amount=1000&currency=usd&source=MY_TOKEN&description=Test%20charge%20to%20text%40example.com";
// Replace MY_SECRET_KEY with test secret key (e.g. sk_test_...)
HttpWebRequest request = (HttpWebRequest)WebRequest.Create (new Uri(url));
request.Headers.Add("Authorization", "Bearer MY_SECRET_KEY");
request.Method = "POST";
using (WebResponse response = await request.GetResponseAsync ()) {
using (Stream stream = response.GetResponseStream ()) {
return true;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment