Skip to content

Instantly share code, notes, and snippets.

Last active August 20, 2016 04:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Creating a charge using C# with RestSharp
// White doesn't provide a C# wrapper library (yet), but you can still easily
// create charges by sending requests directly to the API. Here's how.
using RestSharp;
var client = new RestClient();
client.BaseUrl = "";
client.Authenticator = new HttpBasicAuthenticator("your_secret_api_key_here", "");
var request = new RestRequest("charges", Method.POST); // send a POST request
request.AddParameter("currency", "AED");
request.AddParameter("amount", "1000"); // 1000 = 10.00 AED
request.AddParameter("description", "The monthly plan!");
request.AddParameter("email", "");
request.AddParameter("card[number]", "4242424242424242");
request.AddParameter("card[exp_month]", "12");
request.AddParameter("card[exp_year]", "2015");
request.AddParameter("card[cvc]", "123");
IRestResponse response = client.Execute(request);
Copy link

Hi yazinsai,

I was stuck when I tried to write this code using JavaScript.

Can u explain to me what is client.Authenticator = new HttpBasicAuthenticator("your_secret_api_key_here", "");

Kindly help me how to write this code in JavaScript.

Thanks in Advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment