示例#1
0
 public virtual StripeCustomer Update(string customerId, StripeCustomerUpdateOptions updateOptions, StripeRequestOptions requestOptions = null)
 {
     return(Mapper <StripeCustomer> .MapFromJson(
                Requestor.PostString(
                    this.ApplyAllParameters(updateOptions, $"{Urls.Customers}/{WebUtility.UrlEncode(customerId)}", false),
                    this.SetupRequestOptions(requestOptions))));
 }
 public virtual async Task <StripeCustomer> UpdateAsync(string customerId, StripeCustomerUpdateOptions updateOptions, StripeRequestOptions requestOptions = null)
 {
     return(Mapper <StripeCustomer> .MapFromJson(
                await Requestor.PostStringAsync(this.ApplyAllParameters(updateOptions, $"{Urls.Customers}/{customerId}", false),
                                                SetupRequestOptions(requestOptions))
                ));
 }
 public virtual StripeCustomer Update(string customerId, StripeCustomerUpdateOptions updateOptions, StripeRequestOptions requestOptions = null)
 {
     return Mapper<StripeCustomer>.MapFromJson(
         Requestor.PostString(this.ApplyAllParameters(updateOptions, $"{Urls.Customers}/{customerId}", false),
         SetupRequestOptions(requestOptions))
     );
 }
 public virtual async Task<StripeCustomer> UpdateAsync(string customerId, StripeCustomerUpdateOptions updateOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return Mapper<StripeCustomer>.MapFromJson(
         await Requestor.PostStringAsync(this.ApplyAllParameters(updateOptions, $"{Urls.Customers}/{customerId}", false),
         SetupRequestOptions(requestOptions),
         cancellationToken)
     );
 }
示例#5
0
 public virtual async Task <StripeCustomer> UpdateAsync(string customerId, StripeCustomerUpdateOptions updateOptions, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(Mapper <StripeCustomer> .MapFromJson(
                await Requestor.PostStringAsync(
                    this.ApplyAllParameters(updateOptions, $"{Urls.Customers}/{WebUtility.UrlEncode(customerId)}", false),
                    this.SetupRequestOptions(requestOptions),
                    cancellationToken).ConfigureAwait(false)));
 }
        public StripeCustomer Update(string customerId, StripeCustomerUpdateOptions updateOptions)
        {
            var url = string.Format("{0}/{1}", Urls.Customers, customerId);
            url = ParameterBuilder.ApplyAllParameters(updateOptions, url);

            var response = Requestor.PostString(url);

            return PopulateStripeCustomer(response);
        }
		public virtual StripeCustomer Update(string customerId, StripeCustomerUpdateOptions updateOptions)
		{
			var url = string.Format("{0}/{1}", Urls.Customers, customerId);
			url = ParameterBuilder.ApplyAllParameters(updateOptions, url);

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

			return Mapper<StripeCustomer>.MapFromJson(response);
		}
示例#8
0
        public StripeCustomer Update(string customerId, StripeCustomerUpdateOptions updateOptions)
        {
            var url = string.Format("{0}/{1}", Urls.Customers, customerId);

            url = ParameterBuilder.ApplyAllParameters(updateOptions, url);

            var response = Requestor.PostString(url);

            return(PopulateStripeCustomer(response));
        }
        public virtual StripeCustomer Update(string customerId, StripeCustomerUpdateOptions updateOptions)
        {
            var url = string.Format("{0}/{1}", Urls.Customers, customerId);

            url = ParameterBuilder.ApplyAllParameters(updateOptions, url);

            var response = Requestor.PostString(url);

            return(Mapper <StripeCustomer> .MapFromJson(response));
        }
        public virtual StripeCustomer Update(string customerId, StripeCustomerUpdateOptions updateOptions, StripeRequestOptions requestOptions = null)
        {
            requestOptions = SetupRequestOptions(requestOptions);

            var url = string.Format("{0}/{1}", Urls.Customers, customerId);
            url = this.ApplyAllParameters(updateOptions, url, false);

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

            return Mapper<StripeCustomer>.MapFromJson(response);
        }
        public virtual StripeCustomer Update(string customerId, StripeCustomerUpdateOptions updateOptions, StripeRequestOptions requestOptions = null)
        {
            requestOptions = SetupRequestOptions(requestOptions);

            var url = string.Format("{0}/{1}", Urls.Customers, customerId);

            url = this.ApplyAllParameters(updateOptions, url, false);

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

            return(Mapper <StripeCustomer> .MapFromJson(response));
        }
示例#12
0
        /// <summary>
        /// Updates the customer.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="card">The card.</param>
        /// <returns></returns>
        public object UpdateCustomer(SaasEcomUser user, CreditCard card)
        {
            var customer = new StripeCustomerUpdateOptions
            {
                Email = user.Email,

                // Card Details
                SourceToken = card.StripeToken
            };

            return _customerService.Update(user.StripeCustomerId, customer);
        }
        public ActionResult ChangeDefault(string id)
        {
            User userObj = (User)Session["user"];
            var stripeCustomerID = accountRepo.Accounts.FirstOrDefault(aid => aid.ID == userObj.AccountID).StripeCustomerID;

            var customer = new StripeCustomerService();
            customer.ApiKey = "sk_test_4Xusc3Meo8gniONh6dDRZvlp";

            var customerUpdate = new StripeCustomerUpdateOptions();
            customerUpdate.DefaultCard = id;
            customer.Update(stripeCustomerID, customerUpdate);

            return RedirectToAction("Subscription", "Admin", new { id = 1 });
        }
