示例#1
0
        public GetProfileResponse GetProfile(GetProfileRequest getProfileRequest)
        {
            SetupIntent setupIntent = _adaptee.GetProfile(getProfileRequest.Token);

            return(new GetProfileResponse()
            {
                PaymentMethod = setupIntent.PaymentMethodId
            });
        }
示例#2
0
        public CreateNewCardResponse CreateNewCard(CreateNewCardRequest createNewCardRequest)
        {
            SetupIntent setupIntent = _adaptee.CreateNewCard(createNewCardRequest.CustomerId, createNewCardRequest.UserId);

            return(new CreateNewCardResponse()
            {
                SetupIntentId = setupIntent.Id,
                ClientSecret = setupIntent.ClientSecret
            });
        }
        public async Task <string> CreateClientSecretAsync()
        {
            var options = new SetupIntentCreateOptions {
                PaymentMethodTypes = new List <string> {
                    "card"
                }
            };

            var         service = new SetupIntentService();
            SetupIntent intent  = await service.CreateAsync(options);

            return(intent.ClientSecret);
        }
示例#4
0
        public static SetupIntentDao ToSetupIntentDao(this SetupIntent setupIntent)
        {
            if (setupIntent == null)
            {
                return(null);
            }

            return(new SetupIntentDao
            {
                Id = setupIntent.Id,
                CustomerId = setupIntent.CustomerId,
                ClientSecret = setupIntent.ClientSecret,
            });
        }
示例#5
0
        public ActionResult AddCardToCustomer(SetupIntent intent)
        {
            User user = SessionManager.GetUserSession();

            if (string.IsNullOrEmpty(user.StripeCustomerID))
            {
                _stripeService.stripe_CreateCustomer(user);
            }
            else
            {
                _stripeService.AddCardToExistingCustomer(intent, user.StripeCustomerID);
            }
            return(View());
        }
示例#6
0
        public bool AddCardToExistingCustomer(SetupIntent intent, string StripeCustomerID)
        {
            bool result = true;

            try
            {
                var options = new PaymentMethodAttachOptions
                {
                    Customer = StripeCustomerID,
                };
                var service       = new PaymentMethodService();
                var paymentMethod = service.Attach(intent.PaymentMethodId, options);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                result = false;
            }

            return(result);
        }