Home > Uncategorized > Charging a credit card with #Stripe in C#

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…


Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: