private StripeCharge CreateCharges(double amount, string customerId, string description, bool capture = true)
        {
            var myCharge = new StripeChargeCreateOptions();

            // always set these properties
            myCharge.Amount   = Convert.ToInt32(amount * 100); // cents
            myCharge.Currency = "USD";

            // set this if you want to
            myCharge.Description = description;

            // set this property if using a customer - this MUST be set if you are using an existing source!
            myCharge.CustomerId = customerId;

            // (not required) set this to false if you don't want to capture the charge yet - requires you call capture later
            myCharge.Capture = capture;

            var          chargeService = new StripeChargeService();
            StripeCharge stripeCharge  = chargeService.Create(myCharge);

            return(stripeCharge);
        }
        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);
        }
Exemple #3
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("");
        }
Exemple #4
0
        public void Charge(int amount, string currency, string description, string cardNumber, string expireYear, string expireMonth, string cvv2)
        {
            try
            {
                // setting up the card
                var myCharge = new StripeChargeCreateOptions();

                // always set these properties
                myCharge.Amount   = amount;
                myCharge.Currency = currency;

                // set this if you want to
                //myCharge.Description = "Charge it like it's hot";

                myCharge.SourceCard = new SourceCard()
                {
                    Number          = cardNumber,
                    ExpirationYear  = expireYear,
                    ExpirationMonth = expireMonth,
                    Cvc             = cvv2
                };

                // set this property if using a customer
                //myCharge.CustomerId = *customerId*;

                // set this if you have your own application fees (you must have your application configured first within Stripe)
                //myCharge.ApplicationFee = 25;

                // (not required) set this to false if you don't want to capture the charge yet - requires you call capture later
                myCharge.Capture = true;

                var          chargeService = new StripeChargeService();
                StripeCharge stripeCharge  = chargeService.Create(myCharge);
            }
            catch (Exception ex)
            {
                throw new PaymentException(ex.Message);
            }
        }
Exemple #5
0
        public TransactionsAddRequest ChargeExistingCustomer(ChargeExistingUser model)
        {
            StripeConfiguration.SetApiKey("");

            double _convertAmountToPennies = model.Price * 100;
            int    _convertToIntAmount     = Convert.ToInt32(_convertAmountToPennies);
            //Charge the customer
            var chargeOptions = new StripeChargeCreateOptions
            {
                Amount     = _convertToIntAmount,
                Currency   = model.Currency,
                CustomerId = model.CustomerId
            };

            var          chargeService = new StripeChargeService();
            StripeCharge charge        = chargeService.Create(chargeOptions);

            //insert into transaction table
            TransactionsAddRequest transaction = new TransactionsAddRequest
            {
                UserBaseId      = model.UserBaseId,
                PlanId          = model.PlanId,
                DurationTypeId  = model.DurationTypeId,
                ChargeId        = charge.Id,
                AmountPaid      = _convertToIntAmount / 100,
                Currency        = model.Currency,
                CardId          = charge.Source.Card.Id,
                ExpMonth        = charge.Source.Card.ExpirationMonth,
                ExpYear         = charge.Source.Card.ExpirationYear,
                CardLast4       = charge.Source.Card.Last4,
                NetworkStatus   = charge.Outcome.NetworkStatus,
                Type            = charge.Outcome.Type,
                isPaid          = charge.Paid,
                CreatedDate     = charge.Created,
                DiscountPercent = model.DiscountPercent
            };

            return(transaction);
        }
        public IHttpActionResult Charge(StripeChargeRequest request)
        {
            var myCharge = new StripeChargeCreateOptions();

            // always set these properties
            myCharge.Amount   = request.OrderAmount;
            myCharge.Currency = "usd";

            // set this if you want to
            myCharge.Description = request.Description;

            myCharge.SourceTokenOrExistingSourceId = request.Token;

            var          chargeService = new StripeChargeService();
            StripeCharge stripeCharge  = chargeService.Create(myCharge);

            if (stripeCharge.Paid)
            {
                return(Ok(new
                {
                    stripeCharge.Amount,
                    stripeCharge.Created,
                    stripeCharge.Currency,
                    stripeCharge.FailureCode,
                    stripeCharge.FailureMessage,
                    stripeCharge.Id,
                    stripeCharge.LiveMode,
                    stripeCharge.Paid,
                    stripeCharge.ReceiptEmail,
                    stripeCharge.StatementDescriptor,
                    stripeCharge.Status
                }));
            }
            else
            {
                return(BadRequest("Could not complete transaction"));
            }
        }
Exemple #7
0
        public void SetDonationSource(DonationDTO donation, StripeCharge charge)
        {
            if (donation.Source.SourceType == PaymentType.Cash)
            {
                donation.Source.AccountHolderName = "cash";
            }
            else if (charge != null && charge.Source != null)
            {
                donation.Source.AccountNumberLast4 = charge.Source.AccountNumberLast4;

                if (donation.Source.SourceType != PaymentType.CreditCard || charge.Source.Brand == null)
                {
                    return;
                }
                switch (charge.Source.Brand)
                {
                case CardBrand.AmericanExpress:
                    donation.Source.CardType = CreditCardType.AmericanExpress;
                    break;

                case CardBrand.Discover:
                    donation.Source.CardType = CreditCardType.Discover;
                    break;

                case CardBrand.MasterCard:
                    donation.Source.CardType = CreditCardType.MasterCard;
                    break;

                case CardBrand.Visa:
                    donation.Source.CardType = CreditCardType.Visa;
                    break;

                default:
                    donation.Source.CardType = null;
                    break;
                }
            }
        }
