public static StripeChargeCreateOptions ValidCard()
        {
            var cardOptions = new StripeCreditCardOptions()
            {
                CardAddressCountry = "US",
                CardAddressLine1 = "24 Beef Flank St",
                CardAddressLine2 = "Apt 24",
                CardAddressCity = "BIGGIE",
                CardAddressState = "NC",
                CardAddressZip = "27617",
                CardCvc = "1223",
                CardExpirationMonth = "10",
                CardExpirationYear = "2021",
                CardName = "Joe Meatballs",
                CardNumber = "4000000000000077",
            };

            return new StripeChargeCreateOptions()
            {
                Card = cardOptions,
                Description = "Joe Meatball Charge",
                Amount = 5153,
                Currency = "usd",
                Metadata = new Dictionary<string, string>
                {
                    { "A", "Value-A" },
                    { "B", "Value-B" }
                }
            };
        }
        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 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;
     }
 }
Exemplo n.º 4
0
        public static StripeChargeCreateOptions ValidCard()
        {
            var cardOptions = new StripeCreditCardOptions()
            {
                CardAddressCountry  = "US",
                CardAddressLine1    = "24 Beef Flank St",
                CardAddressLine2    = "Apt 24",
                CardAddressCity     = "BIGGIE",
                CardAddressState    = "NC",
                CardAddressZip      = "27617",
                CardCvc             = "1223",
                CardExpirationMonth = "10",
                CardExpirationYear  = "2021",
                CardName            = "Joe Meatballs",
                CardNumber          = "4242424242424242",
            };

            return(new StripeChargeCreateOptions()
            {
                Card = cardOptions,
                Description = "Joe Meatball Charge",
                Amount = 5153,
                Currency = "usd",
                Metadata = new Dictionary <string, string>
                {
                    { "A", "Value-A" },
                    { "B", "Value-B" }
                }
            });
        }
Exemplo n.º 5
0
        public static StripeTokenCreateOptions ValidForRadar()
        {
            var cardOptions = new StripeCreditCardOptions()
            {
                ExpirationMonth = "06",
                ExpirationYear  = "2020",
                Number          = "4000000000009235"
            };

            return(new StripeTokenCreateOptions()
            {
                Card = cardOptions
            });
        }
Exemplo n.º 6
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 static StripeTokenCreateOptions ValidForRadar()
        {
            var cardOptions = new StripeCreditCardOptions()
            {
               
                ExpirationMonth = "06",
                ExpirationYear = "2020",
                Number = "4000000000009235"
            };

            return new StripeTokenCreateOptions()
            {
                Card = cardOptions
            };
        }
        public static StripeCustomerCreateOptions ValidCard(string _planId = null, string _couponId = null, DateTime?_trialEnd = null)
        {
            var cardOptions = new StripeCreditCardOptions()
            {
                CardAddressCountry  = "US",
                CardAddressLine1    = "234 Bacon St",
                CardAddressLine2    = "Apt 1",
                CardAddressState    = "NC",
                CardAddressZip      = "27617",
                CardCvc             = "1661",
                CardExpirationMonth = "10",
                CardExpirationYear  = "2021",
                CardName            = "Johnny Tenderloin",
                CardNumber          = "4242424242424242",
            };

            var stripeCustomerCreateOptions = new StripeCustomerCreateOptions()
            {
                Card           = cardOptions,
                Email          = "*****@*****.**",
                Description    = "Johnny Tenderloin ([email protected])",
                AccountBalance = 100,
                Metadata       = new Dictionary <string, string>
                {
                    { "A", "Value-A" },
                    { "B", "Value-B" }
                }
            };

            if (_planId != null)
            {
                stripeCustomerCreateOptions.PlanId = _planId;
            }

            if (_couponId != null)
            {
                stripeCustomerCreateOptions.CouponId = _couponId;
            }

            if (_trialEnd != null)
            {
                stripeCustomerCreateOptions.TrialEnd = _trialEnd;
            }

            return(stripeCustomerCreateOptions);
        }
