/// <summary>
        /// Initializes the wizard
        /// </summary>
        /// <param name="merchantId">The merchant id (DB Table RDN_Merchants)</param>
        /// <param name="currency"></param>
        /// <param name="paymentProvider"></param>
        /// <returns></returns>
        public InvoiceFactory Initalize(Guid merchantId, string currency, PaymentProvider paymentProvider, PaymentMode mode, ChargeTypeEnum chargeType)
        {
            invoice = Invoice.CreateNewInvoice();
            try
            {
                invoice.FinancialData.BasePriceForItems = 0;
                invoice.FinancialData.TotalBeforeTax = 0;
                invoice.FinancialData.ShippingCost = 0.0M;
                invoice.FinancialData.TaxRate = 0;
                invoice.FinancialData.Tax = 0;
                invoice.FinancialData.TotalIncludingTax = 0;

                invoice.ChargeType = chargeType;
                invoice.Mode = mode;
                invoice.Currency = currency;
                invoice.ShippingType = ShippingType.None;
                invoice.InvoiceId = Guid.NewGuid();
                invoice.PaymentProvider = paymentProvider;
                invoice.InvoiceStatus = InvoiceStatus.Not_Started;
                invoice.MerchantId = merchantId;

                RecalculateTotalAfterTax();
            }
            catch (Exception exception)
            {
                ErrorDatabaseManager.AddException(exception, exception.GetType());
            }
            return this;
        }
        /// <summary>
        /// Create Charge with customer
        /// </summary>
        /// <param name="creditCard"></param>
        /// <returns></returns>
        public async Task <StripeCharge> ChargeCardAsync(CreditCardModel creditCard, Citation citation, CommonAccount account, ChargeTypeEnum chargeType)
        {
            Check.NotNull(creditCard, nameof(creditCard));

            var metaData = new Dictionary <string, string>();

            metaData["Account"]        = account.Name;
            metaData["AccountNumber"]  = account.Number.ToString();
            metaData["CitationNumber"] = citation.CitationNumber.ToString();
            metaData["Type"]           = chargeType.GetDescription();
            // Token is created using Checkout or Elements!
            // Get the payment token submitted by the form:
            var token = creditCard.SourceToken; // Using ASP.NET MVC

            var options = new StripeChargeCreateOptions
            {
                Amount      = creditCard.Amount,
                Currency    = "usd",
                Description = chargeType.GetDescription(),
                SourceTokenOrExistingSourceId = token,
                Metadata = metaData
            };
            var          service = new StripeChargeService();
            StripeCharge charge  = await service.CreateAsync(options);

            return(charge);
        }
Beispiel #3
0
 public UpdateRequest ChargeType(ChargeTypeEnum chargeType)
 {
     m_params.AddOpt("charge_type", chargeType);
     return(this);
 }