Exemple #8
0
        public IActionResult Charge(string stripeEmail, string stripeToken, Tickets ticket)
        {
            var myCharge = new StripeChargeCreateOptions();

            // always set these properties
            myCharge.Amount   = (int)ticket.Total * 100;
            myCharge.Currency = "eur";

            myCharge.ReceiptEmail = stripeEmail;
            myCharge.Description  = "Test Charge";
            myCharge.SourceTokenOrExistingSourceId = stripeToken;
            myCharge.Capture = true;


            var          chargeService = new StripeChargeService();
            StripeCharge stripeCharge  = chargeService.Create(myCharge);


            Guid   g          = Guid.NewGuid();
            string GuidString = Convert.ToBase64String(g.ToByteArray());

            GuidString = GuidString.Replace("=", "");
            GuidString = GuidString.Replace("+", "");
            GuidString = GuidString.Replace("/", "");

            if (GuidString.Length > 15)
            {
                ticket.Code = GuidString.Substring(0, 15);
            }
            else
            {
                ticket.Code = GuidString;
            }
            ticket.Active = true;
            ticketRepository.Add(ticket);
            ticketRepository.Save();
            return(View("Charge", GuidString));
        }
Exemple #9
0
    protected void stripeCharge(Decimal amount, string api)
    {
        try
        {
            int amt = (int)amount * 100;
            // Set your secret key: remember to change this to your live secret key in production
            // See your keys here: https://dashboard.stripe.com/account/apikeys
            StripeConfiguration.SetApiKey(api);

            var chargeOptions = new StripeChargeCreateOptions()
            {
                Amount      = amt,
                Currency    = "usd",
                Description = "Charge Test",
                SourceTokenOrExistingSourceId = "tok_visa"
            };
            var          chargeService = new StripeChargeService();
            StripeCharge charge        = chargeService.Create(chargeOptions);
        }
        catch (Exception)
        {
        }
    }
        public void CreateCharge(string Api_Key, string stripeChargeCreateOptionsJSON, ref string Response, ref string Errors, ref int ErrorCode)
        {
            try
            {
                StripeConfiguration.SetApiKey(Api_Key);

                Serializer serializer = new Serializer();

                StripeChargeCreateOptions stripeChargeCreateOptions = serializer.Deserialize <StripeChargeCreateOptions>(stripeChargeCreateOptionsJSON);

                var          stripeChargeService = new StripeChargeService();
                StripeCharge stripeCharge        = stripeChargeService.Create(stripeChargeCreateOptions);
                Response  = stripeCharge.StripeResponse.ResponseJson;
                ErrorCode = 0;
            }
            catch (StripeException e)
            {
                ErrorCode = 1;
                Serializer  serializer  = new Serializer();
                StripeError stripeError = e.StripeError;
                Errors = serializer.Serialize <StripeError>(stripeError);
            }
        }
Exemple #11
0
        public ActionResult MonthlyCharge(string stripeToken, Subscriber subscriber)
        {
            var currentUserId = User.Identity.GetUserId();

            subscriber.ApplicationUserID = currentUserId;
            StripeConfiguration.SetApiKey(ClientKeys.StripeApiSecretKey);
            var token = stripeToken;

            var options = new StripeChargeCreateOptions
            {
                Amount      = 200,
                Currency    = "usd",
                Description = "Payment Amount",
                SourceTokenOrExistingSourceId = token,
            };

            var          service = new StripeChargeService();
            StripeCharge charge  = service.Create(options);



            return(RedirectToAction("Details"));
        }
Exemple #12
0
        /// <summary>
        /// Deduct money from client's credit card
        /// </summary>
        /// <param name="tokenId">Enter Token ID</param>
        /// <param name="amount">Enter Amount in cents</param>
        /// <returns></returns>
        public static bool PerformStripeCharge(string tokenId, int amount, string description)
        {
            try
            {
                var oneTimeCharge = new StripeChargeCreateOptions();

                // always set these properties
                oneTimeCharge.Amount   = amount;
                oneTimeCharge.Currency = "usd";

                // set this if you want to
                oneTimeCharge.Description = description;

                oneTimeCharge.SourceTokenOrExistingSourceId = tokenId;

                var          chargeService = new StripeChargeService(StripeApiKey);
                StripeCharge stripeCharge  = chargeService.Create(oneTimeCharge);

                return(true);
            }
            catch (Exception ex)
            { return(false); }
        }
    //----------------------------------------------------------------------------------------------------------------------------------------------//

    private void MakeCharge()
    {
        confirmation.transform.GetChild(2).gameObject.SetActive(true);

        int    tempTarget   = balance + topup;
        string balanceCents = (tempTarget * 100).ToString();

        activePushID = DataRef.CurrentUser().Child("stripe").Child("charges").Push().Key;

        StripeCharge charge = new StripeCharge(balanceCents, activeCardID);
        string       json   = JsonUtility.ToJson(charge);

        DataRef.CurrentUser().Child("stripe").Child("charges").Child(activePushID).SetRawJsonValueAsync(json).ContinueWith(async(task) => {
            if (task.IsFaulted || task.IsCanceled)
            {
                await new WaitForUpdate();
                confirmation.transform.GetChild(2).gameObject.SetActive(false);
                return;
            }
            await new WaitForUpdate();
            ListenForCharge();
        });
    }
        public charges_fixture()
        {
            // make sure there's a charge
            Charge = Cache.GetStripeCharge(Cache.ApiKey);

            ChargeListOptions = new StripeChargeListOptions
            {
                IncludeTotalCount = true
            };

            var service = new StripeChargeService(Cache.ApiKey);

            Charges = service.List(ChargeListOptions);

            ChargeUpdateOptions = new StripeChargeUpdateOptions
            {
                Description = "updatd description",
                // setting the updated shipping object to the same object used for the create charge
                // i attempted to just create a new shipping object and set one property,
                // but it threw an error 'name' was not supplied (which was on the original)
                Shipping = Cache.GetStripeChargeCreateOptions().Shipping
            };

            ChargeUpdateOptions.Shipping.Phone          = "8675309";
            ChargeUpdateOptions.Shipping.TrackingNumber = "56789";

            UpdatedCharge = service.Update(Charge.Id, ChargeUpdateOptions);

            UncapturedCharge = Cache.GetStripeChargeUncaptured(Cache.ApiKey);

            ChargeCaptureOptions = new StripeChargeCaptureOptions
            {
                Amount = 123,
                StatementDescriptor = "CapturedCharge"
            };
            CapturedCharge = service.Capture(UncapturedCharge.Id, ChargeCaptureOptions);
        }
