Beispiel #1
0
        /// <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 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;
     }
 }
Beispiel #3
0
        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);
        }
        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);
        }
        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 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");
            }
        }
Beispiel #7
0
        public static StripeTokenCreateOptions GetTokenCreateOptions()
        {
            if (Items.ContainsKey("token_create_options"))
            {
                return((StripeTokenCreateOptions)Items["token_create_options"]);
            }

            var options = new StripeTokenCreateOptions
            {
                Card = new StripeCreditCardOptions
                {
                    Name            = "Jason Isbell",
                    AddressCity     = "Green Hill",
                    AddressState    = "AL",
                    AddressLine1    = "I could ask?",
                    AddressLine2    = "",
                    AddressZip      = "35636",
                    AddressCountry  = "US",
                    Cvc             = "123",
                    ExpirationMonth = "10",
                    ExpirationYear  = "2025",
                    Number          = "4242424242424242"
                }
            };

            Items.Add("token_create_options", options);

            return(options);
        }
        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");
        }
Beispiel #9
0
        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);
        }
Beispiel #10
0
        /// <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 StripeToken Create(StripeTokenCreateOptions createOptions)
        {
            var url = ParameterBuilder.ApplyAllParameters(createOptions, Urls.Tokens);

            var response = Requestor.PostString(url);

            return(PopulateStripeToken(response));
        }
        public StripeToken Create(StripeTokenCreateOptions createOptions)
        {
            var url = ParameterBuilder.ApplyAllParameters(createOptions, Urls.Tokens);
            
            var response = Requestor.PostString(url);

            return PopulateStripeToken(response);
        }
		public virtual StripeToken Create(StripeTokenCreateOptions createOptions)
		{
			var url = this.ApplyAllParameters(createOptions, Urls.Tokens, false);

			var response = Requestor.PostString(url, ApiKey);

			return Mapper<StripeToken>.MapFromJson(response);
		}
        public virtual StripeToken Create(StripeTokenCreateOptions createOptions)
        {
            var url = this.ApplyAllParameters(createOptions, Urls.Tokens, false);

            var response = Requestor.PostString(url, ApiKey);

            return(Mapper <StripeToken> .MapFromJson(response));
        }
Beispiel #15
0
        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 virtual StripeToken Create(StripeTokenCreateOptions createOptions, StripeRequestOptions requestOptions = null)
        {
            requestOptions = SetupRequestOptions(requestOptions);

            var url = this.ApplyAllParameters(createOptions, Urls.Tokens, false);

            var response = Requestor.PostString(url, requestOptions);

            return Mapper<StripeToken>.MapFromJson(response);
        }
Beispiel #17
0
        public virtual StripeToken Create(StripeTokenCreateOptions createOptions, StripeRequestOptions requestOptions = null)
        {
            requestOptions = SetupRequestOptions(requestOptions);

            var url = this.ApplyAllParameters(createOptions, Urls.Tokens, false);

            var response = Requestor.PostString(url, requestOptions);

            return(Mapper <StripeToken> .MapFromJson(response));
        }
Beispiel #18
0
        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());
        }
        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);
        }
Beispiel #21
0
        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 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 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);
        }
        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);
        }
Beispiel #25
0
        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
        }
Beispiel #26
0
        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);
        }
Beispiel #27
0
        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
        }
Beispiel #28
0
        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);
        }
Beispiel #29
0
        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);
        }
        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);
        }
Beispiel #31
0
        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("");
        }
        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",
                },
            };
        }
Beispiel #33
0
        public static StripeTokenCreateOptions GetTokenCreateOptions()
        {
            var options = new StripeTokenCreateOptions
            {
                Card = new StripeCreditCardOptions
                {
                    Name            = "Jason Isbell",
                    AddressCity     = "Green Hill",
                    AddressState    = "AL",
                    AddressLine1    = "I could ask?",
                    AddressLine2    = "",
                    AddressZip      = "35636",
                    AddressCountry  = "US",
                    Cvc             = "123",
                    ExpirationMonth = 10,
                    ExpirationYear  = 2025,
                    Number          = "4242424242424242"
                }
            };

            return(options);
        }