public StripeCustomer CreateCustomer(StripeCustomerInfo customer)
        {
            if (customer == null)
                throw new ArgumentNullException ("customer");

            return CreateOrUpdateCustomer (null, customer);
        }
Esempio n. 2
0
        public StripeCustomer CreateCustomer(StripeCustomerInfo customer)
        {
            if (customer == null)
            {
                throw new ArgumentNullException("customer");
            }

            return(CreateOrUpdateCustomer(null, customer));
        }
Esempio n. 3
0
 static void TestCustomer(StripePayment payment)
 {
     StripeCustomerInfo customer = new StripeCustomerInfo ();
     //customer.Card = GetCC ();
     StripeCustomer customer_resp = payment.CreateCustomer (customer);
     string customer_id = customer_resp.ID;
     StripeCustomer customer_info = payment.GetCustomer (customer_id);
     Console.WriteLine (customer_info);
     StripeCustomer ci2 = payment.DeleteCustomer (customer_id);
     if (ci2.Deleted == false)
         throw new Exception ("Failed to delete " + customer_id);
 }
Esempio n. 4
0
        public StripeCustomer UpdateCustomer(string id, StripeCustomerInfo customer)
        {
            if (String.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("id");
            }
            if (customer == null)
            {
                throw new ArgumentNullException("customer");
            }

            return(CreateOrUpdateCustomer(id, customer));
        }
Esempio n. 5
0
        StripeCustomer CreateOrUpdateCustomer(string id, StripeCustomerInfo customer)
        {
            StringBuilder str = UrlEncode(customer);

            string format = "{0}/customers"; // Create

            if (id != null)
            {
                format = "{0}/customers/{1}"; // Update
            }
            string ep = String.Format(format, api_endpoint, HttpUtility.UrlEncode(id));

            return(DoRequest <StripeCustomer> (ep, "POST", str.ToString()));
        }
Esempio n. 6
0
 static void TestCustomerAndCharge(StripePayment payment)
 {
     StripeCustomerInfo customer = new StripeCustomerInfo ();
     //customer.Card = GetCC ();
     StripeCustomer response = payment.CreateCustomer (customer);
     string customer_id = response.ID;
     StripeCustomer customer_info = payment.GetCustomer (customer_id);
     Console.WriteLine (customer_info);
     StripeCustomerInfo info_update = new StripeCustomerInfo ();
     info_update.Card = GetCC ();
     StripeCustomer update_resp = payment.UpdateCustomer (customer_id, info_update);
     Console.Write ("Customer updated with CC. Press ENTER to continue...");
     Console.Out.Flush ();
     Console.ReadLine ();
     StripeCustomer ci2 = payment.DeleteCustomer (customer_id);
     if (ci2.Deleted == false)
         throw new Exception ("Failed to delete " + customer_id);
 }
 public string ProcessPayment(string FirstName, string LastName, string EmailAddress, string CardNumber, string ExpMonth, string ExpYear, string Cvv)
 {
     StripePayment payment = new StripePayment("OxGcTunKYwFuBr6JPDpX1mehWlXHIJ7k");
     StripeCustomerInfo customer = new StripeCustomerInfo
                                       {
                                           Email = EmailAddress,
                                           Card =
                                               new StripeCreditCardInfo
                                                   {
                                                       Number = CardNumber,
                                                       ExpirationMonth = Convert.ToInt32(ExpMonth),
                                                       ExpirationYear = Convert.ToInt32(ExpYear),
                                                       FullName = FirstName + " " + LastName
                                                   }
                                       };
     StripeCustomer response = payment.CreateCustomer(customer);
     string customerId = response.ID;
     return payment.Charge(2500, "usd", customerId, "QuadAutomotive Group Application Fee").ID;            
 }
Esempio n. 8
0
        StripeCustomer CreateOrUpdateCustomer(string id, StripeCustomerInfo customer)
        {
            StringBuilder str = UrlEncode (customer);

            string format = "{0}/customers"; // Create
            if (id != null)
                format = "{0}/customers/{1}"; // Update
            string ep = String.Format (format, api_endpoint, HttpUtility.UrlEncode (id));
            string json = DoRequest (ep, "POST", str.ToString ());
            return JsonConvert.DeserializeObject<StripeCustomer> (json);
        }
