예제 #1
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);
 }
예제 #2
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);
 }
예제 #3
0
        private static void TestInvoices2(StripePayment payment)
        {
            StripeCustomer cust = payment.GetCustomer("cus_ulcOcy5Seu2dpq");
            StripePlanInfo planInfo = new StripePlanInfo
                {
                    Amount = 1999,
                    Id = "testplan",
                    Interval = StripePlanInterval.month,
                    Name = "The Test Plan",
                    //TrialPeriod = 7
                };
            //payment.DeletePlan (planInfo.Id);
            StripePlan plan = payment.CreatePlan(planInfo);
            StripeSubscriptionInfo subInfo = new StripeSubscriptionInfo
                { Card = GetCC(), Plan = planInfo.Id, Prorate = true };
            StripeSubscription sub = payment.Subscribe(cust.Id, subInfo);
            payment.CreateInvoiceItem(
                new StripeInvoiceItemInfo { CustomerId = cust.Id, Amount = 1337, Description = "Test single charge" });

            int total;
            List<StripeInvoice> invoices = payment.GetInvoices(0, 10, cust.Id, out total);
            StripeInvoice upcoming = payment.GetUpcomingInvoice(cust.Id);
            payment.Unsubscribe(cust.Id, true);
            payment.DeletePlan(planInfo.Id);
            foreach (StripeInvoiceLineItem line in upcoming)
            {
                Console.WriteLine("{0} for type {1}", line.Amount, line.GetType());
            }
        }
예제 #4
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);
    }