Charging a credit card with #Stripe in C#
This has been demoed a million times before, but just to show how ridiculously simple it is to bill a card with stripe, here’s a code example in C#
You first open package manager and type
Install-Package Stripe.net
Then use the following code:
var strStripeSecretKey = “sk_live_xxxxxxxxxxxxxx”;
var strCardNumber = “xxxxxxxxxxxxxxxxx”; // Long card number
var strCvCNumber = “xxx”;
var intExpiryMonth = 1;
var intExpiryYear = 2019;
var requestOptions = new StripeRequestOptions() { ApiKey = strStripeSecretKey };
var chargeService = new StripeChargeService();
var chareResponse = chargeService.Create(new StripeChargeCreateOptions()
{
Amount = 1000, // In pence – i.e. £10
Currency = “GBP”,
SourceCard = new SourceCard()
{
Number = strCardNumber,
Cvc = strCvCNumber,
ExpirationMonth = intExpiryMonth,
ExpirationYear = intExpiryYear
}
}, requestOptions);
And that’s all there is! – wow…