Esempio n. 1
0
        public async Task <PaymentMethod> CreatePaymentMethod(string customerId, string type, string startingAfter = null)
        {
            var service  = new PaymentMethodService();
            var response = await service.CreateAsync(new PaymentMethodCreateOptions
            {
                Customer = customerId,
                Type     = type,
                Card     = new PaymentMethodCardOptions
                {
                }
            });

            return(response);
        }
 private static async Task <PaymentMethod> CreatePaymentMethodAsync(PaymentMethodService paymentMethodService)
 {
     return(await paymentMethodService
            .CreateAsync(new PaymentMethodCreateOptions()
     {
         Card = new PaymentMethodCardCreateOptions()
         {
             Number = "4242424242424242",
             Cvc = "123",
             ExpMonth = 10,
             ExpYear = 30
         },
         Type = "card"
     }));
 }
Esempio n. 3
0
        public async Task AddCreditCardAsync(string customerId, string cardholderName, string number, string cvc, long expMonth, long expYear, string zipCode)
        {
            var paymentMethodCreateOptions = new PaymentMethodCreateOptions
            {
                Type = "card",
                Card = new PaymentMethodCardOptions
                {
                    Number   = number,
                    Cvc      = cvc,
                    ExpMonth = expMonth,
                    ExpYear  = expYear
                },

                BillingDetails = new PaymentMethodBillingDetailsOptions
                {
                    Name    = cardholderName,
                    Address = new AddressOptions
                    {
                        PostalCode = zipCode
                    }
                }
            };

            var paymentMethodService = new PaymentMethodService();

            var paymentMethod = await paymentMethodService.CreateAsync(paymentMethodCreateOptions);

            var cards = await paymentMethodService.ListAsync(new PaymentMethodListOptions { Customer = customerId, Type = "card" });

            foreach (var card in cards)
            {
                await paymentMethodService.DetachAsync(card.Id);
            }

            var paymentMethodAttachOptions = new PaymentMethodAttachOptions
            {
                Customer = customerId
            };

            await paymentMethodService.AttachAsync(paymentMethod.Id, paymentMethodAttachOptions);
        }
Esempio n. 4
0
        async public Task <string> AddPaymentMethodAsync([FromBody] PaymentMethodCreateOptions paymentMethodCreateOptions)
        {
            var res = await _paymentMethodService.CreateAsync(paymentMethodCreateOptions, _requestOptions);

            return(res.Id);
        }