Home
> Uncategorized > Charging a with # in C#

Charging a credit card with #Stripe in C#

twitter

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 = 00, // In pence – i.e. £
Currency = “GBP”,
SourceCard = new SourceCard()
{
Number = strCardNumber,
Cvc = strCvCNumber,
ExpirationMonth = intExpiryMonth,
ExpirationYear = intExpiryYear
}
}, requestOptions);

And that’s all there is!  – wow…

 



Source link
thanks you RSS link
( https://blog.dotnetframework.org/2018/10/04/charging-a-credit-card-with-stripe-in-c/)

LEAVE A REPLY

Please enter your comment!
Please enter your name here