示例#14
0
        public string UpdateCustomer(string customerId, string email, string firstName, string lastName)
        {
            string description = firstName + " " + lastName + " (" + email + ")";
            try
            {
                var customerUpdate = new StripeCustomerUpdateOptions();
                customerUpdate.Email = email;
                customerUpdate.Description = description;

                StripeCustomer customer = cusService.Update(customerId, customerUpdate);
                return customer.Id;
            }
            catch (Exception ex)
            {
                if (ex is StripeException)
                {
                    StripeException exception = (StripeException)ex;
                    StripeError err = exception.StripeError;
                    return err.ErrorType;
                }
                return null;
            }
        }
        private static StripeCustomerUpdateOptions InitializeUpdateCustomerOptions(ApplicationModel.Billing.CustomerPayment payment)
        {
            var myCustomer = new StripeCustomerUpdateOptions();

            // set these properties if using a card
            myCustomer.CardNumber = payment.CardNumber; //how is this coming in?
            myCustomer.CardExpirationYear = payment.CardExpirationYear;
            myCustomer.CardExpirationMonth = payment.CardExpirationMonth;
            myCustomer.CardAddressCountry = payment.CardAddressCountry;                // optional
            myCustomer.CardAddressLine1 = payment.CardAddressLine1;    // optional
            myCustomer.CardAddressLine2 = payment.CardAddressLine2;              // optional
            myCustomer.CardAddressCity = payment.CardAddressCity;        // optional
            myCustomer.CardAddressState = payment.CardAddressState;                  // optional
            myCustomer.CardAddressZip = payment.CardAddressZip;                 // optional
            myCustomer.CardName = payment.CardName;               // optional
            myCustomer.CardCvc = payment.CardCvc;                         // optional
            return myCustomer;
        }
示例#16
0
        /// <summary>
        /// Updates a customer record, using the given payment token
        /// NOTE: Save changes on the underlying context for the model after calling this method
        /// </summary>
        /// <param name="user"></param>
        /// <param name="paymentToken"></param>
        public static void UpdateCustomer(IStripeUser user, string paymentToken = null)
        {
            var customerUpdate = new StripeCustomerUpdateOptions() { Email = user.Email };

            // Create a token for this payment token
            customerUpdate.Card = new StripeCreditCardOptions() { TokenId = paymentToken };

            var customerService = new StripeCustomerService();
            StripeCustomer stripeCustomer = customerService.Update(user.PaymentSystemId, customerUpdate);

            System.Diagnostics.Trace.TraceInformation("Updated customer in stripe: '{0}' with id '{1}", user.Email, user.PaymentSystemId);
        }
		static private StripeCustomerUpdateOptions SetUpdateCustomer(StripeCustomer oldCustomer, CreditCardInformation creditCardInfo, string productName)
		{
			var customerUpdateOptions = new StripeCustomerUpdateOptions
								{
									Email = creditCardInfo.Email,
									CardNumber = creditCardInfo.CardNumber,
									CardExpirationMonth = creditCardInfo.ExpMonth,
									CardExpirationYear = creditCardInfo.ExpYear,
									CardCvc = creditCardInfo.CVV2,
									CardName = creditCardInfo.FirstName + " " + creditCardInfo.LastName
								};
			//if (oldCustomer.Description != oldCustomer.StripeCard.Name + " (" + oldCustomer.Email + ")" + " has purchased tubeCore")
			//    customerUpdateOptions.Description = oldCustomer.Description + " and tubeCore";
			//else
			//    customerUpdateOptions.Description = customerUpdateOptions.CardName + " (" + customerUpdateOptions.Email + ")" + " has purchased tubeCore";
			if (!Utility.IsStringEmpty(oldCustomer.Description) && oldCustomer.Description.Contains("has purchased"))
				customerUpdateOptions.Description += string.Format("{0} and {1}", oldCustomer.Description, productName);
			else
				customerUpdateOptions.Description = string.Format("{0} ({1}) has purchased {2}", customerUpdateOptions.CardName, customerUpdateOptions.Email, productName);
			return customerUpdateOptions;
		}
示例#18
0
        public UpdateCustomerResponse UpdateCustomer(UpdateCustomerRequest req)
        {
            var response = new UpdateCustomerResponse();

            try
            {
                if (req.PlanId.Length > 0)
                {
                    return UpdateSubscription(req);
                }
                else
                {
                    // Update Customer
                    var myCustomer = new StripeCustomerUpdateOptions();
                    
                    if (req.CreditCard.CardNumber.Trim().Length > 0)
                    {
                        myCustomer.CardNumber = req.CreditCard.CardNumber;
                        myCustomer.CardExpirationYear = req.CreditCard.ExpirationYear.ToString();
                        myCustomer.CardExpirationMonth = req.CreditCard.ExpirationMonth.ToString();
                        myCustomer.CardAddressCountry = "US";                 // optional
                        //myCustomer.CardAddressLine1 = "24 Beef Flank St";   // optional
                        //myCustomer.CardAddressLine2 = "Apt 24";             // optional
                        //myCustomer.CardAddressState = "NC";                 // optional
                        myCustomer.CardAddressZip = req.PostalCode; //        // optional
                        myCustomer.CardName = req.CreditCard.CardHolderName;  // optional
                        if (req.CreditCard.SecurityCode.Length > 0)
                        {
                            myCustomer.CardCvc = req.CreditCard.SecurityCode;
                        }
                    }
                                                       
                    var customerService = new StripeCustomerService();
                    StripeCustomer stripeCustomer = customerService.Update(req.CustomerId, myCustomer);

                    response.Success = true;
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return response;
        }