/// <summary>
        /// Decision Point Registration Charge
        /// </summary>
        /// <param name="payment">StripePayment</param>
        /// <param name="paymentResponse">PaymentResponse</param>
        /// <createdby>Sumit Saurav</createdby>
        /// <createdDate>may/22/2014</createdDate>
        /// <returns>string type result.</returns>
        public static string DecisionPointRegistrationCharge(StripePayment payment, PaymentResponse paymentResponse)
        {
            RecurringPaymentResponseParam objRecurring            = null;
            DecisionPointRepository       decisionPointRepository = null;

            #region Create Customer

            //create customer and set annual plan.
            string AnnualCustomerId = CreateCustomer(payment, paymentResponse);

            //save customer details in the database
            objRecurring = new RecurringPaymentResponseParam()
            {
                UserId     = paymentResponse.UserId,
                CustomerId = AnnualCustomerId,
                Amount     = Convert.ToInt32(paymentResponse.CompanyFee),
                Remark     = "Annual and Monthly Plans",
                Type       = "insert"
            };
            decisionPointRepository = new DecisionPointRepository();
            decisionPointRepository.MakeRecurringPayment(objRecurring);
            #endregion


            #region Make Registration payment
            //get credit card details
            StripeCreditCardInfo cc = GetCC(paymentResponse);
            //make first time payment.
            StripeCharge charge      = payment.Charge(Convert.ToInt32(paymentResponse.Amount), "usd", cc, paymentResponse.TransactionType);
            string       charge_id   = charge.ID;
            StripeCharge charge_info = payment.GetCharge(charge_id);
            #endregion

            return(charge_id);
        }
Exemple #2
0
        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"
            });

            var           invoices = payment.GetInvoices(0, 10, cust.ID);
            StripeInvoice upcoming = payment.GetUpcomingInvoice(cust.ID);

            payment.Unsubscribe(cust.ID, true);
            payment.DeletePlan(planInfo.ID);
            foreach (StripeLineItem line in upcoming)
            {
                Console.WriteLine("{0} for type {1}", line.Amount, line.GetType());
            }
        }
Exemple #3
0
        static void TestCreatePlanGetPlan(StripePayment payment)
        {
            StripePlan plan  = CreatePlan(payment);
            var        plans = payment.GetPlans(10, 10);

            Console.WriteLine(plans.Total);
        }
Exemple #4
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);
        }
Exemple #5
0
        /// <summary>
        /// Process a payment
        /// </summary>
        /// <param name="processPaymentRequest">Payment info required for an order processing</param>
        /// <returns>Process payment result</returns>
        public ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
        {
            var result = new ProcessPaymentResult();

            var customer = _customerService.GetCustomerById(processPaymentRequest.CustomerId);
            //var orderTotal = Math.Round(processPaymentRequest.OrderTotal, 2);

            StripeCreditCardInfo cc = new StripeCreditCardInfo();

            cc.CVC      = processPaymentRequest.CreditCardCvv2;
            cc.FullName = customer.BillingAddress.FirstName + " " + customer.BillingAddress.LastName;

            cc.Number          = processPaymentRequest.CreditCardNumber;
            cc.ExpirationMonth = processPaymentRequest.CreditCardExpireMonth;
            cc.ExpirationYear  = processPaymentRequest.CreditCardExpireYear;
            cc.AddressLine1    = customer.BillingAddress.Address1;
            cc.AddressLine2    = customer.BillingAddress.Address2;
            if (customer.BillingAddress.Country.TwoLetterIsoCode.ToLower() == "us")
            {
                cc.StateOrProvince = customer.BillingAddress.StateProvince.Abbreviation;
            }
            else
            {
                cc.StateOrProvince = "ot";
            }

            cc.ZipCode = customer.BillingAddress.ZipPostalCode;

            cc.Country = customer.BillingAddress.Country.TwoLetterIsoCode;

            StripePayment payment = new StripePayment(_stripePaymentSettings.TransactionKey);

            try
            {
                StripeCharge charge = payment.Charge((int)(processPaymentRequest.OrderTotal * 100),
                                                     _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode.ToLower(),
                                                     cc, string.Format("charge for {0} - {1}",
                                                                       cc.FullName, processPaymentRequest.PurchaseOrderNumber));

                if (charge != null)
                {
                    result.NewPaymentStatus               = PaymentStatus.Paid;
                    _stripePaymentSettings.TransactMode   = TransactMode.AuthorizeAndCapture;
                    result.AuthorizationTransactionId     = charge.ID;
                    result.AuthorizationTransactionResult = StripeChargeStatus.SUCCESS;
                    //need this for refund
                    result.AuthorizationTransactionCode = _stripePaymentSettings.TransactionKey;
                }
            }
            catch (StripeException stripeException)
            {
                result.AuthorizationTransactionResult = stripeException.StripeError.Message;
                result.AuthorizationTransactionCode   = stripeException.StripeError.Code;
                result.AuthorizationTransactionId     = "-1";
                result.AddError(string.Format("Declined ({0}: {1} - {2})", result.AuthorizationTransactionCode,
                                              result.AuthorizationTransactionResult, _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode));
            }

            return(result);
        }
