public Card CreateCartdStripe(StripeCardDTO dto, string customerid)
        {
            var tokenCreate = new TokenCreateOptions
            {
                Card = new TokenCardOptions
                {
                    Number   = dto.Cardnumber,
                    ExpMonth = dto.Month,
                    ExpYear  = dto.Year,
                    Cvc      = dto.CVC,
                    Name     = dto.CardHolderName
                },
            };
            var tokenService = new TokenService();
            var token        = tokenService.Create(tokenCreate);

            var options = new CardCreateOptions
            {
                Source = token.Id
            };
            var service  = new Stripe.CardService();
            var response = service.Create(customerid, options);

            return(response);
        }
        public async Task <bool> DeleteCardFromCustomer(string customerId, string cardId)
        {
            StripeConfiguration.ApiKey = this._configuration.GetSection("Stripe")["SecretKey"];

            var service   = new Stripe.CardService();
            var cardToken = await service.DeleteAsync(customerId, cardId);

            return(cardToken.Deleted.Value);
        }
Ejemplo n.º 3
0
        public async Task <StripeList <Card> > GetCardListAsync(string customerId)
        {
            var service = new Stripe.CardService();
            var options = new Stripe.CardListOptions
            {
                Limit = 3,
            };

            return(await service.ListAsync(customerId, options));
        }
        public StripeList <Card> GetCardList(string customerid)
        {
            var service = new Stripe.CardService();
            var options = new CardListOptions
            {
                Limit = 50,
            };
            var cards = service.List(customerid, options);

            return(cards);
        }
Ejemplo n.º 5
0
        public bool CreateCreditCard(CreaditCardCreateViewModel model)
        {
            StripeConfiguration.SetApiKey(SETTING.Value.SecretStripe);


            var customerTMP = _customerRepository.Get(x => x.Deleted == false && x.Id == model.CustomerId);

            if (customerTMP.StripeId == null || customerTMP.StripeId == "")
            {
                var options = new CustomerCreateOptions
                {
                    Email       = customerTMP.Email,
                    Description = "Customer for " + customerTMP.FullName + " " + customerTMP.Email,
                    SourceToken = model.CardId
                };
                var             service  = new Stripe.CustomerService();
                Stripe.Customer customer = service.Create(options);
                customerTMP.StripeId = customer.Id;
                _customerRepository.Update(customerTMP);
                model.CardId    = customer.DefaultSourceId;
                model.Isdefault = true;
            }
            else
            {
                var optionsCard = new CardCreateOptions
                {
                    SourceToken = model.CardId
                };
                var serviceCard = new Stripe.CardService();
                var card        = serviceCard.Create(customerTMP.StripeId, optionsCard);
                model.CardId = card.Id;
            }
            model.Last4DigitsHash = encrypt(model.Last4DigitsHash);
            var creditCard = _mapper.Map <CreaditCardCreateViewModel, CreditCard>(model);

            _creditCardRepository.Add(creditCard);
            _unitOfWork.CommitChanges();
            return(true);
        }