Exemple #1
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);
        }
        /// <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);
        }
        /// <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 #4
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 #5
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);
        }
        /// <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 #7
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);
        }