Exemplo n.º 9
0
        public static StripeTokenCreateOptions Valid()
        {
            var cardOptions = new StripeCreditCardOptions()
            {
                AddressCountry  = "US",
                AddressLine1    = "24 Chicken Leg Ave",
                AddressLine2    = "Unit B",
                AddressState    = "NC",
                AddressZip      = "27617",
                Cvc             = "1223",
                ExpirationMonth = "10",
                ExpirationYear  = "2021",
                Name            = "Bob Winghead",
                Number          = "4242424242424242"
            };

            return(new StripeTokenCreateOptions()
            {
                Card = cardOptions
            });
        }
        public static StripeTokenCreateOptions Valid()
        {
            var cardOptions = new StripeCreditCardOptions()
            {
                AddressCountry = "US",
                AddressLine1 = "24 Chicken Leg Ave",
                AddressLine2 = "Unit B",
                AddressState = "NC",
                AddressZip = "27617",
                Cvc = "1223",
                ExpirationMonth = "10",
                ExpirationYear = "2021",
                Name = "Bob Winghead",
                Number = "4242424242424242"
            };

            return new StripeTokenCreateOptions()
            {
                Card = cardOptions
            };
        }
        public static StripeCustomerCreateOptions ValidCard(string _planId = null, string _couponId = null, DateTime? _trialEnd = null)
        {
            var cardOptions = new StripeCreditCardOptions()
            {
                CardAddressCountry = "US",
                CardAddressLine1 = "234 Bacon St",
                CardAddressLine2 = "Apt 1",
                CardAddressState = "NC",
                CardAddressZip = "27617",
                CardCvc = "1661",
                CardExpirationMonth = "10",
                CardExpirationYear = "2021",
                CardName = "Johnny Tenderloin",
                CardNumber = "4242424242424242",
            };

            var stripeCustomerCreateOptions = new StripeCustomerCreateOptions()
            {
                Card = cardOptions,
                Email = "*****@*****.**",
                Description = "Johnny Tenderloin ([email protected])",
                AccountBalance = 100,
                Metadata = new Dictionary<string, string>
                {
                    { "A", "Value-A" },
                    { "B", "Value-B" }
                }
            };

            if (_planId != null)
                stripeCustomerCreateOptions.PlanId = _planId;

            if (_couponId != null)
                stripeCustomerCreateOptions.CouponId = _couponId;

            if (_trialEnd != null)
                stripeCustomerCreateOptions.TrialEnd = _trialEnd;

            return stripeCustomerCreateOptions;
        }
        public static StripeTokenCreateOptions ValidDebitCard()
        {
            var cardOptions = new StripeCreditCardOptions()
            {
                AddressCountry = "US",
                AddressLine1 = "123 Shawshank Way",
                AddressLine2 = "(Red) Cell #237",
                AddressState = "NC",
                AddressZip = "27617",
                Cvc = "1223",
                ExpirationMonth = "10",
                ExpirationYear = "2021",
                Name = "Andy Dufresne",
                Number = "4000056655665556",
                Currency = "usd"
            };

            return new StripeTokenCreateOptions()
            {
                Card = cardOptions
            };
        }
Exemplo n.º 13
0
        public static StripeTokenCreateOptions ValidDebitCard()
        {
            var cardOptions = new StripeCreditCardOptions()
            {
                AddressCountry  = "US",
                AddressLine1    = "123 Shawshank Way",
                AddressLine2    = "(Red) Cell #237",
                AddressState    = "NC",
                AddressZip      = "27617",
                Cvc             = "1223",
                ExpirationMonth = "10",
                ExpirationYear  = "2021",
                Name            = "Andy Dufresne",
                Number          = "4000056655665556",
                Currency        = "usd"
            };

            return(new StripeTokenCreateOptions()
            {
                Card = cardOptions
            });
        }
Exemplo n.º 14
0
        public static StripeTokenCreateOptions Valid()
        {
            // While we should not use raw PANs anymore in Tests we keep this code
            // to properly test the token creation API
            var cardOptions = new StripeCreditCardOptions()
            {
                AddressCountry  = "US",
                AddressLine1    = "24 Chicken Leg Ave",
                AddressLine2    = "Unit B",
                AddressState    = "NC",
                AddressZip      = "27617",
                Cvc             = "1223",
                ExpirationMonth = 10,
                ExpirationYear  = 2021,
                Name            = "Bob Winghead",
                Number          = "4242424242424242"
            };

            return(new StripeTokenCreateOptions()
            {
                Card = cardOptions
            });
        }
