Exemplo n.º 1
0
        public async Task <List <string> > GetPayoutTransactionsAsync(string accountId, string payoutId)
        {
            var result = new List <string>();

            var balanceTransactionService = new BalanceTransactionService();
            var chargeService             = new ChargeService();
            var transferService           = new TransferService();

            var requestOptions = new RequestOptions {
                StripeAccount = accountId
            };

            var transactions = await balanceTransactionService.ListAsync(new BalanceTransactionListOptions { Payout = payoutId, Type = "payment", Limit = 100 }, requestOptions);

            foreach (var transaction in transactions)
            {
                var payment = await chargeService.GetAsync(transaction.SourceId, null, requestOptions);

                var transfer = await transferService.GetAsync(payment.SourceTransferId);

                result.Add(transfer.SourceTransactionId);
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get details of a charge
        /// </summary>
        /// <param name="ChargeId"></param>
        /// <returns></returns>
        public async Task <Charge> RetrieveChargeAsync(string ChargeId)
        {
            StripeConfiguration.SetApiKey(options.ApiKey);

            var service = new ChargeService();

            return(await service.GetAsync(ChargeId));
        }
        public override async Task <ApiResult> FetchPaymentStatusAsync(PaymentProviderContext <StripeCheckoutSettings> ctx)
        {
            try
            {
                var secretKey = ctx.Settings.TestMode ? ctx.Settings.TestSecretKey : ctx.Settings.LiveSecretKey;

                ConfigureStripe(secretKey);

                // See if we have a payment intent to work from
                var paymentIntentId = ctx.Order.Properties["stripePaymentIntentId"];
                if (!string.IsNullOrWhiteSpace(paymentIntentId))
                {
                    var paymentIntentService = new PaymentIntentService();
                    var paymentIntent        = await paymentIntentService.GetAsync(paymentIntentId, new PaymentIntentGetOptions
                    {
                        Expand = new List <string>(new[] {
                            "review"
                        })
                    });

                    return(new ApiResult()
                    {
                        TransactionInfo = new TransactionInfoUpdate()
                        {
                            TransactionId = GetTransactionId(paymentIntent),
                            PaymentStatus = GetPaymentStatus(paymentIntent)
                        }
                    });
                }

                // No payment intent, so look for a charge
                var chargeId = ctx.Order.Properties["stripeChargeId"];
                if (!string.IsNullOrWhiteSpace(chargeId))
                {
                    var chargeService = new ChargeService();
                    var charge        = await chargeService.GetAsync(chargeId);

                    return(new ApiResult()
                    {
                        TransactionInfo = new TransactionInfoUpdate()
                        {
                            TransactionId = GetTransactionId(charge),
                            PaymentStatus = GetPaymentStatus(charge)
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Stripe - FetchPaymentStatus");
            }

            return(ApiResult.Empty);
        }
Exemplo n.º 4
0
 private async Task<Charge> GetChargeAsync(Stripe.Event parsedEvent, bool fresh = false)
 {
     if(!(parsedEvent.Data.Object is Charge eventCharge))
     {
         throw new Exception("Charge is null (from parsed event). " + parsedEvent.Id);
     }
     if(!fresh)
     {
         return eventCharge;
     }
     var chargeService = new ChargeService();
     var charge = await chargeService.GetAsync(eventCharge.Id);
     if(charge == null)
     {
         throw new Exception("Charge is null. " + eventCharge.Id);
     }
     return charge;
 }
Exemplo n.º 5
0
 public async Task <Charge> GetAsync(string chargeId, ChargeGetOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default)
 {
     return(await chargeService.GetAsync(chargeId, options, requestOptions, cancellationToken));
 }
Exemplo n.º 6
0
        public async Task <string> GetStatusAsync(string chargeId)
        {
            var service = new ChargeService();

            return((await service.GetAsync(chargeId)).Status);
        }