Create a gist now

Instantly share code, notes, and snippets.

@yazinsai /charge.cs
Last active Aug 20, 2016

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 = "https://api.start.payfort.com/";
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", "abdullah@customer.com");
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);

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