Exemple #6
0
        static void TestCreatePlanGetPlan(StripePayment payment)
        {
            StripePlan        plan = CreatePlan(payment);
            int               total;
            List <StripePlan> plans = payment.GetPlans(10, 10, out total);

            Console.WriteLine(total);
        }
Exemple #7
0
        static StripePlan CreatePlan(StripePayment payment)
        {
            StripePlan plan  = payment.CreatePlan(GetPlanInfo());
            StripePlan plan2 = payment.GetPlan(plan.ID);

            //DeletePlan (plan2, payment);
            return(plan2);
        }
        /// <summary>
        /// Annual Monthly Payment Charge deduction method
        /// </summary>
        /// <param name="payment">StripePayment</param>
        /// <param name="paymentResponse"><RecurringPaymentResponseParam/param>
        ///  <createdby>Sumit Saurav</createdby>
        /// <createdDate>may/22/2014</createdDate>
        /// <returns>string result</returns>
        public static string AnnualMonthlyPaymentCharge(StripePayment payment, RecurringPaymentResponseParam paymentResponse)
        {
            StripeCharge charge      = payment.Charge(Convert.ToInt32(paymentResponse.Amount), "usd", paymentResponse.CustomerId, paymentResponse.Remark);
            string       charge_id   = charge.ID;
            StripeCharge charge_info = payment.GetCharge(charge_id);
            string       result      = string.Empty;

            return(result);
        }
Exemple #9
0
        static void TestPartialRefund(StripePayment payment)
        {
            StripeCreditCardInfo cc     = GetCC();
            StripeCharge         charge = payment.Charge(5001, "usd", cc, "Test partial refund");

            Console.WriteLine(charge.ID);
            StripeCharge refund = payment.Refund(charge.ID, 2499);

            Console.WriteLine(refund.Amount);
        }
Exemple #10
0
        //IF THE DAILY SUBSCRIPTION RENEWAL DOESN'T CATCH YOUR EXPIRED SUBSCRIPTION, THIS ONE WILL
        //WILL CHARGE AND RENEW CURRENT LOGGED IN USER'S EXPIRED SUBSCRIPTION UPON REACHING ANY MEMBER PAGE
        private void RenewSubscriptionById(int userBaseId)
        {
            StripePayment        cust  = _userService.GetExpiredSubscriptionById(userBaseId);
            StripePaymentRequest model = new StripePaymentRequest();

            model.AmountInPennies = cust.AmountInPennies;
            model.Customer        = cust.Customer;
            model.Email           = cust.Email;
            model.UserBaseId      = cust.UserBaseId;
            Charge(model);
        }
Exemple #11
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);
        }
Exemple #13
0
        static void TestSimpleCharge(StripePayment payment)
        {
            StripeCreditCardInfo cc     = GetCC();
            StripeCharge         charge = payment.Charge(5001, "usd", cc, "Test charge");

            Console.WriteLine(charge);
            string       charge_id   = charge.ID;
            StripeCharge charge_info = payment.GetCharge(charge_id);

            Console.WriteLine(charge_info);

            StripeCharge refund = payment.Refund(charge_info.ID);

            Console.WriteLine(refund.Created);
        }
Exemple #14
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);
            }
        }
        public async Task <IActionResult> StripePayment([FromBody] StripePayment paymentRequest)
        {
            StripeConfiguration.ApiKey = _config.GetValue <string>("Stripe:Accesskey");
            var myCharge = new ChargeCreateOptions();

            myCharge.Source             = "tok_mastercard";
            myCharge.Amount             = paymentRequest.Amount;
            myCharge.Currency           = "cad";
            myCharge.Description        = paymentRequest.ProductName;
            myCharge.Metadata           = new Dictionary <string, string>();
            myCharge.Metadata["OurRef"] = "OurRef-" + Guid.NewGuid().ToString();

            var    chargeService = new ChargeService();
            Charge stripeCharge  = chargeService.Create(myCharge);

            return(Ok(stripeCharge));
        }
Exemple #16
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);
        }
Exemple #17
0
        static void Main(string [] args)
        {
            StripePayment payment = new StripePayment("vtUQeOtUnYr7PGCLQ96Ul4zqpDUO4sOE");

            TestSimpleCharge(payment);
            //TestPartialRefund (payment);
            //TestCustomer (payment);
            TestCustomerAndCharge(payment);
            //TestGetCharges (payment);
            TestGetCustomers(payment);
            //TestCreateGetToken (payment);
            //TestCreatePlanGetPlan (payment);
            //TestCreateSubscription (payment);
            //TestCreateInvoiceItems (payment);
            //TestInvoices (payment);
            //TestInvoices2 (payment);
            TestDeserializePastDue();
        }
