public ChargeServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new ChargeService(this.StripeClient); this.captureOptions = new ChargeCaptureOptions { Amount = 123, }; this.createOptions = new ChargeCreateOptions { Amount = 123, Currency = "usd", Source = "tok_123", }; this.updateOptions = new ChargeUpdateOptions { FraudDetails = new ChargeFraudDetailsOptions { UserReport = "safe", }, }; this.listOptions = new ChargeListOptions { Limit = 1, }; }
public async Task <List <StripeTransaction> > GetListOfTransactions() { var transactions = new List <StripeTransaction>(); var stripeClient = new StripeClient(appSettings.ApiSecret); var options = new ChargeListOptions { Limit = 100 }; var service = new ChargeService(stripeClient); StripeList <Charge> charges = await service.ListAsync( options ); return(charges.Data.Select(c => new StripeTransaction() { Id = c.Id, Paid = c.Paid, ApplicationFeeAmount = MoneyExtender.ConvertToDollars(c.ApplicationFeeAmount != null ? c.ApplicationFeeAmount.Value : 0), Status = c.Status, Description = c.Description, PaymentType = c.Object, AmountRefunded = MoneyExtender.ConvertToDollars(c.AmountRefunded), Amount = MoneyExtender.ConvertToDollars(c.Amount), Created = c.Created, FailureCode = c.FailureCode, FailureMessage = c.FailureMessage, TotalAmount = MoneyExtender.ConvertToDollars(c.Amount) - MoneyExtender.ConvertToDollars(c.AmountRefunded) }).ToList()); }
public List <Charge> List() { //StripeConfiguration.SetApiKey(_config.GetSection("api_key").Value); var service = new ChargeService(); var optionsl = new ChargeListOptions { Limit = 100, }; var orders = service.List(optionsl); foreach (var order in orders) { var services = new ChargeService(); var options = new ChargeGetOptions(); options.AddExpand("customer"); options.AddExpand("order"); var charge = service.Get(order.Id, options); order.Created = charge.Created.Date; order.Amount = charge.Amount; order.AmountRefunded = charge.AmountRefunded; if (order.Customer != null) { if (charge.Customer.Email == "*****@*****.**") { charge.Customer.Email = ""; } } } return(orders.Data); }
public ChargeServiceTest() { this.service = new ChargeService(); this.captureOptions = new ChargeCaptureOptions { Amount = 123, }; this.createOptions = new ChargeCreateOptions { Amount = 123, Currency = "usd", SourceId = "tok_123", }; this.updateOptions = new ChargeUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, }; this.listOptions = new ChargeListOptions { Limit = 1, }; }
public ChargeServiceTest( StripeMockFixture stripeMockFixture, MockHttpClientFixture mockHttpClientFixture) : base(stripeMockFixture, mockHttpClientFixture) { this.service = new ChargeService(this.StripeClient); this.captureOptions = new ChargeCaptureOptions { Amount = 123, }; this.createOptions = new ChargeCreateOptions { Amount = 123, Currency = "usd", Source = "tok_123", }; this.updateOptions = new ChargeUpdateOptions { Metadata = new Dictionary <string, string> { { "key", "value" }, }, }; this.listOptions = new ChargeListOptions { Limit = 1, }; }
public IActionResult Get() { var options = new ChargeListOptions(); var service = new ChargeService(); var charges = service.List(options); return(View("ChargesHistory", charges.Data)); }
public virtual async Task <List <Charge> > List(ChargeListOptions options = null) { var url = Urls.Charges; url = this.ApplyAllParameters(options, url, true); var response = await Requestor.Get(url); return(Mapper <Charge> .MapCollectionFromJson(response)); }
public async Task <IEnumerable <Charge> > ListCharges() { var service = new ChargeService(); var options = new ChargeListOptions { Limit = 3, }; var charges = await service.ListAsync(options); return(charges); }
public async Task <IActionResult> GetPayments() { var options = new ChargeListOptions { Limit = 100 }; var service = new ChargeService(); StripeList <Charge> charges = await service.ListAsync( options ); return(new OkObjectResult(new { success = "true", payments = PaymentMapper.Map(charges.Data) })); }
private StripeList <Charge> GetCharges(string intent) { StripeConfiguration.ApiKey = _appKeys.StripeApiKey; var options = new ChargeListOptions { PaymentIntent = intent }; var service = new ChargeService(); StripeList <Charge> charges = service.List( options ); return(charges); }
public static StripeList <Charge> GetListCharge(Transactions transactionModel) { // Set your secret key: remember to change this to your live secret key in production // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.SetApiKey(SecretKey); var service = new ChargeService(); var options = new ChargeListOptions { Limit = 3, }; var charges = service.List(options); return(charges); }
public Year Summary() { var year = new Year(); var service = new ChargeService(); service.ExpandCustomer = false; service.ExpandOrder = true; var options = new ChargeListOptions { Limit = 100, }; var orders = service.List(options); foreach (var order in orders) { if (order.Created.Year == DateTime.Now.Year) { switch (order.Created.Month) { case 1: year.jan++; break; case 2: year.feb++; break; case 3: year.mar++; break; case 4: year.apr++; break; case 5: year.may++; break; case 6: year.jun++; break; case 7: year.jul++; break; case 8: year.aug++; break; case 9: year.sep++; break; case 10: year.oct++; break; case 11: year.nov++; break; case 12: year.dec++; break; default: Console.WriteLine("Other"); break; } year.totalOrders++; year.yearTotal += order.Amount; year.refundedTotal += order.AmountRefunded; } } year.totalCustomers = _stripeCustomerService.Count(); //ordersPerMonth = new int[]{0,12,40,50}; return(year); }
public JsonResult Stripe(string order_id, string pi_id) { try { StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; if (String.IsNullOrEmpty(pi_id)) { var options = new PaymentIntentCreateOptions { Amount = 2000, Currency = "usd", //CaptureMethod = "manual", PaymentMethodTypes = new List <string> { "card", }, PaymentMethodOptions = new PaymentIntentPaymentMethodOptionsOptions { Card = new PaymentIntentPaymentMethodOptionsCardOptions { RequestThreeDSecure = "any" } }, ReceiptEmail = "*****@*****.**" }; var service = new PaymentIntentService(); var create = service.Create(options); return(Json(new { status = "Success", response = create })); } else { /* * var service = new PaymentIntentService(); * var options = new PaymentIntentCaptureOptions * { * //ReturnUrl = "https://example.com/return_url", * }; * var intent = service.Capture(pi_id, options); * return Json(new { status = "Success", response = intent }); */ var options = new ChargeListOptions { Limit = 100, PaymentIntent = pi_id }; var service = new ChargeService(); StripeList <Charge> charges = service.List(options); return(Json(new { status = "Success", response = charges })); } } catch (StripeException se) { Response.StatusCode = (int)se.HttpStatusCode; return(Json(new { status = "Failure", code = se.HttpStatusCode, message = se.Message, data = se.Data, error = se.StripeError, response = se.StripeResponse })); } }
static async Task Main(string[] args) { Console.WriteLine("Press Enter"); Console.ReadLine(); //CulqiConfiguration.ApiKey = "pk_test_8MtrpF4Kw1pAjdYX"; CulqiConfiguration.ApiKey = "sk_test_iSCxCg7THuZB2DwG"; var tokenOptions = new TokenCreateOptions() { CardNumber = "4111111111111111", ExpirationMonth = "09", ExpirationYear = "2029", Cvv = "123", Email = "*****@*****.**" }; var tokenService = new TokenService(); //var tokens = await tokenService.Create(tokenOptions); //var tokens = await tokenService.Get("tkn_test_rk0lMDeGolf9fBa5"); var tokenUpdateOptions = new TokenUpdateOptions { Metadata = new Dictionary <string, string> { { "email", "*****@*****.**" }, { "active", "false" } } }; //var tokens = await tokenService.Update("tkn_test_rk0lMDeGolf9fBa5", tokenUpdateOptions); var tokenListOptions = new TokenListOptions { Limit = 2, Bin = 411111, CountryCode = "PE" }; //var tokens = await tokenService.List(tokenListOptions); ChargeService chargeService = new ChargeService(); var chargeCreateOptions = new ChargeCreateOptions { Amount = 100000, CurrencyCode = "PEN", Email = "*****@*****.**", SourceId = "tkn_test_o1tYygTfUzugALDq", Description = "Test Charge from .net platform" }; //chr_test_QezSVuBoRuSsrslL //var charge = await chargeService.Create(chargeCreateOptions); //var charge = await chargeService.Get("chr_test_QezSVuBoRuSsrslL"); //var charge = await chargeService.Capture("chr_test_Wmr3PB18xmwyMtOq"); var chargeListOptions = new ChargeListOptions { Limit = 3, Amount = 10000 }; //var charge = await chargeService.List(chargeListOptions); var chargeUpdateOptions = new ChargeUpdateOptions { Metadata = new Dictionary <string, string> { { "email", "*****@*****.**" }, { "dni", "77777770" } } }; var charge = await chargeService.Update("chr_test_QezSVuBoRuSsrslL", chargeUpdateOptions); Console.WriteLine(charge); Console.ReadLine(); }
public async Task <StripeList <Charge> > ListAsync(ChargeListOptions options = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default) { return(await chargeService.ListAsync(options, requestOptions, cancellationToken)); }
public Sales Sales() { var year = new Sales(); var service = new ChargeService(); service.ExpandCustomer = true; service.ExpandOrder = true; var options = new ChargeListOptions { Limit = 100, }; var orders = service.List(options); foreach (var order in orders) { if (order.Created.Year == DateTime.Now.Year) { switch (order.Created.Month) { case 1: year.jan += order.Amount; break; case 2: year.feb += order.Amount; break; case 3: year.mar += order.Amount; break; case 4: year.apr += order.Amount; break; case 5: year.may += order.Amount; break; case 6: year.jun += order.Amount; break; case 7: year.jul += order.Amount; break; case 8: year.aug += order.Amount; break; case 9: year.sep += order.Amount; break; case 10: year.oct += order.Amount; break; case 11: year.nov += order.Amount; break; case 12: year.dec += order.Amount; break; default: Console.WriteLine("Other"); break; } } order.Created = order.Created.Date; order.Amount = order.Amount; order.AmountRefunded = order.AmountRefunded; } return(year); }
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); }