Exemple #15
0
        public IActionResult ExtendSubscriptionStripe([FromBody] StripePaymentRequest paymentRequest)
        {
            //Stripe developer api key
            StripeConfiguration.SetApiKey("sk_test_IhD98M0gMGB1G7rbcHifS3GP");

            //configuration of stripe chrarge object
            var myCharge = new StripeChargeCreateOptions();

            myCharge.SourceTokenOrExistingSourceId = paymentRequest.tokenId;
            myCharge.Amount             = paymentRequest.amount;
            myCharge.Currency           = "gbp";
            myCharge.Description        = paymentRequest.productName;
            myCharge.Metadata           = new Dictionary <string, string>();
            myCharge.Metadata["OurRef"] = "OurRef-" + Guid.NewGuid().ToString();

            var          chargeService = new StripeChargeService();
            StripeCharge stripeCharge  = chargeService.Create(myCharge);

            if (stripeCharge.Status.Equals("succeeded"))
            {
                TransactionDto transaction = new TransactionDto();
                transaction.Amount           = (decimal)(paymentRequest.amount / 100.0);
                transaction.Status           = "succeeded";
                transaction.CustomerId       = 1;
                transaction.PaymentGatewayId = 1;
                transaction.PricingPackageId = paymentRequest.packageId;
                transaction.DateCreated      = DateTime.Now;
                _transactionManipulation.SaveTransaction(transaction);


                SubscriptionDto subscription = _subscriptionManipulation.GetCustomerSubscription(1);
                subscription.SubscriptionExpirationDate = subscription.SubscriptionExpirationDate.AddMonths(1);
                _subscriptionManipulation.UpdateSubscription(subscription);
            }
            return(Ok(stripeCharge));
        }
Exemple #16
0
        private bool StripeCharge(string stipeEmail, string stripeToken, float amount, string currency, string descr, string secretkey)
        {
            // Set your secret key: remember to change this to your live secret key in production
            // See your keys here: https://dashboard.stripe.com/account/apikeys
            StripeConfiguration.SetApiKey(secretkey);

            var options = new StripeChargeCreateOptions
            {
                Amount      = int.Parse((amount * 100).ToString()),
                Currency    = currency,
                Description = descr,
                SourceTokenOrExistingSourceId = stripeToken,
            };
            var service = new StripeChargeService();

            StripeCharge charge = service.Create(options);

            if (charge.Captured == true)
            {
                return(true);
            }

            return(false);
        }
Exemple #17
0
        public bool ProcessPayment(string token)
        {
            var myCharge = new StripeChargeCreateOptions();

            // Always set these properties
            myCharge.Amount      = 50;
            myCharge.Currency    = "usd";
            myCharge.Description = "Premium membership";
            myCharge.SourceTokenOrExistingSourceId = token;
            // (not required) set this to false if you don't want to capture the charge yet - requires you call capture later
            myCharge.Capture           = true;
            stripeChargeService.ApiKey = paymentSettings.StripePrivateKey;
            StripeCharge stripeCharge = stripeChargeService.Create(myCharge);

            if (String.IsNullOrEmpty(stripeCharge.FailureCode) && String.IsNullOrEmpty(stripeCharge.FailureMessage))
            {
                return(true);
            }
            else
            {
                //TODO: Handle errors
                return(false);
            }
        }
