Exemplo n.º 1
0
        static void TestCreateInvoiceItems(StripePayment payment)
        {
            StripeCustomer        cust = payment.CreateCustomer(new StripeCustomerInfo());
            StripeInvoiceItemInfo info = GetInvoiceItemInfo();

            info.CustomerID = cust.ID;
            StripeInvoiceItem     item    = payment.CreateInvoiceItem(info);
            StripeInvoiceItemInfo newInfo = GetInvoiceItemInfo();

            newInfo.Description = "Invoice item: " + Guid.NewGuid().ToString();
            StripeInvoiceItem item2 = payment.UpdateInvoiceItem(item.ID, newInfo);
            StripeInvoiceItem item3 = payment.GetInvoiceItem(item2.ID);

            if (item.Description == item3.Description)
            {
                throw new Exception("Update failed");
            }
            StripeInvoiceItem deleted = payment.DeleteInvoiceItem(item2.ID);

            if (!deleted.Deleted.HasValue && deleted.Deleted.Value)
            {
                throw new Exception("Delete failed");
            }
            var items = payment.GetInvoiceItems(10, 10, null);

            Console.WriteLine(items.Total);
            payment.DeleteCustomer(cust.ID);
        }
Exemplo n.º 2
0
        static void TestInvoices(StripePayment payment)
        {
            var                invoices = payment.GetInvoices(10, 10);
            StripeInvoice      inv      = payment.GetInvoice(invoices.Data [0].ID);
            StripeCustomer     cust     = payment.CreateCustomer(new StripeCustomerInfo());
            StripeSubscription sub      = payment.Subscribe(cust.ID, new StripeSubscriptionInfo {
                Card = GetCC()
            });
            StripeInvoice inv2 = payment.GetUpcomingInvoice(cust.ID);

            payment.Unsubscribe(cust.ID, true);
            payment.DeleteCustomer(cust.ID);
        }
        /// <summary>
        /// Create Customer
        /// </summary>
        /// <param name="payment">StripePayment</param>
        /// <param name="paymentResponse">Payment Response</param>
        /// <createdby>Sumit Saurav</createdby>
        /// <createdDate>may/22/2014</createdDate>
        /// <returns>string type Customer id.</returns>
        static string CreateCustomer(StripePayment payment, PaymentResponse paymentResponse)
        {
            StripeCustomerInfo customer = new StripeCustomerInfo()
            {
                Email       = paymentResponse.CustomerEmail,
                Description = paymentResponse.NameOnCard + "-" + paymentResponse.BusinessName,
                Card        = GetCC(paymentResponse),
            };
            StripeCustomer response    = payment.CreateCustomer(customer);
            string         customer_id = response.ID;

            return(customer_id);
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        static void TestCreateSubscription(StripePayment payment)
        {
            StripeCustomer cust = payment.CreateCustomer(new StripeCustomerInfo {
                Card = GetCC()
            });
            //StripePlan temp = new StripePlan { ID = "myplan" };
            //DeletePlan (temp, payment);
            StripePlan         plan = CreatePlan(payment);
            StripeSubscription sub  = payment.Subscribe(cust.ID, new StripeSubscriptionInfo {
                Card    = GetCC(),
                Plan    = "myplan",
                Prorate = true
            });
            StripeSubscription sub2 = payment.GetSubscription(sub.CustomerID);

            TestDeleteSubscription(cust, payment);
            DeletePlan(plan, payment);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
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);
            }
        }