Exemplo n.º 1
0
        public async Task <PaymentIntent> CreatePaymentIntentAsync(string customerId, string accountId, string description, decimal amount, decimal applicationFeeAmount, string paymentMethodId)
        {
            var options = new PaymentIntentCreateOptions
            {
                Description          = description,
                Amount               = (long)(amount * 100),
                ApplicationFeeAmount = (long)(applicationFeeAmount * 100),
                TransferData         = new PaymentIntentTransferDataOptions
                {
                    Destination = accountId,
                },
                Currency           = "usd",
                PaymentMethodTypes = new List <string>
                {
                    "card"
                },
                Customer      = customerId,
                PaymentMethod = paymentMethodId,
                Confirm       = true,
                OffSession    = true
            };

            var service = new Stripe.PaymentIntentService();

            return(await service.CreateAsync(options));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            RepoDb.SqlServerBootstrap.Initialize();

            var repo = new PaymentIntentRepository();

            var data = repo.GetAll(0, 3000);

            StripeConfiguration.ApiKey = ConfigurationManager.AppSettings["Cashier:Stripe:Secret"];

            var chargeApi = new Stripe.ChargeService();
            var charges   = chargeApi.List(new ChargeListOptions
            {
                Limit = 5000
            });

            foreach (var item in data)
            {
                var paymentMethodApi = new Stripe.PaymentMethodService();
                var paymentIntentApi = new Stripe.PaymentIntentService();
                var invoiceApi       = new Stripe.InvoiceService();
                if (item.ExternalReference?.StartsWith("pi_") ?? true)
                {
                    continue;
                }

                var payment = charges.FirstOrDefault(p => p.PaymentMethod == item.ExternalReference);

                if (payment != null && !string.IsNullOrEmpty(payment.PaymentIntentId))
                {
                    item.ExternalReference = payment.PaymentIntentId;
                    repo.SavePaymentIntent(item);
                }
            }
        }
Exemplo n.º 3
0
        public async Task <PaymentIntent> GetPaymentIntentAsync(string paymentIntentId)
        {
            var service = new Stripe.PaymentIntentService();

            return(await service.GetAsync(paymentIntentId));
        }