Exemple #18
0
        //ONE-TIME CHARGE
        public void Charge(ChargeRequest model)
        {
            StripeConfiguration.SetApiKey("");

            var options = new StripeChargeCreateOptions
            {
                Amount   = (int)(model.Amount * 100), //Stripe arg in units of cents (usd)
                Currency = model.Currency,
                SourceTokenOrExistingSourceId = model.SourceTokenOrExistingSourceId,
                ReceiptEmail = model.Email
            };
            var          service = new StripeChargeService();
            StripeCharge charge  = service.Create(options);

            //insert into transaction table
            TransactionsAddRequest transactionModel = new TransactionsAddRequest
            {
                UserBaseId      = model.UserBaseId,
                PlanId          = model.PlanId,
                DurationTypeId  = model.DurationTypeId,
                DiscountPercent = model.DiscountPercent,
                ChargeId        = charge.Id,
                AmountPaid      = model.Amount,
                Currency        = model.Currency,
                CardId          = charge.Source.Card.Id,
                ExpMonth        = charge.Source.Card.ExpirationMonth,
                ExpYear         = charge.Source.Card.ExpirationYear,
                CardLast4       = charge.Source.Card.Last4,
                NetworkStatus   = charge.Outcome.NetworkStatus,
                Type            = charge.Outcome.Type,
                isPaid          = charge.Paid,
                CreatedDate     = charge.Created
            };

            InsertTransaction(transactionModel);
        }
        private void ExecutePayment(Player player, ModalForm modal)
        {
            StripeConfiguration.SetApiKey("sk_test_****************************");             // Add your API key here

            double amount = 1.90;

            var chargeOptions = new StripeChargeCreateOptions()
            {
                Amount      = (int?)(amount * 100),
                Currency    = "usd",
                Description = "Charge for [email protected]",
                SourceCard  = new SourceCard()
                {
                    Number          = "4242424242424242",
                    ExpirationMonth = 01,
                    ExpirationYear  = 2025,
                    Cvc             = "111",
                    Capture         = true
                },
            };

            var          chargeService = new StripeChargeService();
            StripeCharge charge        = chargeService.Create(chargeOptions);
        }
        //Billing
        public ActionResult CreateStripeCustomer(string token)
        {
            var          email           = Session["Email"].ToString();
            var          subscription    = new StripeSubscription();
            var          customerDetails = new StripeCustomer();
            var          userInfo        = new UpdateUserInfo();
            string       msg             = "";
            var          cardStatus      = 0;
            DataTable    userData;
            StripeCharge charge = null;

            try
            {
                if (token != null)
                {
                    var ds = new AccountData().ValidateEmailAndGetUserinfo(email);
                    userData = ds.Tables[0];
                    var custID = Convert.ToString(userData.Rows[0]["stp_custId"]);
                    if (userData.Rows.Count > 0 && !string.IsNullOrWhiteSpace(custID))                                 //update
                    {
                        var customerUpdateOptions = new StripeCustomerUpdateOptions
                        {
                            Email       = email,
                            Description = Session["FirstName"] + " " + Session["LastName"],
                            SourceToken = token
                        };

                        //updated customer
                        customerDetails = StripeHelper.UpdateCustomer(custID, customerUpdateOptions);

                        //add a test charge for $1
                        var makeTestCharge = new StripeChargeCreateOptions
                        {
                            CustomerId  = customerDetails.Id,
                            Amount      = 100,
                            Currency    = "usd",
                            Description = "Card verification charge",
                            SourceTokenOrExistingSourceId = customerDetails.DefaultSourceId
                        };
                        charge = StripeHelper.MakePayment(makeTestCharge);
                        if (charge != null)
                        {
                            var refund = StripeHelper.RefundCharge(charge.Id);
                            cardStatus      = 1;
                            userInfo.CustId = customerDetails.Id;
                            userInfo.CardId = customerDetails.DefaultSourceId;
                            userInfo.UserId = Convert.ToInt32(Session["UserID"]);
                            AccountData.UpdateStripeCardData(userInfo);
                            if ((SessionData.PlanID == 1 && SessionData.TrialEndOn < DateTime.Now) || SessionData.PlanStatus == 0) //When trail was expired || Unsubscribed and adding a card since payments are not succesfull
                            {
                                msg = StripeServices.SubscribePlan(SessionData.StripeCustId, userInfo.CardId);
                            }
                            if (String.IsNullOrWhiteSpace(msg))
                            {
                                SessionData.PlanStatus   = 1; //Default subscription
                                SessionData.StripeCustId = customerDetails.Id;
                                SessionData.StripeCardId = customerDetails.DefaultSourceId;
                            }
                        }
                        else
                        {
                            StripeHelper.DeleteCard(customerDetails.DefaultSourceId, custID);
                            cardStatus = 0;
                        }
                    }
                    customerDetails = StripeHelper.GetStripeCustomer(customerDetails.Id);
                }

                var respo = new { Status = cardStatus, Message = msg, CustomerDetails = customerDetails };
                return(Json(respo, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogFile.WriteLog("CreateCustomer - " + ex.Message.ToString());
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get Querystring Values
            if (string.IsNullOrEmpty(Request.QueryString["Item"]) || string.IsNullOrEmpty(Request.QueryString["UserID"]) || string.IsNullOrEmpty(Request.QueryString["UserName"]) || string.IsNullOrEmpty(Request.QueryString["Price"]))
            {
                //QueryString null, Redirect USer
                Response.Redirect("/Home?MSG=CheckOutError");
            }

            else
            {
                //Retrieve QS values
                ItemPrice = Request.QueryString["Price"];
                Item      = Request.QueryString["Item"];
                UserName  = Request.QueryString["UserName"];
                UserId    = Request.QueryString["UserID"];
            }

            //Check for postback
            if (!Page.IsPostBack)
            {
                //Load Data to form
                try
                {
                    //Get the logged in User if any
                    MembershipUser LoggedInMembershipUser;
                    LoggedInMembershipUser = Membership.GetUser();

                    //Check if there is a logged in User
                    if (LoggedInMembershipUser != null)
                    {
                        //Membership Data
                        UserName2.Text = LoggedInMembershipUser.UserName.ToString();
                        Email.Text     = LoggedInMembershipUser.Email.ToString();
                        Price.Text     = "$" + ItemPrice;
                        Hours.Text     = Item;

                        //Set link
                        HLPaypal.NavigateUrl = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=J9T4RVL3P6SRE&item_name=" + Item +
                                               "&amount=" + ItemPrice + "&on1=RALTUserID&os1=" + UserId + "&on0=RALTUserName&os0=" + UserName;

                        //RALT UserData
                        user UserData = new user();
                        UserData = UserService.GetUserByMemberId(Convert.ToInt32(LoggedInMembershipUser.ProviderUserKey.ToString()));

                        //Show User Status
                        if (UserData.account_status == "Request Made")
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "CompleteVerify", "CompleteStep(" + '0' + ");", true);
                        }
                        else if (UserData.account_status == "Verified")
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "CompleteVerify", "CompleteStep(" + '1' + ");", true);
                        }
                        else if (UserData.account_status == "Email Sent")
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "CompleteVerify", "CompleteStep(" + '2' + ");", true);
                        }
                        else if (UserData.account_status == "Paid")
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "CompleteVerify", "CompleteStep(" + '3' + ");", true);
                        }
                        else if (UserData.account_status == "First Class")
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "CompleteVerify", "CompleteStep(" + '4' + ");", true);
                        }
                    }
                }

                catch
                {
                }
            }

            //PostBack
            else
            {
                //Retrieve the StripeToken if any
                var customerToken = this.Request.Form["stripeToken"];

                //No Token do not proceed
                if (!object.ReferenceEquals(customerToken, null))
                {
                    try
                    {
                        var myCharge = new StripeChargeCreateOptions();

                        double Price = Convert.ToDouble(ItemPrice);

                        // always set these properties
                        myCharge.AmountInCents = (int)(Price * 100);
                        myCharge.Currency      = "usd";

                        // set this if you want to
                        myCharge.Description = Request.QueryString["Item"];

                        Dictionary <string, string> dictionary =
                            new Dictionary <string, string>();
                        dictionary.Add("RALTUserName", Request.QueryString["UserName"]);
                        dictionary.Add("RALTUserID", Request.QueryString["UserID"]);

                        myCharge.Metadata = dictionary;

                        // set this property if using a token
                        myCharge.TokenId = customerToken;

                        // (not required) set this to false if you don't want to capture the charge yet - requires you call capture later
                        myCharge.Capture = true;

                        var          chargeService = new StripeChargeService();
                        StripeCharge stripeCharge  = chargeService.Create(myCharge);

                        //Clear CC details
                        //  this.Request.Form.Remove("stripeToken");

                        CardHolderName.Text = "";
                        CardNumber.Text     = "";
                        CVC.Text            = "";
                        EXPMonth.Text       = "";
                        EXPYear.Text        = "";


                        App_Code.NotificationService.SendNotification("ChargeComplete", "Thank you, your payment is complete.", "success", "3000");
                    }

                    catch (Exception ex)
                    {
                        App_Code.NotificationService.SendNotification("ChargeError", ex.Message, "error");
                    }
                }
            }
        }