Esempio n. 9
0
        public StripeCustomer UpdateCustomer(string id, StripeCustomerInfo customer)
        {
            if (String.IsNullOrEmpty (id))
                throw new ArgumentNullException ("id");
            if (customer == null)
                throw new ArgumentNullException ("customer");

            return CreateOrUpdateCustomer (id, customer);
        }
Esempio n. 10
0
    private void TestStripePayment()
    {
        string stripeApiKey = Util.GetAppSetting(Constants.AppSettingKeys.StripeApiKey);
        StripePayment payment = new StripePayment(stripeApiKey);

        StripeCreditCardInfo cc = new StripeCreditCardInfo();
        cc.CVC = "1234";
        cc.ExpirationMonth = 6;
        cc.ExpirationYear = 2013;
        cc.Number = "4242424242424242";

        StripeCustomerInfo customerInfo = new StripeCustomerInfo();
        customerInfo.Card = cc;
        customerInfo.Description = "Test User";
        customerInfo.Email = UserSession.Current.Email;
        customerInfo.Validate = false;

        try
        {
            StripeCustomer customer = payment.CreateCustomer(customerInfo);

            int userID = UserSession.Current.UserID;

            StripeUser stripeUser = new StripeUser()
            {
                UserID = userID,
                StripeCustomerID = customer.ID,
                LiveMode = customer.LiveMode,
                Description = customer.Description,
                DateCreated = DateTime.UtcNow
            };

            int stripeUserID = StripeUserService.AddStripeUser(stripeUser);

            StripeCustomer customerFromPayment = payment.GetCustomer(customer.ID);

            customerInfo.Description = "Other Description";
            StripeCustomer updatedCustomer = payment.UpdateCustomer(customerFromPayment.ID, customerInfo);

            StripeCharge charge = payment.Charge(5001, "usd", customer.ID, "Another Test Charge");

            List<StripeUser> stripeUsers = StripeUserService.GetStripeUsers(userID, customer.ID);

        }
        catch (Exception ex)
        {
            string error = "Error Processing Request";
            LoggingFactory.GetLogger().LogError(error, ex);
        }

        //StripeCharge charge = payment.Charge(5001, "usd", cc, "Test charge");
        //string charge_id = charge.ID;
        //StripeCharge charge_info = payment.GetCharge(charge_id);
        //StripeCharge refund = payment.Refund(charge_info.ID);
    }
Esempio n. 11
0
        public void CustomerAndCharge()
        {
            StripeCustomerInfo customer = new StripeCustomerInfo();
            //customer.Card = GetCC ();
            StripeCustomer response = _payment.CreateCustomer(customer);
            string customer_id = response.Id;
            StripeCustomer customer_info = _payment.GetCustomer(customer_id);
            Console.WriteLine(customer_info);
            StripeCustomerInfo info_update = new StripeCustomerInfo();
            info_update.Card = GetValidCreditCard();
            StripeCustomer update_resp = _payment.UpdateCustomer(customer_id, info_update);
            Console.Write("Customer updated with CC. Press ENTER to continue...");
            Console.Out.Flush();
            Console.ReadLine();
            StripeCustomer ci2 = _payment.DeleteCustomer(customer_id);

            //if (ci2.Deleted == false) throw new Exception("Failed to delete " + customer_id);
            Assert.IsTrue(ci2.Deleted, "Failed to delete " + customer_id);
        }
Esempio n. 12
0
        public void Customer()
        {
            StripeCustomerInfo customer = new StripeCustomerInfo();
            //customer.Card = GetCC ();
            StripeCustomer customer_resp = _payment.CreateCustomer(customer);
            string customer_id = customer_resp.Id;
            StripeCustomer customer_info = _payment.GetCustomer(customer_id);
            Console.WriteLine(customer_info);
            StripeCustomer ci2 = _payment.DeleteCustomer(customer_id);

            //if (ci2.Deleted == false) throw new Exception("Failed to delete " + customer_id);
            Assert.IsTrue(ci2.Deleted, "Failed to delete " + customer_id);
        }