Esempio n. 1
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);
 }
Esempio n. 2
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);
    }