Exemple #18
0
        public void Charge(RequestPayment requestPayment, StripePayment stripe)
        {
            // Set your secret key: remember to change this to your live secret key in production
            // See your keys here: https://dashboard.stripe.com/account/apikeys
            StripeConfiguration.ApiKey = "sk_test_lomdOfxbm7QDgZWvR82UhV6D";

            // Token is created using Checkout or Elements!
            // Get the payment token submitted by the form:
            var token = requestPayment.StripeToken;

            var options = new ChargeCreateOptions {
                Amount      = stripe.Amount,
                Currency    = stripe.Currency,
                Description = stripe.Description,
                Source      = token,
            };
            var    service = new ChargeService();
            Charge charge  = service.Create(options);
        }
        /// <summary>
        /// Annual Monthly Payment Charge deduction method
        /// </summary>
        /// <param name="payment">StripePayment</param>
        /// <param name="paymentResponse"><RecurringPaymentResponseParam/param>
        ///  <createdby>Sumit Saurav</createdby>
        /// <createdDate>july/19/2014</createdDate>
        /// <returns>string result</returns>
        public static int AnnualMonthlyPaymentFailCharge(StripePayment payment, RecurringPaymentResponseParam paymentResponse)
        {
            RecurringPaymentResponseParam objRecurring            = null;
            DecisionPointRepository       decisionPointRepository = null;
            StripeCharge charge      = payment.Charge(Convert.ToInt32(paymentResponse.Amount), "usd", paymentResponse.CustomerId, paymentResponse.Remark);
            string       charge_id   = charge.ID;
            StripeCharge charge_info = payment.GetCharge(charge_id);

            //save customer details in the database
            objRecurring = new RecurringPaymentResponseParam()
            {
                UserId     = paymentResponse.UserId,
                CustomerId = paymentResponse.CustomerId,
                Amount     = Convert.ToInt32(paymentResponse.Amount),
                Remark     = paymentResponse.Remark,
                ChargeId   = charge_id,
            };
            decisionPointRepository = new DecisionPointRepository();
            return(decisionPointRepository.MakeRecurringPaymentTransaction(objRecurring));
        }
Exemple #20
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);
        }
        public async Task <ActionResult> Charge([FromForm] string stripeToken, [FromForm] string email, [FromForm] int orderId, [FromForm] string description, [FromForm] int amount, string currency = "usd")
        {
            var service = new StripePayment
            {
                OrderId     = orderId,
                StripeToken = stripeToken,
                Amount      = amount,
                Description = description,
                Currency    = currency
            };

            var payment = new RequestPayment
            {
                Email       = email,
                OrderId     = orderId,
                StripeToken = stripeToken
            };

            _services.Charge(payment, service);

            return(Ok());
        }
Exemple #22
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 static int UpdateCustomerDetails(StripePayment payment, PaymentResponse paymentResponse)
        {
            RecurringPaymentResponseParam objRecurring            = null;
            DecisionPointRepository       decisionPointRepository = null;

            #region Create Customer

            //create customer and set annual plan.
            string AnnualCustomerId = CreateCustomer(payment, paymentResponse);

            //save customer details in the database
            objRecurring = new RecurringPaymentResponseParam()
            {
                UserId     = paymentResponse.UserId,
                CustomerId = AnnualCustomerId,
                Amount     = Convert.ToInt32(paymentResponse.CompanyFee),
                Remark     = "Annual and Monthly Plans",
                Type       = "update"
            };
            decisionPointRepository = new DecisionPointRepository();
            return(decisionPointRepository.MakeRecurringPayment(objRecurring));

            #endregion
        }
Exemple #24
0
        static void TestGetCharges(StripePayment payment)
        {
            List <StripeCharge> charges = payment.GetCharges(0, 10);

            Console.WriteLine(charges.Count);
        }
Exemple #25
0
        static void TestGetCustomers(StripePayment payment)
        {
            List <StripeCustomer> customers = payment.GetCustomers(0, 10);

            Console.WriteLine(customers.Count);
        }
Exemple #26
0
        static void TestGetCharges(StripePayment payment)
        {
            var charges = payment.GetCharges(0, 10);

            Console.WriteLine(charges.Data.Count);
        }
Exemple #27
0
        static StripeSubscription TestDeleteSubscription(StripeCustomer customer, StripePayment payment)
        {
            StripeSubscription sub = payment.Unsubscribe(customer.ID, true);

            return(sub);
        }
Exemple #28
0
        static void TestGetCustomers(StripePayment payment)
        {
            var customers = payment.GetCustomers(0, 10);

            Console.WriteLine(customers.Data.Count);
        }
Exemple #29
0
        static StripePlan DeletePlan(StripePlan plan, StripePayment payment)
        {
            StripePlan deleted = payment.DeletePlan(plan.ID);

            return(deleted);
        }
Exemple #30
0
 static void TestCreateGetToken(StripePayment payment)
 {
     StripeCreditCardToken tok  = payment.CreateToken(GetCC());
     StripeCreditCardToken tok2 = payment.GetToken(tok.ID);
 }