Exemplo n.º 15
0
        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);
        }
        public static StripeChargeCreateOptions InvalidCard()
        {
            var cardOptions = new StripeCreditCardOptions()
            {
                CardAddressCountry = "US",
                CardAddressLine1 = "24 Poopie St",
                CardAddressCity = "Yeehaw Beebop ChickyChicky",
                CardAddressState = "NC",
                CardAddressZip = "90210",
                CardCvc = "1223",
                CardExpirationMonth = "10",
                CardExpirationYear = "2004",
                CardName = "Joe Meatballs",
                CardNumber = "425221"
            };

            return new StripeChargeCreateOptions()
            {
                Card = cardOptions,
                Description = "Joe Meatball Charge",
                Amount = 5153,
                Currency = "usd"
            };
        }
Exemplo n.º 17
0
        public static StripeChargeCreateOptions InvalidCard()
        {
            var cardOptions = new StripeCreditCardOptions()
            {
                CardAddressCountry  = "US",
                CardAddressLine1    = "24 Poopie St",
                CardAddressCity     = "Yeehaw Beebop ChickyChicky",
                CardAddressState    = "NC",
                CardAddressZip      = "90210",
                CardCvc             = "1223",
                CardExpirationMonth = "10",
                CardExpirationYear  = "2004",
                CardName            = "Joe Meatballs",
                CardNumber          = "425221"
            };

            return(new StripeChargeCreateOptions()
            {
                Card = cardOptions,
                Description = "Joe Meatball Charge",
                Amount = 5153,
                Currency = "usd"
            });
        }
Exemplo n.º 18
0
        /// <summary>
        /// Process a payment
        /// </summary>
        /// <param name="processPaymentRequest">Payment info required for an order processing</param>
        /// <returns>Process payment result</returns>
        public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
        {
            var result = new ProcessPaymentResult();

            result.AllowStoringCreditCardNumber = false;

            StripeCreditCardOptions cardOptions = new StripeCreditCardOptions()
            {
                Number          = processPaymentRequest.CreditCardNumber,
                ExpirationYear  = processPaymentRequest.CreditCardExpireYear.ToString(),
                ExpirationMonth = processPaymentRequest.CreditCardExpireMonth.ToString(),
                Cvc             = processPaymentRequest.CreditCardCvv2,
                Name            = processPaymentRequest.CustomerId.ToString()
            };
            string token         = CreateToken(cardOptions);
            int    paymentAmount = 0;

            if (_stripePaymentSettings.AdditionalFeePercentage && _stripePaymentSettings.AdditionalFee > 0)
            {
                decimal additionalFee = processPaymentRequest.OrderTotal * (_stripePaymentSettings.AdditionalFee / 100);
                paymentAmount = (int)(processPaymentRequest.OrderTotal * 100) + (int)(additionalFee * 100); //convert to cents/pence
            }
            else if (!_stripePaymentSettings.AdditionalFeePercentage && _stripePaymentSettings.AdditionalFee > 0)
            {
                paymentAmount = (int)(processPaymentRequest.OrderTotal * 100) + (int)(_stripePaymentSettings.AdditionalFee * 100);
            }
            else
            {
                paymentAmount = (int)(processPaymentRequest.OrderTotal * 100);
            }

            StripeChargeCreateOptions chargeOptions = new StripeChargeCreateOptions()
            {
                Amount      = paymentAmount,
                Currency    = "gbp",
                Description = processPaymentRequest.OrderGuid.ToString()
            };

            if (ChargeCard(token, chargeOptions))
            {
                result.NewPaymentStatus = PaymentStatus.Paid;
            }
            else
            {
                result.AddError("Failed");
            }
            //switch (_stripePaymentSettings.TransactMode)
            //{
            //    //case TransactMode.Pending:
            //    //    result.NewPaymentStatus = PaymentStatus.Pending;
            //    //    break;
            //    case TransactMode.Authorize:
            //        result.NewPaymentStatus = PaymentStatus.Authorized;
            //        break;
            //    case TransactMode.AuthorizeAndCapture:
            //        result.NewPaymentStatus = PaymentStatus.Paid;
            //        break;
            //    default:
            //        {
            //            result.AddError("Not supported transaction type");
            //            return result;
            //        }
            //}

            return(result);
        }