Beispiel #1
0
        public void Post(PayRequest request)
        {
            ServicePointManager.ServerCertificateValidationCallback = Callback;
            var openPayments  = GetOpenPayments();
            var usersPayedFor = openPayments.Select(x => x.User.FirstName + " " + x.User.LastName)
                                .Aggregate((i, j) => i + ", " + j);

            var division = Db.LoadSingleById <Division>(DivisionId);

            var gateway = new StripeGateway(division.PrivateStripeKey);

            gateway.Post(new ChargeStripeCustomer()
            {
                Amount      = request.Amount,
                Currency    = Currencies.SwissFranc,
                Description = "Mitgliederbeitrag von " + usersPayedFor,
                Source      = request.Token
            });

            openPayments.ForEach(x =>
            {
                x.HasPaid = true;
                x.Comment = "Kreditkarte";
            });

            Db.UpdateAll(openPayments);
        }
        //Machine ID & Subcription
        public void SubmitPayment_Click(object sender, RoutedEventArgs e)
        {
            //subscription
            try
            {
                var gateway    = new StripeGateway("sk_live_DmUVQDTpe9tOV0b6kFvy9y6K00bNafAJyN");
                int MonthValue = Convert.ToInt32(Month.SelectedValue);
                int YearValue  = Convert.ToInt32(Year.Text);
                var cardToken  = gateway.Post(new CreateStripeToken
                {
                    Card = new StripeCard
                    {
                        Name           = FirstName.Text + " " + LastName.Text,
                        Number         = CreditCardNumber.Text,
                        Cvc            = CVV.Text,
                        ExpMonth       = MonthValue,
                        ExpYear        = YearValue,
                        AddressLine1   = Address.Text,
                        AddressZip     = Zip.Text,
                        AddressState   = State.Text,
                        AddressCountry = (string)Country.SelectedValue,
                    },
                });
                var customer = gateway.Post(new CreateStripeCustomerWithToken
                {
                    Card        = cardToken.Id,
                    Description = FirstName.Text + " " + LastName.Text,
                    Email       = Email.Text,
                });
                { customerID = customer.Id; };
            }
            catch (Exception g)
            {
                MessageBox.Show(g.Message + Environment.NewLine + g.InnerException +
                                Environment.NewLine + g.StackTrace + Environment.NewLine +
                                g.Data + Environment.NewLine + g.HResult + Environment.NewLine + g.GetBaseException().Message);
            }
            try
            {
                var gateway      = new StripeGateway("sk_live_DmUVQDTpe9tOV0b6kFvy9y6K00bNafAJyN");
                var subscription = gateway.Post(new SubscribeStripeCustomer
                {
                    CustomerId = customerID,
                    Plan       = "price_1H2kCBJHdLsTZND2MIJsWEEk",
                    Quantity   = 1,
                });


                WebBrowser1.Visibility = Visibility.Visible;
                WebBrowser1.Navigate("http://alliancetechhub.com/submit.php?uid=");
                Productkeyentry = true;
            }
            catch (Exception f)
            {
                MessageBox.Show(f.Message + Environment.NewLine + f.InnerException +
                                Environment.NewLine + f.StackTrace + Environment.NewLine +
                                f.Data + Environment.NewLine + f.HResult + Environment.NewLine + f.GetBaseException().Message);
            }
        }
