Skip to content

Instantly share code, notes, and snippets.

@yazinsai
Last active August 20, 2016 04:00
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 yazinsai/47b570cc20f6ddff3989 to your computer and use it in GitHub Desktop.
Save yazinsai/47b570cc20f6ddff3989 to your computer and use it in GitHub Desktop.
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);
@suryamuppalla
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