public static string GetTokenId() { try { var stripekey = ConfigurationManager.AppSettings["AdminStripeApiKey"]; StripeConfiguration.SetApiKey(stripekey); StripeTokenCreateOptions myToken = new StripeTokenCreateOptions(); var card = new StripeCreditCardOptions() { AddressCountry = "", AddressLine1 = "", AddressLine2 = "", AddressCity = "", AddressZip = "144507", Cvc = 150.ToString(CultureInfo.CurrentCulture), ExpirationMonth = Convert.ToInt32(12), ExpirationYear = Convert.ToInt32(2022), Name = "Inderjit", Number = "4242424242424242" }; myToken.Card = card; var tokenService = new StripeTokenService(); var stripeToken = tokenService.Create(myToken); return(stripeToken.Id); } catch (Exception ex) { Common.ExcepLog(ex); throw; } }
protected string getStripeToken(string cardNumber, string expirationYear, string expirationMonth, string cvc) { var myToken = new StripeTokenCreateOptions(); // if you need this... myToken.Card = new StripeCreditCardOptions() { // set these properties if passing full card details (do not // set these properties if you set TokenId) Number = cardNumber, ExpirationYear = expirationYear, ExpirationMonth = expirationMonth, //AddressCountry = "US", // optional //AddressLine1 = "24 Beef Flank St", // optional //AddressLine2 = "Apt 24", // optional //AddressCity = "Biggie Smalls", // optional //AddressState = "NC", // optional //AddressZip = "27617", // optional //Name = "Joe Meatballs", // optional Cvc = cvc }; var tokenService = new StripeTokenService(); StripeToken stripeToken = tokenService.Create(myToken); return(stripeToken.Id); }
public string CreateToken(string cardNumber, int cardExpMonth, int cardExpYear, string cardCVC) { try { StripeConfiguration.SetApiKey("sk_test_70zfg67P7qQ12FiVLzET76sH"); var tokenOptions = new StripeTokenCreateOptions() { Card = new StripeCreditCardOptions() { Number = cardNumber, ExpirationYear = cardExpYear, ExpirationMonth = cardExpMonth, Cvc = cardCVC } }; var tokenService = new StripeTokenService(); StripeToken stripeToken = tokenService.Create(tokenOptions); return(stripeToken.Id); // This is the token } catch (Exception ex) { return("error"); } }
private StripeToken CreateToken(string number, int expireYear, int expireMonth, string zipCode, string name, string cvc) { var myToken = new StripeTokenCreateOptions(); // if you need this... myToken.Card = new StripeCreditCardOptions() { // set these properties if passing full card details (do not // set these properties if you set TokenId) Number = number, ExpirationYear = expireYear, ExpirationMonth = expireMonth, //AddressCountry = "US", // optional //AddressLine1 = "24 Beef Flank St", // optional //AddressLine2 = "Apt 24", // optional //AddressCity = "Biggie Smalls", // optional //AddressState = state, // optional AddressZip = zipCode, // optional Name = name, // optional Cvc = cvc // optional }; // set this property if using a customer (stripe connect only) //if (!string.IsNullOrEmpty(customerId)) //{ // myToken.CustomerId = customerId; //} var tokenService = new StripeTokenService(); StripeToken stripeToken = tokenService.Create(myToken); return(stripeToken); }
/// <summary> /// Creates the token required by Stripe in order to send credit card information to processed for a transaction /// </summary> /// <param name="t">The transaction object</param> /// <returns>A StripeToken object that can be associated with the charge that is sent to Stripe</returns> private StripeToken CreateCardToken(Transaction t) { var tokenOptions = new StripeTokenCreateOptions() { Card = new StripeCreditCardOptions() { Number = t.Card.CardNumber, ExpirationYear = t.Card.ExpirationYear.ToString(), ExpirationMonth = t.Card.ExpirationMonthPadded, } }; if (!string.IsNullOrEmpty(t.Card.SecurityCode)) { tokenOptions.Card.Cvc = t.Card.SecurityCode; // optional } if (t.Customer.Street.Length > 0) { tokenOptions.Card.AddressLine1 = t.Customer.Street; // optional } if (t.Customer.PostalCode.Length > 0) { tokenOptions.Card.AddressZip = t.Customer.PostalCode; // optional } tokenOptions.Card.Name = t.Card.CardHolderName; var tokenService = new StripeTokenService(); StripeToken stripeToken = tokenService.Create(tokenOptions); return(stripeToken); }
public static string GetTokenId(Payment payment) { StripeTokenCreateOptions myToken = new StripeTokenCreateOptions(); StripeCreditCardOptions card = new StripeCreditCardOptions() { AddressCountry = "USA", AddressLine1 = payment.addressLine1, AddressLine2 = payment.addressLine2, AddressCity = payment.city, AddressZip = payment.zip, Cvc = payment.cvc, Number = payment.ccnumber, ExpirationMonth = payment.expirationMonth, ExpirationYear = payment.expirationYear, Name = payment.firstName + " " + payment.lastName }; myToken.Card = card; var tokenService = new StripeTokenService(); var stripeToken = tokenService.Create(myToken); return(stripeToken.Id); }
public StripeProcessor(ISettingService settingService, ICurrencyService currencyService, ICustomerService customerService, CurrencySettings currencySettings, IWebHelper webHelper, IOrderTotalCalculationService orderTotalCalculationService, IOrderService orderService, StripePaymentSettings stripePaymentSettings, ILocalizationService localizationService, ILogger logger) { _stripePaymentSettings = stripePaymentSettings; _settingService = settingService; _currencyService = currencyService; _customerService = customerService; _currencySettings = currencySettings; _webHelper = webHelper; _orderTotalCalculationService = orderTotalCalculationService; _orderService = orderService; _localizationService = localizationService; _logger = logger; if (!stripePaymentSettings.IsValid()) { return; } StripeConfiguration.SetApiKey(stripePaymentSettings.SecretApiKey); _chargeService = new StripeChargeService(); _tokenService = new StripeTokenService(); _refundService = new StripeRefundService(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; }
/// <summary> /// Creates a token as per /// https://github.com/jaymedavis/stripe.net#creating-a-token /// </summary> /// <param name="customer"></param> /// <returns></returns> public static StripeToken CreateTestToken(ICustomerEntity customer = null) { var myToken = new StripeTokenCreateOptions(); // if you need this... myToken.Card = new StripeCreditCardOptions() { // set these properties if passing full card details (do not // set these properties if you set TokenId) Number = "4242424242424242", ExpirationYear = "2063", ExpirationMonth = "10", AddressCountry = "US", // optional AddressLine1 = "24 Beef Flank St", // optional AddressLine2 = "Apt 24", // optional AddressCity = "Biggie Smalls", // optional AddressState = "NC", // optional AddressZip = "27617", // optional Name = "Joe Meatballs", // optional Cvc = "1223" // optional }; if (customer != null) { myToken.CustomerId = customer.PaymentSystemId; } var tokenService = new StripeTokenService(); StripeToken stripeToken = tokenService.Create(myToken); return(stripeToken); }
public async Task test_payments() { StripeConfiguration.SetApiKey(ConfigurationManager.AppSettings["Stripe.SecretKey"]); var stripeTokenreateOptions = new StripeTokenCreateOptions(); stripeTokenreateOptions.Card = new StripeCreditCardOptions() { Number = "4242424242424242", ExpirationYear = "2022", ExpirationMonth = "10", }; var tokenService = new StripeTokenService(); StripeToken stripeToken = tokenService.Create(stripeTokenreateOptions); StripeCustomerCreateOptions customerCreateOptions = new StripeCustomerCreateOptions { SourceToken = stripeToken.Id, Email = $"{Guid.NewGuid()}@test.com" }; var customerService = new StripeCustomerService(); var customer = customerService.Create(customerCreateOptions); var dbConnection = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString(); var stripeService = new StripeService(dbConnection); await stripeService.TryCharge(customer.Id, 300, "AUD"); }
private string CreateToken(string cardNumber, int cardExpMonth, int cardExpYear, string cardCVC) { StripeConfiguration.SetApiKey("sk_test_eydXW0qoj2r9kXTVI37uuj94"); var tokenOptions = new StripeTokenCreateOptions() { Card = new StripeCreditCardOptions() { Number = cardNumber, ExpirationYear = cardExpYear, ExpirationMonth = cardExpMonth, Cvc = cardCVC } }; var tokenService = new StripeTokenService(); StripeToken stripeToken; try { stripeToken = tokenService.Create(tokenOptions); MakePayment(stripeToken.Id.ToString()); return(stripeToken.Id);// This is the token } catch { Toast.MakeText(this, "You entered wrong data", ToastLength.Short).Show(); activityIndicator.Visibility = ViewStates.Gone; confirmBn.Visibility = ViewStates.Visible; } return(null); }
public bool payByCard(PaymentDetails paymentDetails, string userId) { var charge = paymentDetails.paymentCardDetails; // Treat the info to be ready to put into the charge object for stripe api int?amountTreated = Convert.ToInt32(Math.Round(Convert.ToDouble(charge.amount, new CultureInfo("en-US")) * 100), new CultureInfo("en-US")); // get Stripe Customer Id string stripeCustomerId = getStripeCustomerId(userId); var user = getUser(userId); // insatnce of card service var tokenService = new StripeTokenService(); StripeTokenCreateOptions stripeToken = new StripeTokenCreateOptions() { Card = new StripeCreditCardOptions() { // Capture = true, Cvc = charge.cvc, // Description = "", ExpirationMonth = charge.month, ExpirationYear = charge.year, Number = charge.number, Name = charge.cardHolderName } //,CustomerId = stripeCustomerId }; StripeToken token = tokenService.Create(stripeToken); // Instance of charge service var chargeService = new StripeChargeService(); // Put info in the Charge object StripeChargeCreateOptions chargeCasted = new StripeChargeCreateOptions() { Amount = amountTreated, //ApplicationFee = applicationFeeTreated, Capture = true, Currency = "EUR", //CustomerId = stripeCustomerId, Description = "", //Destination = "", SourceTokenOrExistingSourceId = token.Id, ReceiptEmail = user.Email, }; // Send charge to stripe API StripeCharge response = chargeService.Create(chargeCasted); if (response.Status == "succeeded") { return(true); } return(false); }
public static StripeToken GetToken() { if (Items.ContainsKey("token")) { return((StripeToken)Items["token"]); } var token = new StripeTokenService(ApiKey).Create(GetTokenCreateOptions()); Items.Add("token", token); return(token); }
private string CreateToken(StripeCreditCardOptions card) { var myToken = new StripeTokenCreateOptions { Card = card }; var tokenService = new StripeTokenService(); tokenService.ApiKey = _stripePaymentSettings.ApiKey; var stripeToken = tokenService.Create(myToken); return(stripeToken.Id); }
public async Task <IHttpActionResult> StripeCreateCustomer(CreateStripeCustomer data) { try { StripeConfiguration.SetApiKey(StripeKey); string userId = User.Identity.GetUserId(); var UserModel = userdb.Users.Find(userId); //Ana es loca var stripeTokenCreateOptions = new StripeTokenCreateOptions { Card = new StripeCreditCardOptions { Number = data.Number, ExpirationMonth = Convert.ToInt32(data.ExpiryMonth), ExpirationYear = Convert.ToInt32(data.ExpiryYear), Cvc = data.CVC, Name = data.Name } }; var tokenService = new StripeTokenService(); var stripeToken = tokenService.Create(stripeTokenCreateOptions); var token = stripeToken.Id; var customerOptions = new StripeCustomerCreateOptions() { Description = "Customer for " + UserModel.Email, SourceToken = token }; var customerService = new StripeCustomerService(); StripeCustomer customer = customerService.Create(customerOptions); UserModel.StripeCustomerId = customer.Id; var result = await userdb.SaveChangesAsync(); } catch (Exception sex) { return(Content(HttpStatusCode.BadRequest, sex)); } return(Ok()); }
/* * public ActionResult Proceed(int? id) * { * if (id == null) * { * return new HttpStatusCodeResult(HttpStatusCode.BadRequest); * } * Gift gift = db.Gifts.Find(id); * if (gift == null) * { * return HttpNotFound(); * } * var price = gift.price; * TempData["price"] = price; * return RedirectToAction("Pay"); * * * * }*/ private static async Task <string> GetTokenId(UserInfo ui) { return(await System.Threading.Tasks.Task.Run(() => { var myToken = new StripeTokenCreateOptions(); myToken.Card = new StripeCreditCardOptions() { Number = ui.CardNumber, ExpirationYear = ui.ExpYear, ExpirationMonth = ui.ExpMonth, Cvc = ui.Cvc }; var tokenService = new StripeTokenService(); var stripeToken = tokenService.Create(myToken); return stripeToken.Id; })); }
public ChargeService(IWorkContext workContext, ILogger logger, StripeConnectPaymentSettings stripeConnectPaymentSettings, IWebHelper webHelper, HttpClient httpClient, ICustomerEntityService customerEntityService, IOrderChargeEntityService orderChargeEntityService) { _workContext = workContext; _logger = logger; _stripeConnectPaymentSettings = stripeConnectPaymentSettings; _webHelper = webHelper; _httpClient = httpClient; _customerEntityService = customerEntityService; _orderChargeEntityService = orderChargeEntityService; _stripeChargeService = new StripeChargeService(_stripeConnectPaymentSettings.SecretKey); _stripetokenservice = new StripeTokenService(_stripeConnectPaymentSettings.SecretKey); }
public string CreateToken(string cardNumber, int cardExpMonth, int cardExpYear, string cardCVC) { StripeConfiguration.SetApiKey("pltestxxxxxxx");//do not put our secrtet key in the mobile app var token = new StripeTokenCreateOptions() { Card = new StripeCreditCardOptions() { Number = cardNumber, ExpirationYear = cardExpYear,//might have to convert this to a string later ons ExpirationMonth = cardExpMonth, Cvc = cardCVC } }; var tokenSerivce = new StripeTokenService(); StripeToken stripeToken = tokenSerivce.Create(token); return(stripeToken.Id); }
private StripeSource createStripeSource(string cardNo, int?expirationYear, int?expirationMonth, string ccv, string cardHolderFullName, bool isReusable) { StripeSource source = new StripeSource(); try { var tokenOptions = new StripeTokenCreateOptions() { Card = new StripeCreditCardOptions() { Number = cardNo, ExpirationYear = expirationYear, ExpirationMonth = expirationMonth, Cvc = ccv } }; var tokenService = new StripeTokenService(secretKey); StripeToken stripeToken = tokenService.Create(tokenOptions); string usage = "reusable"; if (!isReusable) { usage = "single_use"; } var sourceOptions = new StripeSourceCreateOptions() { Type = StripeSourceType.Card, Owner = new StripeSourceOwner() { Name = cardHolderFullName }, Token = stripeToken.Id, Usage = usage }; var sourceService = new StripeSourceService(secretKey); //CREATE A SOURCE source = sourceService.Create(sourceOptions); } catch (StripeException e) { throw new StripeException(e.HttpStatusCode, e.StripeError, e.Message); } return(source); }
public static async Task <string> GetTokenId() { var myToken = new StripeTokenCreateOptions { Card = new StripeCreditCardOptions { Number = "4242424242424242" } }; var tokenService = new StripeTokenService() { ApiKey = GetPublicApiKey() }; var stripeToken = await tokenService.CreateAsync(myToken); return(stripeToken.Id); }
private static StripeToken CreateToken(string cardNumber, string cardCvc, int cardExpMonth, int cardExpYear) { var myToken = new StripeTokenCreateOptions { Card = new StripeCreditCardOptions { Cvc = cardCvc, ExpirationMonth = cardExpMonth.ToString(CultureInfo.InvariantCulture), ExpirationYear = cardExpYear.ToString(CultureInfo.InvariantCulture), Number = cardNumber } }; var tokenService = new StripeTokenService(); var stripeToken = tokenService.Create(myToken); return(stripeToken); }
public string CreateToken(string cardNumber, string cardExpMonth, string cardExpYear, string cardCVC) { StripeConfiguration.SetApiKey("pk_test_xxxxxxxxxxxxxxxxx"); var tokenOptions = new StripeTokenCreateOptions() { Card = new StripeCreditCardOptions() { Number = cardNumber, ExpirationYear = cardExpYear, ExpirationMonth = cardExpMonth, Cvc = cardCVC } }; var tokenService = new StripeTokenService(); StripeToken stripeToken = tokenService.Create(tokenOptions); return(stripeToken.Id); // This is the token }
public string CreateToken(CardInfo card) { StripeConfiguration.SetApiKey("sk_test_fMQSO85L4eNQWH7LEESCbY71"); var tokenOptions = new StripeTokenCreateOptions() { Card = new StripeCreditCardOptions() { Number = card.CardNumber, ExpirationYear = card.CardExpyear, ExpirationMonth = card.CardExpMonth, Cvc = card.CardCVV } }; var tokenService = new StripeTokenService(); StripeToken stripeToken = tokenService.Create(tokenOptions); return(stripeToken.Id); // This is the token }
private static string GetTokenId(AcceptedDonations model) { var myToken = new StripeTokenCreateOptions { Card = new StripeCreditCardOptions { Cvc = model.CardCvc, ExpirationMonth = model.CardExpirationMonth.ToString(), ExpirationYear = model.CardExpirationYear.ToString(), Currency = model.Currency, Number = model.CardNumber, Name = model.CardName } }; var tokenService = new StripeTokenService(); var stripeToken = tokenService.Create(myToken); return(stripeToken.Id); }
public static string CreateStripeToken(string cardNumber, string cardExpMonth, string cardExpYear, string cardCVC) { StripeConfiguration.SetApiKey("pk_test_kwCcalSyhmEyq3CmxJqfG6ZJ"); var tokenOptions = new StripeTokenCreateOptions() { Card = new StripeCreditCardOptions() { Number = cardNumber, ExpirationYear = Int32.Parse(cardExpYear), ExpirationMonth = Int32.Parse(cardExpMonth), Cvc = cardCVC } }; var tokenService = new StripeTokenService(); StripeToken stripeToken = tokenService.Create(tokenOptions); return(stripeToken.Id); }
public string CreateToken(string cardNumber, string cardExpMonth, string cardExpYear, string cardCVC) { StripeConfiguration.SetApiKey("your_stripe_live_api_key"); var tokenOptions = new StripeTokenCreateOptions() { Card = new StripeCreditCardOptions() { Number = cardNumber, ExpirationMonth = Int32.Parse(cardExpMonth), ExpirationYear = Int32.Parse(cardExpYear), Cvc = cardCVC } }; var tokenService = new StripeTokenService(); StripeToken stripeToken = tokenService.Create(tokenOptions); return(stripeToken.Id); }
public StripeTokenServiceTest() { this.service = new StripeTokenService(); this.createOptions = new StripeTokenCreateOptions { Card = new StripeCreditCardOptions { AddressCity = "City", AddressCountry = "US", AddressLine1 = "Line 1", AddressLine2 = "Line 2", AddressState = "CA", AddressZip = "90210", Cvc = "123", ExpirationMonth = 10, ExpirationYear = DateTime.Now.Year + 1, Name = "Name", Number = "4242424242424242", }, }; }
public string MakePayment(PaymentRequest paymentRequest) { //can't use a customer from the shared opentable account directly, need to create a one off token first var tokenOptions = new StripeTokenCreateOptions(); tokenOptions.CustomerId = paymentRequest.CustomerToken; var tokenService = new StripeTokenService(paymentRequest.MerchantToken); StripeToken stripeToken = tokenService.Create(tokenOptions); //use the token to create the charge var chargeOptions = new StripeChargeCreateOptions(); chargeOptions.Amount = (int)(paymentRequest.Amount * 100); chargeOptions.Currency = "GBP"; chargeOptions.TokenId = stripeToken.Id; //optional properties chargeOptions.Description = "tasty meal"; var metaData = new Dictionary <string, string>(); metaData.Add("opentableBookingId", "998998924"); chargeOptions.Metadata = metaData; var chargeService = new StripeChargeService(paymentRequest.MerchantToken); try { StripeCharge stripeCharge = chargeService.Create(chargeOptions); return(stripeCharge.Id); } catch (StripeException sx) { //do some logging } return(""); }
async Task <InforAutosStripeCharge> ICustomStripeService.MakePayment(StripeCardInfo cardInfo, double Amount) { //var _token = CreateToken(cardInfo.CardNumber, cardInfo.Month, cardInfo.Year, cardInfo.CCV); InforAutosStripeCharge result = new InforAutosStripeCharge(); try { var myCharge = new StripeChargeCreateOptions(); var myToken = new StripeTokenCreateOptions(); myToken.Card = new StripeCreditCardOptions() { Number = cardInfo.CardNumber, ExpirationMonth = cardInfo.Month, ExpirationYear = cardInfo.Year, Cvc = cardInfo.CCV }; // Stripe amount transformation from double with 2 decimals //Amount = 1; myCharge.Amount = Int32.Parse((Amount * Int32.Parse("100")).ToString()); myCharge.Currency = "EUR"; var chargeService = new StripeChargeService(API_KEY); var tokenService = new StripeTokenService(API_KEY); var token = tokenService.Create(myToken); myCharge.SourceTokenOrExistingSourceId = token.Id; StripeCharge stripeCharge = await chargeService.CreateAsync(myCharge); result.FailureMessage = stripeCharge.FailureMessage; result.IsPaid = stripeCharge.Paid; result.ID = stripeCharge.Id; } catch (System.Exception ex) { // result.FailureMessage = "Payment Successful"; result.FailureMessage = ex.Message; } return(result); }
private void CreateToken() { var myToken = new StripeTokenCreateOptions(); // set these properties if using a card myToken.CardAddressCountry = "US"; myToken.CardAddressLine1 = "24 Portal St"; myToken.CardAddressLine2 = "Unit B"; myToken.CardAddressCity = "Biggie Smalls"; myToken.CardAddressState = "NC"; myToken.CardAddressZip = "27617"; myToken.CardCvc = "1223"; myToken.CardExpirationMonth = "10"; myToken.CardExpirationYear = "2030"; myToken.CardName = "Test Name"; myToken.CardNumber = "4242424242424242"; var tokenService = new StripeTokenService(LibLogic.Helpers.SiteInfo.StripeAPISecretKey); StripeToken stripeToken = tokenService.Create(myToken); this.token = stripeToken.Id; System.Console.WriteLine("Token is: " + token); }
private static string GetTokenId(BuySignModel model) { var myCardToken = new StripeCreditCardOptions { //AddressCountry = model.CardAddressCountry, //AddressLine1 = model.CardAddressLine1, //AddressLine2 = model.CardAddressLine2, //AddressCity = model.CardAddressCity, //AddressZip = model.CardAddressZip, //Cvc = model.CardCvc.ToString(CultureInfo.CurrentCulture), //ExpirationMonth = model.CardExpirationMonth, //ExpirationYear = model.CardExpirationYear, //Name = model.CardName, //Number = model.CardNumber AddressCountry = "Brazil (BR)", AddressLine1 = " ", AddressLine2 = " ", AddressCity = " ", AddressZip = " ", Cvc = "954", ExpirationMonth = "1", ExpirationYear = "2020", Name = " ", Number = "4000000760000002" }; var myToken = new StripeTokenCreateOptions { Card = myCardToken }; var tokenService = new StripeTokenService(); var stripeToken = tokenService.Create(myToken); return(stripeToken.Id); }