Beispiel #3
0
 public StripeHandler(string secretKey)
 {
     StripeGateway = new StripeGateway(secretKey);
 }
        /// <summary>
        /// Creates a modal credit-card collector that is implemented with Stripe Checkout. When the window’s submit button is clicked, the credit card is charged
        /// or otherwise used.
        /// </summary>
        /// <param name="jsOpenStatements">The JavaScript statement list that will open this credit-card collector.</param>
        /// <param name="testPublishableKey">Your test publishable API key. Will be used in non-live installations. Do not pass null.</param>
        /// <param name="livePublishableKey">Your live publishable API key. Will be used in live installations. Do not pass null.</param>
        /// <param name="name">See https://stripe.com/docs/legacy-checkout. Do not pass null.</param>
        /// <param name="description">See https://stripe.com/docs/legacy-checkout. Do not pass null.</param>
        /// <param name="amountInDollars">See https://stripe.com/docs/legacy-checkout, but note that this parameter is in dollars, not cents</param>
        /// <param name="testSecretKey">Your test secret API key. Will be used in non-live installations. Do not pass null.</param>
        /// <param name="liveSecretKey">Your live secret API key. Will be used in live installations. Do not pass null.</param>
        /// <param name="successHandler">A method that executes if the credit-card submission is successful. The first parameter is the charge ID and the second
        /// parameter is the amount of the charge, in dollars.</param>
        /// <param name="prefilledEmailAddressOverride">By default, the email will be prefilled with AppTools.User.Email if AppTools.User is not null. You can
        /// override this with either a specified email address (if user is paying on behalf of someone else) or the empty string (to force the user to type in the
        /// email address).</param>
        public CreditCardCollector(
            JsStatementList jsOpenStatements, string testPublishableKey, string livePublishableKey, string name, string description, decimal?amountInDollars,
            string testSecretKey, string liveSecretKey, Func <string, decimal, StatusMessageAndDestination> successHandler,
            string prefilledEmailAddressOverride = null)
        {
            if (!EwfApp.Instance.RequestIsSecure(HttpContext.Current.Request))
            {
                throw new ApplicationException("Credit-card collection can only be done from secure pages.");
            }

            if (amountInDollars.HasValue && amountInDollars.Value.DollarValueHasFractionalCents())
            {
                throw new ApplicationException("Amount must not include fractional cents.");
            }

            var          token = new DataValue <string>();
            ResourceInfo successDestination = null;
            var          postBack           = PostBack.CreateFull(
                id: PostBack.GetCompositeId("ewfCreditCardCollection", description),
                modificationMethod: () => {
                // We can add support later for customer creation, subscriptions, etc. as needs arise.
                if (!amountInDollars.HasValue)
                {
                    throw new ApplicationException("Only simple charges are supported at this time.");
                }

                StripeCharge response;
                try {
                    response = new StripeGateway(ConfigurationStatics.IsLiveInstallation ? liveSecretKey : testSecretKey).Post(
                        new ChargeStripeCustomer
                    {
                        Amount = (int)(amountInDollars.Value * 100), Currency = "usd", Description = description.Any() ? description : null, Card = token.Value
                    });
                }
                catch (StripeException e) {
                    if (e.Type == "card_error")
                    {
                        throw new DataModificationException(e.Message);
                    }
                    throw new ApplicationException("A credit-card charge failed.", e);
                }

                try {
                    var messageAndDestination = successHandler(response.Id, amountInDollars.Value);
                    if (messageAndDestination.Message.Any())
                    {
                        PageBase.AddStatusMessage(StatusMessageType.Info, messageAndDestination.Message);
                    }
                    successDestination = messageAndDestination.Destination;
                }
                catch (Exception e) {
                    throw new ApplicationException("An exception occurred after a credit card was charged.", e);
                }
            },
                actionGetter: () => new PostBackAction(successDestination));

            var hiddenFieldId = new HiddenFieldId();
            var hiddenFields  = new List <EtherealComponent>();

            FormState.ExecuteWithDataModificationsAndDefaultAction(
                postBack.ToCollection(),
                () => hiddenFields.Add(
                    new EwfHiddenField("", validationMethod: (postBackValue, validator) => token.Value = postBackValue.Value, id: hiddenFieldId).PageComponent));

            FormAction action = new PostBackFormAction(postBack);

            childGetter = () => {
                stripeCheckoutIncludeSetter();
                action.AddToPageIfNecessary();
                jsOpenStatements.AddStatementGetter(
                    () => {
                    var jsTokenHandler = "function( token, args ) { " + hiddenFieldId.GetJsValueModificationStatements("token.id") + " " + action.GetJsStatements() +
                                         " }";
                    return("StripeCheckout.open( { key: '" + (ConfigurationStatics.IsLiveInstallation ? livePublishableKey : testPublishableKey) + "', token: " +
                           jsTokenHandler + ", name: '" + name + "', description: '" + description + "', " +
                           (amountInDollars.HasValue ? "amount: " + amountInDollars.Value * 100 + ", " : "") + "email: '" +
                           (prefilledEmailAddressOverride ?? (AppTools.User == null ? "" : AppTools.User.Email)) + "' } );");
                });
                return(hiddenFields);
            };
        }