Exemple #22
0
 public void SendRefundIssuedNotificationToTeam(Payment payment, StripeCharge charge, Department department)
 {
     _emailProvider.TEAM_SendNotifyRefundIssued(department.DepartmentId.ToString(), department.Name, DateTime.UtcNow.ToShortDateString() + " " + DateTime.UtcNow.ToShortTimeString(),
                                                (float.Parse(charge.AmountRefunded.ToString()) / 100f).ToString("C"), ((PaymentMethods)payment.Method).ToString(), charge.Id, payment.PaymentId.ToString());
 }
Exemple #23
0
 public Task <StripeResponse> PayCustomer(StripeCharge pay)
 {
     throw new NotImplementedException();
 }
Exemple #24
0
        public static void PaymentMethod(int amount)
        {
            // var amount = 100;
            //var payment = Stripe.StripeCharge.(amount);
            try
            {
                //use nu-get Stripe
                //set TLS 1.2 in androuid settings

                StripeConfiguration.SetApiKey("sk_test_BEPrGyKARA5fbK1rcLbAixdd");

                var chargeOptions = new StripeChargeCreateOptions()
                {
                    Amount   = amount,
                    Currency = "eur",
                    SourceTokenOrExistingSourceId = "tok_visa",
                    Metadata = new Dictionary <String, String>()
                    {
                        { "OrderId", "6735" }
                    }
                };

                var          chargeService = new StripeChargeService();
                StripeCharge charge        = chargeService.Create(chargeOptions);
            }
            // Use Stripe's library to make request

            catch (StripeException ex)
            {
                switch (ex.StripeError.ErrorType)
                {
                case "card_error":
                    System.Diagnostics.Debug.WriteLine("   Code: " + ex.StripeError.Code);
                    System.Diagnostics.Debug.WriteLine("Message: " + ex.StripeError.Message);
                    break;

                case "api_connection_error":
                    System.Diagnostics.Debug.WriteLine(" apic  Code: " + ex.StripeError.Code);
                    System.Diagnostics.Debug.WriteLine("apic Message: " + ex.StripeError.Message);
                    break;

                case "api_error":
                    System.Diagnostics.Debug.WriteLine("api   Code: " + ex.StripeError.Code);
                    System.Diagnostics.Debug.WriteLine("api Message: " + ex.StripeError.Message);
                    break;

                case "authentication_error":
                    System.Diagnostics.Debug.WriteLine(" auth  Code: " + ex.StripeError.Code);
                    System.Diagnostics.Debug.WriteLine("auth Message: " + ex.StripeError.Message);
                    break;

                case "invalid_request_error":
                    System.Diagnostics.Debug.WriteLine(" invreq  Code: " + ex.StripeError.Code);
                    System.Diagnostics.Debug.WriteLine("invreq Message: " + ex.StripeError.Message);
                    break;

                case "rate_limit_error":
                    System.Diagnostics.Debug.WriteLine("  rl Code: " + ex.StripeError.Code);
                    System.Diagnostics.Debug.WriteLine("rl Message: " + ex.StripeError.Message);
                    break;

                case "validation_error":
                    System.Diagnostics.Debug.WriteLine(" val  Code: " + ex.StripeError.Code);
                    System.Diagnostics.Debug.WriteLine("val Message: " + ex.StripeError.Message);
                    break;

                default:
                    // Unknown Error Type
                    break;
                }
            }
        }
