private static void Main(string[] args) { var apiKey = ""; var stripe = new StripeClient(apiKey); var chargeService = new ChargeService(stripe); var chargeId = ""; var charge = chargeService.Get(chargeId); Console.WriteLine("Charge"); Console.WriteLine($"Amount: ${charge.Amount}"); var payoutService = new PayoutService(stripe); var payoutId = ""; var payout = payoutService.Get(payoutId); Console.WriteLine($"Payout: {payoutId}"); Console.WriteLine($"Date Paid: {payout.ArrivalDate.ToString()}"); var balanceTransactionService = new BalanceTransactionService(stripe); var requestOptions = new BalanceTransactionListOptions { Payout = payoutId, Limit = 100 }; var transactionList = balanceTransactionService.List(requestOptions); Console.WriteLine($"Transactions: {transactionList.Count()}"); }
public async Task <List <string> > GetPayoutTransactionsAsync(string accountId, string payoutId) { var result = new List <string>(); var balanceTransactionService = new BalanceTransactionService(); var chargeService = new Stripe.ChargeService(); var transferService = new Stripe.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); }
public BalanceTransactionServiceTest() { this.service = new BalanceTransactionService(); this.listOptions = new BalanceTransactionListOptions { Limit = 1, }; }
public BalanceTransactionServiceTest(MockHttpClientFixture mockHttpClientFixture) : base(mockHttpClientFixture) { this.service = new BalanceTransactionService(); this.listOptions = new BalanceTransactionListOptions { Limit = 1, }; }
public BalanceTransactionServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new BalanceTransactionService(this.StripeClient); this.listOptions = new BalanceTransactionListOptions { Limit = 1, }; }
public async Task <IEnumerable <BalanceTransaction> > GetBalanceHistoryFor(string VendorsSKey) { var service = new BalanceTransactionService(); var transactions = await service.ListAsync( new BalanceTransactionListOptions { Limit = 12, } ); return(transactions); // Don't know how with latest Stripe updates //var balanceService = new BalanceService(); //var opts= new RequestOptions() { ApiKey=VendorsSKey, StripeConnectAccountId=} //StripeList<BalanceTransaction> balanceTransactions = // await balanceService.GetAsync(opts, CancellationToken.None) //return balanceTransactions; }
public async Task <IActionResult> GetBalanceHistory([FromRoute] string userId) { try { StripeConfiguration.ApiKey = ServiceKey; var user = await _accountsRepository.GetByUserId(userId); var service = new BalanceTransactionService(); List <BalanceTransaction> transactions = (await service.ListAsync(new BalanceTransactionListOptions { }, new RequestOptions { StripeAccount = user.StripeUserId })).ToList(); return(Ok(transactions)); } catch (Exception e) { return(BadRequest(new MessageObj(e.Message))); } }
private StripeList <BalanceTransaction> ListBalanceTransactions() { StripeConfiguration.ApiKey = _appKeys.StripeApiKey; //DateTime dateNow = DateTime.Now; DateTime createdDate = DateTime.Now.AddDays(-30); var options = new BalanceTransactionListOptions { Created = new DateRangeOptions { GreaterThan = createdDate, }, Limit = 100 }; var service = new BalanceTransactionService(); StripeList <BalanceTransaction> balanceTransactions = service.List( options); return(balanceTransactions); }
private List <Payment> _ExportPayment(DateRangeOptions range) { var payments = new List <Payment>(); try { var options = new PaymentIntentListOptions { Limit = 100, Created = range, }; var paymentIntentService = new PaymentIntentService(); var transactionService = new BalanceTransactionService(); var customerService = new CustomerService(); var chargeService = new ChargeService(); StripeList <PaymentIntent> pis = paymentIntentService.List(options); for (int i = 0; i < pis.Data.Count; i++) { var pi = pis.Data[i]; var payment = new Payment() { Description = pi.Description, Created = pi.Created, Amount = Convert.ToDecimal(pi.Amount) / 100, Currency = pi.Currency, Status = pi.Status, StatementDescriptor = pi.StatementDescriptor, CustomerId = pi.CustomerId, CardId = pi.PaymentMethodId, InvoiceId = pi.InvoiceId }; if (pi.Charges.Data.Count > 0) { var charge = pi.Charges.Data[0]; try { charge.BalanceTransaction = transactionService.Get(charge.BalanceTransactionId); payment.Id = charge.Id; payment.ConvertedAmount = Convert.ToDecimal(charge.BalanceTransaction.Amount) / 100; payment.AmountRefunded = Convert.ToDecimal(charge.AmountRefunded) / 100; payment.Fee = Convert.ToDecimal(charge.BalanceTransaction.Fee) / 100; payment.ConvertedCurrency = charge.BalanceTransaction.Currency; payment.Tax = 0; payment.Captured = charge.Captured; payment.Transfer = charge.TransferId; try { if (charge.Refunds.Data.Count > 0) { var refundTx = transactionService.Get(charge.Refunds.Data[0].BalanceTransactionId); payment.ConvertedAmountRefunded = Convert.ToDecimal(refundTx.Amount) / 100; } } catch (Exception) { } } catch (Exception) { } } try { pi.Customer = customerService.Get(pi.CustomerId); payment.CustomerDescription = pi.Customer.Description; payment.CustomerEmail = pi.Customer.Email; } catch (Exception) { } payment.Description = pi.Description; payments.Add(payment); } var optionsC = new ChargeListOptions { Limit = 100, Created = range, }; StripeList <Charge> chs = chargeService.List(optionsC); for (int i = 0; i < chs.Data.Count; i++) { var ch = chs.Data[i]; if (FindPayment(payments, ch.Id)) { continue; } var payment = new Payment() { Id = ch.Id, Description = ch.Description, Created = ch.Created, Amount = Convert.ToDecimal(ch.Amount) / 100, Currency = ch.Currency, Status = ch.Status, StatementDescriptor = ch.StatementDescriptor, CustomerId = ch.CustomerId, Captured = ch.Captured, CardId = ch.PaymentMethod, InvoiceId = ch.InvoiceId, Transfer = ch.TransferId }; try { ch.BalanceTransaction = transactionService.Get(ch.BalanceTransactionId); payment.ConvertedAmount = Convert.ToDecimal(ch.BalanceTransaction.Amount) / 100; payment.AmountRefunded = Convert.ToDecimal(ch.AmountRefunded) / 100; payment.Fee = Convert.ToDecimal(ch.BalanceTransaction.Fee) / 100; payment.ConvertedCurrency = ch.BalanceTransaction.Currency; payment.Tax = 0; } catch (Exception) { } try { ch.Customer = customerService.Get(ch.CustomerId); payment.CustomerDescription = ch.Customer.Description; payment.CustomerEmail = ch.Customer.Email; } catch (Exception) { } payments.Add(payment); } } catch (Exception) { } payments.Sort( delegate(Payment a, Payment b) { return(b.Created.CompareTo(a.Created)); } ); return(payments); }