Beispiel #5
0
 public AccountsController()
 {
     gateway = new StripeGateway("sk_test_gmsesQcld5Dm19hk4qtN0yjJ");
 }
        protected void btnCheckOut_Click(object sender, EventArgs e)
        {
            var gateway = new StripeGateway("sk_test_Biqolmcf9wmzviLy2J0xHfjg");

            var cardToken = gateway.Post(new CreateStripeToken
            {
                Card = new StripeCard
                {
                    Name           = tbFName.Text + tbLName.Text,
                    Number         = tbCardNo.Text,
                    Cvc            = tbCVC.Text,
                    ExpMonth       = Convert.ToInt32(tbMonth.Text),
                    ExpYear        = Convert.ToInt32(tbYear.Text),
                    AddressLine1   = tbAddress.Text,
                    AddressLine2   = tbAddress.Text,
                    AddressZip     = tbCity.Text,
                    AddressState   = tbState.Text,
                    AddressCountry = "Pakistan",
                },
            });

            var customer = gateway.Post(new CreateStripeCustomerWithToken
            {
                Card        = cardToken.Id,
                Description = "Purchasing Purpose",
                Email       = tbEmail.Text,
            });
            var temp   = customer.Id;
            var charge = gateway.Post(new ChargeStripeCustomer
            {
                Amount      = 100 * 10,
                Customer    = customer.Id,
                Currency    = "usd",
                Description = "Test Charge Customer",
            });


            using (var db = new bigshopeEntities())
            {
                tblCustomer cus = new tblCustomer();
                cus.customer_name     = tbFName.Text;
                cus.customer_surname  = tbLName.Text;
                cus.customer_email    = tbEmail.Text;
                cus.customer_phone    = tbPhone.Text;
                cus.customer_address  = tbAddress.Text;
                cus.customer_city     = tbCity.Text;
                cus.customer_address  = tbAddress.Text;
                cus.customer_city     = tbCity.Text;
                cus.customer_state    = tbState.Text;
                cus.customer_zip      = Convert.ToInt32(tbPost.Text);
                cus.customer_password = EncDec.Encrypt(tbPass.Text);
                //cus.customer_stripe_id = "sk_test_Biqolmcf9wmzviLy2J0xHfjg";
                cus.customer_stripe_id = temp;
                db.tblCustomers.Add(cus);
                db.SaveChanges();

                // Order Insertion
                tblOrder order = new tblOrder();
                order.order_prod_id      = 1;
                order.order_total_amount = Request.Cookies["grandTotal"].Value.ToString();
                order.order_time         = DateTime.Now;
                db.tblOrders.Add(order);
                db.SaveChanges();

                //sendMail();

                Response.Redirect("thanks_for_shopping.aspx");
            }
        }
Beispiel #7
0
 public StripeController()
 {
     gateway = new StripeGateway("sk_test_gmsesQcld5Dm19hk4qtN0yjJ");
     db      = new data_Base();
 }