Exemple #25
0
        public async Task <ActionResult> Payment(int id, string stripeToken, string stripeEmail)
        {
            var selectQuery = await _orderService.Query(x => x.ID == id).Include(x => x.Listing).SelectAsync();

            // Check if order exists
            var order = selectQuery.FirstOrDefault();

            if (order == null)
            {
                return(new HttpNotFoundResult());
            }

            var stripeConnectQuery = await _stripeConnectService.Query(x => x.UserID == order.UserProvider).SelectAsync();

            var stripeConnect = stripeConnectQuery.FirstOrDefault();

            if (stripeConnect == null)
            {
                return(new HttpNotFoundResult());
            }

            // Check for customer profile
            var userId = User.Identity.GetUserId();

            // Create a customer profile for future checkouts
            var customerCreate = new StripeCustomerCreateOptions()
            {
                Email  = stripeEmail,
                Source = new StripeSourceOptions()
                {
                    TokenId = stripeToken
                }
            };
            var customerCreateService = new StripeCustomerService(CacheHelper.GetSettingDictionary("StripeApiKey").Value);
            var response = customerCreateService.Create(customerCreate);

            var customer = new StripeCustomerReference()
            {
                UserID           = userId,
                StripeCustomerID = response.Id,
                ObjectState      = Repository.Pattern.Infrastructure.ObjectState.Added
            };

            _stripeCusRefService.Insert(customer);
            await _unitOfWorkAsyncStripe.SaveChangesAsync();

            //https://stripe.com/docs/checkout
            var charge = new StripeChargeCreateOptions();

            // always set these properties
            charge.Amount     = order.PriceInCents;
            charge.Currency   = CacheHelper.Settings.Currency;
            charge.CustomerId = customer.StripeCustomerID;

            // set booking fee
            var bookingFee = (int)Math.Round(CacheHelper.Settings.TransactionFeePercent * order.PriceInCents);

            if (bookingFee < CacheHelper.Settings.TransactionMinimumFee * 100)
            {
                bookingFee = (int)(CacheHelper.Settings.TransactionMinimumFee * 100);
            }

            charge.ApplicationFee = bookingFee;
            charge.Capture        = false;
            charge.Description    = order.Description;
            charge.Destination    = stripeConnect.stripe_user_id;
            var          chargeService = new StripeChargeService(CacheHelper.GetSettingDictionary("StripeApiKey").Value);
            StripeCharge stripeCharge  = chargeService.Create(charge);

            // Update order status
            order.Status        = (int)Enum_OrderStatus.Pending;
            order.PaymentPlugin = StripePlugin.PluginName;
            _orderService.Update(order);

            // Save transaction
            var transaction = new StripeTransaction()
            {
                OrderID        = id,
                ChargeID       = stripeCharge.Id,
                StripeEmail    = stripeEmail,
                CustomerId     = customer.StripeCustomerID,
                Created        = DateTime.Now,
                LastUpdated    = DateTime.Now,
                FailureCode    = stripeCharge.FailureCode,
                FailureMessage = stripeCharge.FailureMessage,
                ObjectState    = Repository.Pattern.Infrastructure.ObjectState.Added
            };

            _transactionService.Insert(transaction);

            await _unitOfWorkAsync.SaveChangesAsync();

            await _unitOfWorkAsyncStripe.SaveChangesAsync();

            ClearCache();

            // Payment succeeded
            if (string.IsNullOrEmpty(stripeCharge.FailureCode))
            {
                // Send message to the user
                var message = new MessageSendModel()
                {
                    UserFrom  = order.UserReceiver,
                    UserTo    = order.UserProvider,
                    Subject   = order.Listing.Title,
                    ListingID = order.ListingID,
                    Body      = HttpContext.ParseAndTranslate(string.Format(
                                                                  "[[[Order Requested - %0 - Total Price %1 %2. <a href=\"%3\">See Details</a>|||{0}|||{1}|||{2}|||{3}]]]",
                                                                  order.Description,
                                                                  order.Price,
                                                                  order.Currency,
                                                                  Url.Action("Orders", "Payment")))
                };

                await MessageHelper.SendMessage(message);

                TempData[TempDataKeys.UserMessage] = "[[[Thanks for your order! You payment will not be charged until the provider accepted your request.]]]";
                return(RedirectToAction("Orders", "Payment"));
            }
            else
            {
                TempData[TempDataKeys.UserMessageAlertState] = "bg-danger";
                TempData[TempDataKeys.UserMessage]           = stripeCharge.FailureMessage;

                return(RedirectToAction("Payment"));
            }
        }
Exemple #26
0
        public override CallbackInfo ProcessCallback(Order order, HttpRequest request, IDictionary <string, string> settings)
        {
            CallbackInfo callbackInfo = null;

            try {
                order.MustNotBeNull("order");
                request.MustNotBeNull("request");
                settings.MustNotBeNull("settings");
                settings.MustContainKey("mode", "settings");
                settings.MustContainKey(settings["mode"] + "_secret_key", "settings");

                // If in test mode, write out the form data to a text file
                if (settings.ContainsKey("mode") && settings["mode"] == "test")
                {
                    LogRequest <Stripe>(request, logPostData: true);
                }

                StripeChargeCreateOptions chargeOptions = new StripeChargeCreateOptions {
                    AmountInCents = (int)(order.TotalPrice.Value.WithVat * 100),
                    Currency      = CurrencyService.Instance.Get(order.StoreId, order.CurrencyId).IsoCode,
                    TokenId       = request.Form["stripeToken"],
                    Description   = order.CartNumber,
                    Capture       = settings.ContainsKey("capture") && (settings["capture"].TryParse <bool>() ?? false)
                };

                StripeChargeService chargeService = new StripeChargeService(settings[settings["mode"] + "_secret_key"]);
                StripeCharge        charge        = chargeService.Create(chargeOptions);

                if (charge.AmountInCents != null && charge.Paid != null && charge.Paid.Value)
                {
                    callbackInfo = new CallbackInfo((decimal)charge.AmountInCents.Value / 100, charge.Id, charge.Captured != null && charge.Captured.Value ? PaymentState.Captured : PaymentState.Authorized);
                }
            } catch (StripeException e) {
                // Pass through request fields
                string requestFields = string.Join("", request.Form.AllKeys.Select(k => "<input type=\"hidden\" name=\"" + k + "\" value=\"" + request.Form[k] + "\" />"));

                //Add error details from the exception.
                requestFields = requestFields + "<input type=\"hidden\" name=\"TransactionFailed\" value=\"true\" />";
                requestFields = requestFields + "<input type=\"hidden\" name=\"FailureReason.chargeId\" value=\"" + e.StripeError.ChargeId + "\" />";
                requestFields = requestFields + "<input type=\"hidden\" name=\"FailureReason.Code\" value=\"" + e.StripeError.Code + "\" />";
                requestFields = requestFields + "<input type=\"hidden\" name=\"FailureReason.Error\" value=\"" + e.StripeError.Error + "\" />";
                requestFields = requestFields + "<input type=\"hidden\" name=\"FailureReason.ErrorSubscription\" value=\"" + e.StripeError.ErrorSubscription + "\" />";
                requestFields = requestFields + "<input type=\"hidden\" name=\"FailureReason.ErrorType\" value=\"" + e.StripeError.ErrorType + "\" />";
                requestFields = requestFields + "<input type=\"hidden\" name=\"FailureReason.Message\" value=\"" + e.StripeError.Message + "\" />";
                requestFields = requestFields + "<input type=\"hidden\" name=\"FailureReason.Parameter\" value=\"" + e.StripeError.Parameter + "\" />";

                string paymentForm = PaymentMethodService.Instance.Get(order.StoreId, order.PaymentInformation.PaymentMethodId.Value).GeneratePaymentForm(order, requestFields);

                //Force the form to auto submit
                paymentForm += "<script type=\"text/javascript\">document.forms[0].submit();</script>";

                //Write out the form
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Write(paymentForm);
                HttpContext.Current.Response.End();
            } catch (Exception exp) {
                LoggingService.Instance.Error <Stripe>("Stripe(" + order.CartNumber + ") - ProcessCallback", exp);
            }

            return(callbackInfo);
        }
Exemple #27
0
        static void Main(string[] args)
        {
            var usersForPaymentDeduction = unitOfWork.UserSubscriptionDeductionQueueRepository.GetAll().ToList();

            foreach (var paymentUser in usersForPaymentDeduction)
            {
                DateTime newDeductionDate;
                if (paymentUser.TermLengthId == Convert.ToInt32(PlanTermLengthEnum.OneMonth))
                {
                    int days = (DateTime.DaysInMonth((paymentUser.LastDeductionDate).Year, ((paymentUser.LastDeductionDate).Month + 1)));
                    newDeductionDate = paymentUser.LastDeductionDate.AddDays(days);
                }
                else if (paymentUser.TermLengthId == Convert.ToInt32(PlanTermLengthEnum.OneYear))
                {
                    newDeductionDate = paymentUser.LastDeductionDate.AddDays(365);
                }
                else if (paymentUser.TermLengthId == Convert.ToInt32(PlanTermLengthEnum.OneYear))
                {
                    newDeductionDate = paymentUser.LastDeductionDate.AddDays(365 * 2);
                }
                else
                {
                    newDeductionDate = paymentUser.LastDeductionDate.AddDays(365 * 3);
                }

                // DateTime newDeductionDate = paymentUser.LastDeductionDate.AddDays();
                if (DateTime.Now.Date == newDeductionDate.Date)
                {
                    var user = unitOfWork.UserRepository.GetAll().Where(u => u.Id == paymentUser.UserId).SingleOrDefault();
                    if (user != null && user.UserCards != null && user.UserCards.Count() > 0)
                    {
                        var activeCard      = user.UserCards.Where(c => c.IsActive).SingleOrDefault();
                        var currentUserPlan = user.UserPlans.Where(up => up.IsActive).SingleOrDefault();
                        if (activeCard != null)
                        {
                            if (currentUserPlan != null)
                            {
                                StripeCharge charge = null;
                                // int newPlanPrice = Convert.ToInt32(accounts) * Convert.ToInt32(plan.Price * planTermLength.Percent * planTermLength.Month) / 100;
                                int price       = Convert.ToInt32(currentUserPlan.Price);
                                int userCredits = (user.UserCredits != null && user.UserCredits.Count() > 0) ? Convert.ToInt32(user.UserCredits.OrderByDescending(c => c.AddedDate).First().Amount) : 0;

                                try
                                {
                                    int usedUserCredits = 0;
                                    if (userCredits != 0 && userCredits < price)
                                    {
                                        price           = price - userCredits;
                                        usedUserCredits = userCredits;
                                    }
                                    else if (userCredits > price)
                                    {
                                        price           = 0;
                                        userCredits     = userCredits - price;
                                        usedUserCredits = price;
                                    }

                                    string PlanName = unitOfWork.SubscriptionPlanRepository.GetAll().Where(p => p.PlanID == currentUserPlan.PlanID).Single().Name;
                                    if (price > 0)
                                    {
                                        var ApplicationFees = Math.Round((((price) * 0.029) + 0.30), 2);
                                        charge = ChargeCustomer(activeCard.CustomerId, Convert.ToInt32(price + ApplicationFees));
                                        user.UserInvoiceHistory.Add(new UserInvoiceHistory()
                                        {
                                            Id                   = Guid.NewGuid(),
                                            PlanId               = currentUserPlan.PlanID,
                                            PlanName             = PlanName,
                                            Status               = charge.Status,
                                            Price                = price,
                                            Paid                 = charge.Paid,
                                            FailureCode          = charge.FailureCode,
                                            FailureMessage       = charge.FailureMessage,
                                            TransactionDate      = DateTime.Now,
                                            UsedUserCreditAmount = usedUserCredits
                                        });
                                    }
                                    else
                                    {
                                        user.UserInvoiceHistory.Add(new UserInvoiceHistory()
                                        {
                                            Id                   = Guid.NewGuid(),
                                            PlanId               = currentUserPlan.PlanID,
                                            PlanName             = PlanName,
                                            Status               = "succeeded",
                                            Price                = price,
                                            Paid                 = true,
                                            TransactionDate      = DateTime.Now,
                                            UsedUserCreditAmount = usedUserCredits
                                        });
                                    }

                                    if (userCredits > 0)
                                    {
                                        user.UserCredits.Add(new UserCredit()
                                        {
                                            AddedDate = DateTime.Now, Amount = userCredits
                                        });
                                    }

                                    paymentUser.LastDeductionDate = DateTime.Now;
                                    unitOfWork.UserSubscriptionDeductionQueueRepository.Update(paymentUser);
                                    unitOfWork.UserRepository.Update(user);
                                }
                                catch (Exception ex)
                                {
                                    user.UserPlans.Remove(currentUserPlan);
                                    currentUserPlan.IsCardDeductionError = true;
                                    currentUserPlan.IsActive             = false;
                                    user.UserPlans.Add(currentUserPlan);
                                    unitOfWork.UserRepository.Update(user);
                                }
                            }
                        }
                        else
                        {
                            user.UserPlans.Remove(currentUserPlan);
                            currentUserPlan.IsActive = false;
                            user.UserPlans.Add(currentUserPlan);
                            unitOfWork.UserRepository.Update(user);
                        }
                    }
                }
            }
        }