Beispiel #8
0
        static void Main(string[] args)
        {
            IPaymentGateway paymentGateway;
            double          amount;

            while (true)
            {
                Console.Write("Put the amount to pay: $");
                if (Double.TryParse(Console.ReadLine(), out amount))
                {
                    break;
                }
            }

            while (true)
            {
                Console.WriteLine("Choose a gatewawy option from the following list:");
                Console.WriteLine("\t1 - Paypal");
                Console.WriteLine("\t2 - Square");
                Console.WriteLine("\t3 - Strip");
                Console.WriteLine("\t4 - Fastest (Debit)");

                int paymentOption;

                while (true)
                {
                    Console.Write("Your option? ");
                    if ((int.TryParse(Console.ReadLine(), out paymentOption)) && (paymentOption >= 1 && paymentOption <= 4))
                    {
                        break;
                    }
                }

                switch (paymentOption)
                {
                case 1:
                    paymentGateway = new PaypalGateway();
                    break;

                case 2:
                    paymentGateway = new SquareGateway();
                    break;

                case 3:
                    paymentGateway = new StripeGateway();
                    break;

                case 4:
                    paymentGateway = new FastestGateway();
                    break;

                default:
                    paymentGateway = new PaypalGateway();
                    break;
                }
                var paymentStrategy = new PaymentStrategy(paymentGateway);
                int finalOption;

                Console.WriteLine("Choose an option from the following list:");
                Console.WriteLine($"\t1 - Pay now using {paymentGateway.GetPaymentGatewayName()}.");
                Console.WriteLine($"\t2 - Back to gateway options.");
                while (true)
                {
                    Console.Write("Your option? ");
                    if ((int.TryParse(Console.ReadLine(), out finalOption)) && (finalOption >= 1 && finalOption <= 2))
                    {
                        break;
                    }
                }

                if (finalOption == 2)
                {
                    continue;
                }

                paymentStrategy.MakePayment(amount);
                break;
            }
        }
        //Machine ID & Subcription
        public void SubmitPayment_Click(object sender, RoutedEventArgs e)
        {
            //Machin ID
            string gi = "{2B57C22C-2577-4BBA-A51D-BD0A00498AFB}\\";
            string mc = "1";

            try
            {
                string name1 = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + gi;

                RegistryKey key = Registry.LocalMachine.OpenSubKey(name1);
                if (key != null)
                {
                    mc = key.GetValue("uuid") as string;
                    key.Close();
                }
                if (mc == "1")
                {
                    string name2 = "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + gi;
                    key = Registry.LocalMachine.OpenSubKey(name2);
                    if (key != null)
                    {
                        mc = key.GetValue("uuid") as string;
                        key.Close();
                    }
                }
            }
            catch (Exception)
            {
            }
            //subscription
            try
            {
                var gateway    = new StripeGateway("sk_live_DmUVQDTpe9tOV0b6kFvy9y6K00bNafAJyN");
                int MonthValue = Convert.ToInt32(Month.SelectedValue);
                int YearValue  = Convert.ToInt32(Year.Text);
                var cardToken  = gateway.Post(new CreateStripeToken
                {
                    Card = new StripeCard
                    {
                        Name           = FirstName.Text + " " + LastName.Text,
                        Number         = CreditCardNumber.Text,
                        Cvc            = CVV.Text,
                        ExpMonth       = MonthValue,
                        ExpYear        = YearValue,
                        AddressLine1   = Address.Text,
                        AddressZip     = Zip.Text,
                        AddressState   = State.Text,
                        AddressCountry = (string)Country.SelectedValue,
                    },
                });
                var customer = gateway.Post(new CreateStripeCustomerWithToken
                {
                    Card        = cardToken.Id,
                    Description = FirstName.Text + " " + LastName.Text,
                    Email       = Email.Text,
                });
                var charge = gateway.Post(new ChargeStripeCustomer
                {
                    Amount   = 999,
                    Customer = customer.Id,
                    Currency = "usd",
                });
                { customerID = customer.Id; };
            }
            catch (Exception g)
            {
                MessageBox.Show(g.Message + Environment.NewLine + g.InnerException +
                                Environment.NewLine + g.StackTrace + Environment.NewLine +
                                g.Data + Environment.NewLine + g.HResult + Environment.NewLine + g.GetBaseException().Message);
            }
            try
            {
                var gateway      = new StripeGateway("sk_live_DmUVQDTpe9tOV0b6kFvy9y6K00bNafAJyN");
                var subscription = gateway.Post(new SubscribeStripeCustomer
                {
                    CustomerId = customerID,
                    Plan       = "price_1H2kCBJHdLsTZND2MIJsWEEk",
                    Quantity   = 1,
                });


                WebBrowser1.Visibility = Visibility.Visible;
                WebBrowser1.Navigate("http://alliancetechhub.com/submit.php?uid=" + mc);
                Productkeyentry = true;
            }
            catch (Exception f)
            {
                MessageBox.Show(f.Message + Environment.NewLine + f.InnerException +
                                Environment.NewLine + f.StackTrace + Environment.NewLine +
                                f.Data + Environment.NewLine + f.HResult + Environment.NewLine + f.GetBaseException().Message);
            }
        }