Exemple #28
0
        public async Task <IActionResult> Create(Order frmOrder)
        {
            if (ModelState.IsValid)
            {
                var user = _identitySvc.Get(HttpContext.User);

                Order order = frmOrder;

                order.UserName = user.Email;
                order.BuyerId  = user.Id;

                var chargeOptions = new StripeChargeCreateOptions()

                {
                    //required
                    Amount   = (int)(order.OrderTotal * 100),
                    Currency = "usd",
                    SourceTokenOrExistingSourceId = order.StripeToken,
                    //optional
                    Description  = string.Format("Order Payment {0}", order.UserName),
                    ReceiptEmail = order.UserName,
                };

                var chargeService = new StripeChargeService();

                chargeService.ApiKey = paymentSettings.StripePrivateKey;


                StripeCharge stripeCharge = null;
                try
                {
                    stripeCharge = chargeService.Create(chargeOptions);
                    _logger.LogDebug("Stripe charge object creation" + stripeCharge.StripeResponse.ObjectJson);
                }
                catch (StripeException stripeException)
                {
                    _logger.LogDebug("Stripe exception " + stripeException.Message);
                    ModelState.AddModelError(string.Empty, stripeException.Message);
                    return(View(frmOrder));
                }


                try
                {
                    if (stripeCharge.Id != null)
                    {
                        //_logger.LogDebug("TransferID :" + stripeCharge.Id);
                        order.PaymentAuthCode = stripeCharge.Id;

                        //_logger.LogDebug("User {userName} started order processing", user.UserName);
                        int orderId = await _orderSvc.CreateOrder(order);

                        //_logger.LogDebug("User {userName} finished order processing  of {orderId}.", order.UserName, order.OrderId);

                        //await _cartSvc.ClearCart(user);
                        return(RedirectToAction("Complete", new { id = orderId, userName = user.UserName }));
                    }

                    else
                    {
                        ViewData["message"] = "Payment cannot be processed, try again";
                        return(View(frmOrder));
                    }
                }
                catch (BrokenCircuitException)
                {
                    ModelState.AddModelError("Error", "It was not possible to create a new order, please try later on. (Business Msg Due to Circuit-Breaker)");
                    return(View(frmOrder));
                }
            }
            else
            {
                return(View(frmOrder));
            }
        }
Exemple #29
0
        public async Task <ActionResult> Download(int?id, bool?bought, string stripeId)
        {
            Service service = db.Services.Find(id);

            if (id == null)
            {
                return(View("NotFound"));
            }
            if (service.Video != null)
            {
                if (bought == true && stripeId != null)
                {
                    int nonNullId = id.Value;

                    string strIpAddress = string.Empty;
                    strIpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

                    if (strIpAddress == "" || strIpAddress == null)
                    {
                        strIpAddress = Request.ServerVariables["REMOTE_ADDR"];
                    }

                    //Don't record analytics coming from garbage IP addresses
                    if (strIpAddress != "::1")
                    {
                        DownloadAnalytic analyitic = new DownloadAnalytic();
                        analyitic.IPAddress = strIpAddress;
                        analyitic.ServiceId = nonNullId;
                        service.DownloadAnalytics.Add(analyitic);
                        db.SaveChanges();
                        await PopulateDownloadAnalyticObject(analyitic);
                    }
                    try
                    {
                        var          chargeService = new StripeChargeService();
                        StripeCharge stripeCharge  = chargeService.Get(stripeId);
                        if (stripeCharge.Status == "succeeded")
                        {
                            CloudStorageAccount storageAccount  = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
                            CloudBlobClient     blobClient      = storageAccount.CreateCloudBlobClient();
                            CloudBlobContainer  container       = blobClient.GetContainerReference("videos");
                            string                 userFileName = service.FirstName + "_" + service.LastName + "_Video.mp4";
                            CloudBlockBlob         blob         = container.GetBlockBlobReference(service.Video.ConvertedFilePath);
                            SharedAccessBlobPolicy policy       = new SharedAccessBlobPolicy()
                            {
                                Permissions            = SharedAccessBlobPermissions.Read,
                                SharedAccessExpiryTime = DateTime.Now.AddYears(100)
                            };
                            SharedAccessBlobHeaders blobHeaders = new SharedAccessBlobHeaders()
                            {
                                ContentDisposition = "attachment; filename=" + userFileName
                            };
                            string sasToken = blob.GetSharedAccessSignature(policy, blobHeaders);
                            var    sasUrl   = blob.Uri.AbsoluteUri + sasToken;//This is the URL you will use. It will force the user to download the vi
                            return(Redirect(sasUrl));
                        }
                    }
                    catch
                    {
                        return(View("NotFound"));
                    }
                }
                //publicly exposing URL for now
                if (Authorize(service) || service.IsSecured != true)
                {
                    if (service.Video != null)
                    {
                        CloudStorageAccount storageAccount  = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
                        CloudBlobClient     blobClient      = storageAccount.CreateCloudBlobClient();
                        CloudBlobContainer  container       = blobClient.GetContainerReference("videos");
                        string                 userFileName = service.FirstName + "_" + service.LastName + "_Video.mp4";
                        CloudBlockBlob         blob         = container.GetBlockBlobReference(service.Video.ConvertedFilePath);
                        SharedAccessBlobPolicy policy       = new SharedAccessBlobPolicy()
                        {
                            Permissions            = SharedAccessBlobPermissions.Read,
                            SharedAccessExpiryTime = DateTime.Now.AddYears(100)
                        };
                        SharedAccessBlobHeaders blobHeaders = new SharedAccessBlobHeaders()
                        {
                            ContentDisposition = "attachment; filename=" + userFileName
                        };
                        string sasToken = blob.GetSharedAccessSignature(policy, blobHeaders);
                        var    sasUrl   = blob.Uri.AbsoluteUri + sasToken;//This is the URL you will use. It will force the user to download the vi
                        return(Redirect(sasUrl));
                    }
                }
            }
            return(View("NotFound"));
        }
 private string GetStripeChargeString(StripeCharge charge)
 {
     return(String.Format("description={0}&currency={1}&amount={2}&customer={3}&source={4}", charge.Description != null ? charge.Description.Replace(' ', '+') : String.Empty, charge.Currency, charge.Amount, charge.Customer.Id, charge.Source.Id));
 }