// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } StripeConfiguration.SetApiKey(Configuration.GetSection("Stripe")["SecretKey"]); dbInitializer.Initialize(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseSession(); app.UseAuthentication(); app.UseRouting(); //app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{area=Customer}/{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app) { if (_env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); app.UseHttpsRedirection(); } StripeConfiguration.SetApiKey(_config.GetSection("Stripe")["SecretKey"]); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseSession(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{acion=Index}/{id?}"); }); // Set up custom content types -associating file extension to MIME type var provider = new FileExtensionContentTypeProvider(); app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, TrialData trialData) { StripeConfiguration.SetApiKey(Configuration.GetSection("Stripe:SecretKey").Value); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(BuilderExtensions => { BuilderExtensions.Run(async context => { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; var error = context.Features.Get <IExceptionHandlerFeature>(); if (error != null) { context.Response.AddApplicationError(error.Error.Message); await context.Response.WriteAsync(error.Error.Message); } }); }); // app.UseHsts(); } // app.UseHttpsRedirection(); trialData.TrialUsers(); app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials()); // app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseSignalR(routes => { routes.MapHub <ChatHub>("/chat"); }); app.UseAuthentication(); app.UseMvc(); }
public static Charge RequestCharge(Transactions transactionModel, decimal payAmount, string description, bool isCapture = true) { // 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); // Create a Customer: var customerOptions = new CustomerCreateOptions { SourceToken = transactionModel.PaymentCardToken, //Email = "*****@*****.**", }; var customerService = new Stripe.CustomerService(); Stripe.Customer customer = customerService.Create(customerOptions); string PaidAmountString = ConvertDecimalAmountToZeroDecimal(payAmount); var options = new ChargeCreateOptions { Amount = Convert.ToInt64(PaidAmountString), Currency = transactionModel.Currency, //SourceId = transactionModel.PaymentCardToken, Description = description, //ReceiptEmail = "*****@*****.**", CustomerId = customer.Id, Capture = isCapture, Metadata = new Dictionary <string, string>() { { "order_id", transactionModel.OrderId }, } }; var service = new ChargeService(); Charge charge = service.Create(options); return(charge); }
public bool MakePayment() { try { StripeConfiguration.SetApiKey("sk_test_51HgDLdIgT5WnyGxYtR5CYUXlWdEuPQKip4H5AwD1kuXhH4e0Y47NRC2kDqE8cE3R2fDWWtf7I94gLOJl0PNrHHcb00aRjIX460"); var options = new ChargeCreateOptions { Amount = (long)float.Parse("1000"), Currency = "USD", Description = "charge test 1", Capture = true, Source = stripeToken.Id }; var service = new ChargeService(); Charge charge = service.Create(options); return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); throw ex; } }
public ActionResult StripePayment() { StripeConfiguration.SetApiKey("sk_test_dFDizp08z3Cyn2klQBvAMvOc"); var options = new ChargeCreateOptions { Amount = 999, Currency = "usd", SourceId = "tok_visa", ReceiptEmail = "*****@*****.**", }; var service = new ChargeService(); Charge charge = service.Create(options); var user = User.Identity; ApplicationDbContext db = new ApplicationDbContext(); var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db)); var userID = user.GetUserId(); var loggedInUser = db.Users.Where(u => u.Id == userID).Single(); var userName = loggedInUser.UserName; var userAddress = loggedInUser.Email; //check for user roles //if user is not in role, add him to it if (User.IsInRole("PremiumUser") == false) { UserManager.AddToRole(userID, "PremiumUser"); SendMail(userAddress, userName); Thread.Sleep(2000); } db.SaveChanges(); return(View(charge)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { StripeConfiguration.SetApiKey(Configuration.GetSection("Stripe")["SecretKey"]); ///This line was also added for stripe, also remove it if not working if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseStatusCodePagesWithRedirects("/Home/Error/{0}"); } //Initialize Session app.UseSession(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } StripeConfiguration.SetApiKey(Configuration.GetSection("Stripe")["SecretKey"]); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public IActionResult ExtendSubscriptionStripe([FromBody] StripePaymentRequest paymentRequest) { //Stripe developer api key StripeConfiguration.SetApiKey("sk_test_IhD98M0gMGB1G7rbcHifS3GP"); //configuration of stripe chrarge object var myCharge = new StripeChargeCreateOptions(); myCharge.SourceTokenOrExistingSourceId = paymentRequest.tokenId; myCharge.Amount = paymentRequest.amount; myCharge.Currency = "gbp"; myCharge.Description = paymentRequest.productName; myCharge.Metadata = new Dictionary <string, string>(); myCharge.Metadata["OurRef"] = "OurRef-" + Guid.NewGuid().ToString(); var chargeService = new StripeChargeService(); StripeCharge stripeCharge = chargeService.Create(myCharge); if (stripeCharge.Status.Equals("succeeded")) { TransactionDto transaction = new TransactionDto(); transaction.Amount = (decimal)(paymentRequest.amount / 100.0); transaction.Status = "succeeded"; transaction.CustomerId = 1; transaction.PaymentGatewayId = 1; transaction.PricingPackageId = paymentRequest.packageId; transaction.DateCreated = DateTime.Now; _transactionManipulation.SaveTransaction(transaction); SubscriptionDto subscription = _subscriptionManipulation.GetCustomerSubscription(1); subscription.SubscriptionExpirationDate = subscription.SubscriptionExpirationDate.AddMonths(1); _subscriptionManipulation.UpdateSubscription(subscription); } return(Ok(stripeCharge)); }
public bool SaveCard(string TokenId) { Console.WriteLine(TokenId); StripeConfiguration.SetApiKey("sk_test_sM18FjGmOrWQ550zlR6wlpxs"); var myCustomer = new StripeCustomerCreateOptions(); myCustomer.Email = Session["userEmail"].ToString(); myCustomer.Description = "New User"; myCustomer.SourceToken = TokenId; var customerService = new StripeCustomerService(); StripeCustomer stripeCustomer = customerService.Create(myCustomer); User user = new User(); user = db.Users.Find(Session["userId"]); user.CustomerId = stripeCustomer.Id; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(true); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { StripeConfiguration.SetApiKey(Configuration.GetSection("AppSettings")["StripeSecretKey"]); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "API V1"); }); app.UseCors(x => x .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); app.UseHttpsRedirection(); //app.UseStaticFiles(new StaticFileOptions //{ // FileProvider = new PhysicalFileProvider( //Path.Combine(env.ContentRootPath, "MyStaticFiles")), // RequestPath = "/StaticFiles" //}); app.UseStaticFiles(); app.UseRouting(); app.UseElmah(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
private bool StripeCharge(string stipeEmail, string stripeToken, float amount, string currency, string descr, string secretkey) { // 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 options = new StripeChargeCreateOptions { Amount = int.Parse((amount * 100).ToString()), Currency = currency, Description = descr, SourceTokenOrExistingSourceId = stripeToken, }; var service = new StripeChargeService(); StripeCharge charge = service.Create(options); if (charge.Captured == true) { return(true); } return(false); }
private void ExecutePayment(Player player, ModalForm modal) { StripeConfiguration.SetApiKey("sk_test_****************************"); // Add your API key here double amount = 1.90; var chargeOptions = new StripeChargeCreateOptions() { Amount = (int?)(amount * 100), Currency = "usd", Description = "Charge for [email protected]", SourceCard = new SourceCard() { Number = "4242424242424242", ExpirationMonth = 01, ExpirationYear = 2025, Cvc = "111", Capture = true }, }; var chargeService = new StripeChargeService(); StripeCharge charge = chargeService.Create(chargeOptions); }
public bool CheckFreeTrialPeriod(string sStripeCustomerId) { try { StripeConfiguration.SetApiKey(ConfigurationManager.AppSettings["stripeApi_LiveKey"]); bool blnIsFreeTrialPeriod = false; var customerService = new StripeCustomerService(); StripeCustomer customer = customerService.Get(sStripeCustomerId); if (customer.Subscriptions.FirstOrDefault().TrialEnd > DateTime.Now) { blnIsFreeTrialPeriod = true; } return(blnIsFreeTrialPeriod); } catch (Exception ex) { oLogger.LogData("METHOD: CheckFreeTrialPeriod; ERROR: TRUE; EXCEPTION: " + ex.Message + "; INNER EXCEPTION: " + ex.InnerException + "; STACKTRACE: " + ex.StackTrace); throw; } }
public void Setup() { StripeConfiguration.SetApiKey(LibLogic.Helpers.SiteInfo.StripeAPISecretKey); LibLogic.Helpers.SslSecurity.Callback(); var peterAccount = new LibLogic.Accounts.CreateAccount( new LibLogic.Accounts.CreateAccountInfo() { Email = emailAddress, EmailConfirm = emailAddress, Firstname = "Peter", Lastname = "Gill", Password = "******", PasswordConfirm = "Password1", BetaKey = betaKey } , true, LibLogic.Setup.Email); this.userid = peterAccount.Execute(); CreateToken(); }
public void ConfigureServices(IServiceCollection services) { // Options services.AddOptions(); // Settings var globalSettings = services.AddGlobalSettingsServices(Configuration); services.Configure <BillingSettings>(Configuration.GetSection("BillingSettings")); // Stripe Billing StripeConfiguration.SetApiKey(globalSettings.StripeApiKey); // Repositories services.AddSqlServerRepositories(globalSettings); // Context services.AddScoped <CurrentContext>(); // Identity services.AddCustomIdentityServices(globalSettings); //services.AddPasswordlessIdentityServices<ReadOnlyDatabaseIdentityUserStore>(globalSettings); // Services services.AddBaseServices(); services.AddDefaultServices(globalSettings); services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>(); // Mvc services.AddMvc(config => { config.Filters.Add(new LoggingExceptionHandlerFilterAttribute()); }); services.Configure <RouteOptions>(options => options.LowercaseUrls = true); }
public void ProcessNewCard() { StripeConfiguration.SetApiKey("pk_live_HTl5JEEmjEbq772AbJ3N6Ahl"); WebClient newClient = new WebClient(); var tokenOptions = new Stripe.TokenCreateOptions() { Card = new Stripe.CreditCardOptions() { Number = ccNumber.Text, ExpYear = long.Parse(years[expYear.SelectedIndex]), ExpMonth = long.Parse(months[expMonth.SelectedIndex]), Cvc = cvcLabel.Text } }; var tokenService = new Stripe.TokenService(); try { Stripe.Token stripeToken = tokenService.Create(tokenOptions); var sendingParameters = new System.Collections.Specialized.NameValueCollection(); sendingParameters.Set("newToken", stripeToken.Id); sendingParameters.Set("userID", App.currentUser.systemID); sendingParameters.Set("newLastFour", ccNumber.Text.Substring(12)); sendingParameters.Set("newExpiryDate", months[expMonth.SelectedIndex] + "/" + years[expYear.SelectedIndex]); newClient.UploadValues("http://www.cvx4u.com/web_service/updateCreditCard.php", sendingParameters); App.currentUser.ccLastFour = ccNumber.Text.Substring(12); App.currentUser.ccExpiryDate = months[expMonth.SelectedIndex] + "/" + years[expYear.SelectedIndex]; } catch (StripeException stripeExcept) { Console.WriteLine("errros is " + stripeExcept.StripeError.Message + " " + stripeExcept.StripeError.Code + " " + stripeExcept.StripeError.ErrorDescription); } }
private void CreateRefund(Transaction t) { StripeConfiguration.SetApiKey(Settings.StripeApiKey); var refundService = new StripeRefundService(); var refundOptions = new StripeRefundCreateOptions(); refundOptions.Amount = (int)(t.Amount * 100); var refund = refundService.Create(t.PreviousTransactionNumber, refundOptions); if (refund.Id.Length > 0) { t.Result.Succeeded = true; t.Result.ReferenceNumber = refund.Id; } else { t.Result.Succeeded = false; t.Result.ResponseCode = "FAIL"; t.Result.ResponseCodeDescription = "Stripe Failure"; } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { StripeConfiguration.SetApiKey(Configuration.GetSection("Stripe")["SecretKey"]); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
public static async Task CreateSubscription(string customerId, string planId) { StripeConfiguration.SetApiKey("sk_test_5nCTR2UZmnOPWgZASvirbYDy"); List <StripeSubscriptionItemOption> items = new List <StripeSubscriptionItemOption> { new StripeSubscriptionItemOption { PlanId = planId } }; StripeSubscriptionCreateOptions subscriptionOptions = new StripeSubscriptionCreateOptions { Items = items, BillingCycleAnchor = DateTimeOffset.FromUnixTimeSeconds(1539331009).UtcDateTime, Prorate = true }; StripeSubscriptionService subscriptionService = new StripeSubscriptionService(); StripeSubscription subscription = await subscriptionService.CreateAsync(customerId, subscriptionOptions); await RequiredInvoice(subscription.Id); await UpdateInvoice(await RequiredInvoice(subscription.Id)); }
//ONE-TIME CHARGE public void Charge(ChargeRequest model) { StripeConfiguration.SetApiKey(""); var options = new StripeChargeCreateOptions { Amount = (int)(model.Amount * 100), //Stripe arg in units of cents (usd) Currency = model.Currency, SourceTokenOrExistingSourceId = model.SourceTokenOrExistingSourceId, ReceiptEmail = model.Email }; var service = new StripeChargeService(); StripeCharge charge = service.Create(options); //insert into transaction table TransactionsAddRequest transactionModel = new TransactionsAddRequest { UserBaseId = model.UserBaseId, PlanId = model.PlanId, DurationTypeId = model.DurationTypeId, DiscountPercent = model.DiscountPercent, ChargeId = charge.Id, AmountPaid = model.Amount, Currency = model.Currency, CardId = charge.Source.Card.Id, ExpMonth = charge.Source.Card.ExpirationMonth, ExpYear = charge.Source.Card.ExpirationYear, CardLast4 = charge.Source.Card.Last4, NetworkStatus = charge.Outcome.NetworkStatus, Type = charge.Outcome.Type, isPaid = charge.Paid, CreatedDate = charge.Created }; InsertTransaction(transactionModel); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.EnteringCardData); cardET = FindViewById <EditText>(Resource.Id.cardET); monthET = FindViewById <EditText>(Resource.Id.monthET); yearET = FindViewById <EditText>(Resource.Id.yearET); cvvET = FindViewById <EditText>(Resource.Id.cvvET); activityIndicator = FindViewById <ProgressBar>(Resource.Id.activityIndicator); confirmBn = FindViewById <Button>(Resource.Id.confirmBn); //Secure Background Screen Preview in Xamarin Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure); confirmBn.Click += (s, e) => { activityIndicator.Visibility = ViewStates.Visible; confirmBn.Visibility = ViewStates.Gone; StripeConfiguration.SetApiKey("sk_test_eydXW0qoj2r9kXTVI37uuj94"); var planService = new StripePlanService(); CreateToken(cardET.Text, Convert.ToInt32(monthET.Text), Convert.ToInt32(yearET.Text), cvvET.Text); }; }
public static async Task <List <StripeTransaction> > GetStripePayoutTransactionsAsync(IMyConfiguration configuration, DateTime from, DateTime to) { // get stripe configuration parameters string stripeApiKey = configuration.GetValue("StripeApiKey"); StripeConfiguration.SetApiKey(stripeApiKey); var payoutService = new StripePayoutService(); var allPayoutTransactions = new List <StripePayout>(); var lastId = String.Empty; int MAX_PAGINATION = 100; int itemsExpected = MAX_PAGINATION; while (itemsExpected == MAX_PAGINATION) { IEnumerable <StripePayout> charges = null; if (String.IsNullOrEmpty(lastId)) { charges = await payoutService.ListAsync( new StripePayoutListOptions() { Limit = MAX_PAGINATION, Created = new StripeDateFilter { GreaterThanOrEqual = from, LessThanOrEqual = to } }); itemsExpected = charges.Count(); } else { charges = await payoutService.ListAsync( new StripePayoutListOptions() { Limit = MAX_PAGINATION, StartingAfter = lastId, Created = new StripeDateFilter { GreaterThanOrEqual = from, LessThanOrEqual = to } }); itemsExpected = charges.Count(); } allPayoutTransactions.AddRange(charges); if (allPayoutTransactions.Count() > 0) { lastId = charges.LastOrDefault().Id; } } var stripeTransactions = new List <StripeTransaction>(); foreach (var payoutTransaction in allPayoutTransactions) { // only process the charges that are payouts if (payoutTransaction.Object == "payout") { var stripeTransaction = new StripeTransaction(); stripeTransaction.TransactionID = payoutTransaction.Id; stripeTransaction.Created = payoutTransaction.Created; stripeTransaction.AvailableOn = payoutTransaction.ArrivalDate; stripeTransaction.Paid = (payoutTransaction.Status == "paid"); stripeTransaction.Amount = (decimal)payoutTransaction.Amount / 100; stripeTransaction.Currency = payoutTransaction.Currency; stripeTransaction.Description = payoutTransaction.Description; stripeTransaction.Status = payoutTransaction.Status; stripeTransactions.Add(stripeTransaction); } } return(stripeTransactions); }
public DownloadService(string connection) { _connection = connection; StripeConfiguration.SetApiKey(ConfigurationManager.AppSettings["Stripe.SecretKey"]); }
/// <summary> /// Call this once before using the StripeInvoicingService /// </summary> public static void Configure(string secretKey) { StripeConfiguration.SetApiKey(secretKey); }
public static void PaymentMethod(int amount) { // var amount = 100; //var payment = Stripe.StripeCharge.(amount); try { //use nu-get Stripe //set TLS 1.2 in androuid settings StripeConfiguration.SetApiKey("sk_test_BEPrGyKARA5fbK1rcLbAixdd"); var chargeOptions = new StripeChargeCreateOptions() { Amount = amount, Currency = "eur", SourceTokenOrExistingSourceId = "tok_visa", Metadata = new Dictionary <String, String>() { { "OrderId", "6735" } } }; var chargeService = new StripeChargeService(); StripeCharge charge = chargeService.Create(chargeOptions); } // Use Stripe's library to make request catch (StripeException ex) { switch (ex.StripeError.ErrorType) { case "card_error": System.Diagnostics.Debug.WriteLine(" Code: " + ex.StripeError.Code); System.Diagnostics.Debug.WriteLine("Message: " + ex.StripeError.Message); break; case "api_connection_error": System.Diagnostics.Debug.WriteLine(" apic Code: " + ex.StripeError.Code); System.Diagnostics.Debug.WriteLine("apic Message: " + ex.StripeError.Message); break; case "api_error": System.Diagnostics.Debug.WriteLine("api Code: " + ex.StripeError.Code); System.Diagnostics.Debug.WriteLine("api Message: " + ex.StripeError.Message); break; case "authentication_error": System.Diagnostics.Debug.WriteLine(" auth Code: " + ex.StripeError.Code); System.Diagnostics.Debug.WriteLine("auth Message: " + ex.StripeError.Message); break; case "invalid_request_error": System.Diagnostics.Debug.WriteLine(" invreq Code: " + ex.StripeError.Code); System.Diagnostics.Debug.WriteLine("invreq Message: " + ex.StripeError.Message); break; case "rate_limit_error": System.Diagnostics.Debug.WriteLine(" rl Code: " + ex.StripeError.Code); System.Diagnostics.Debug.WriteLine("rl Message: " + ex.StripeError.Message); break; case "validation_error": System.Diagnostics.Debug.WriteLine(" val Code: " + ex.StripeError.Code); System.Diagnostics.Debug.WriteLine("val Message: " + ex.StripeError.Message); break; default: // Unknown Error Type break; } } }
internal Requestor(StripeConfiguration config) { this.config = config; this.AuthorizationHeaderValue = GetAuthorizationHeaderValue(config.ApiKey); }
public StripeInvoiceItemService(StripeConfiguration config) : base(config) { }
public static async Task <List <StripeTransaction> > GetStripeChargeTransactionsAsync(IMyConfiguration configuration, DateTime from, DateTime to) { // get stripe configuration parameters string stripeApiKey = configuration.GetValue("StripeApiKey"); StripeConfiguration.SetApiKey(stripeApiKey); var chargeService = new StripeChargeService(); chargeService.ExpandBalanceTransaction = true; chargeService.ExpandCustomer = true; chargeService.ExpandInvoice = true; var allCharges = new List <StripeCharge>(); var lastId = String.Empty; int MAX_PAGINATION = 100; int itemsExpected = MAX_PAGINATION; while (itemsExpected == MAX_PAGINATION) { IEnumerable <StripeCharge> charges = null; if (String.IsNullOrEmpty(lastId)) { charges = await chargeService.ListAsync( new StripeChargeListOptions() { Limit = MAX_PAGINATION, Created = new StripeDateFilter { GreaterThanOrEqual = from, LessThanOrEqual = to } }); itemsExpected = charges.Count(); } else { charges = await chargeService.ListAsync( new StripeChargeListOptions() { Limit = MAX_PAGINATION, StartingAfter = lastId, Created = new StripeDateFilter { GreaterThanOrEqual = from, LessThanOrEqual = to } }); itemsExpected = charges.Count(); } allCharges.AddRange(charges); if (allCharges.Count() > 0) { lastId = charges.LastOrDefault().Id; } } var stripeTransactions = new List <StripeTransaction>(); foreach (var charge in allCharges) { // only process the charges that were successfull, aka Paid if (charge.Paid) { var stripeTransaction = new StripeTransaction(); stripeTransaction.TransactionID = charge.Id; stripeTransaction.Created = charge.Created; stripeTransaction.Paid = charge.Paid; stripeTransaction.CustomerEmail = charge.Metadata["email"]; stripeTransaction.OrderID = charge.Metadata["order_id"]; stripeTransaction.Amount = (decimal)charge.Amount / 100; stripeTransaction.Net = (decimal)charge.BalanceTransaction.Net / 100; stripeTransaction.Fee = (decimal)charge.BalanceTransaction.Fee / 100; stripeTransaction.Currency = charge.Currency; stripeTransaction.Description = charge.Description; stripeTransaction.Status = charge.Status; decimal amountRefunded = (decimal)charge.AmountRefunded / 100; if (amountRefunded > 0) { // if anything has been refunded // don't add if amount refunded and amount is the same (full refund) if (stripeTransaction.Amount - amountRefunded == 0) { continue; } else { stripeTransaction.Amount = stripeTransaction.Amount - amountRefunded; stripeTransaction.Net = stripeTransaction.Net - amountRefunded; } } stripeTransactions.Add(stripeTransaction); } } return(stripeTransactions); }
public StripePlanService(StripeConfiguration config) : base(config) { }
public StripeClient(string stripeSecretKey) { StripeConfiguration.SetApiKey(stripeSecretKey); }
public StripeChargeService(StripeConfiguration config) : base(config) { }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { //Initializes ABP framework. app.UseAbp(options => { options.UseAbpRequestLocalization = false; //used below: UseAbpRequestLocalization }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseStatusCodePagesWithRedirects("~/Error?statusCode={0}"); app.UseExceptionHandler("/Error"); } app.UseCors(DefaultCorsPolicyName); //Enable CORS! app.UseAuthentication(); app.UseJwtTokenMiddleware(); if (bool.Parse(_appConfiguration["IdentityServer:IsEnabled"])) { app.UseJwtTokenMiddleware("IdentityBearer"); app.UseIdentityServer(); } app.Use(async(context, next) => { await next(); if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value)) { context.Request.Path = "/index.html"; await next(); } }); app.UseStaticFiles(); using (var scope = app.ApplicationServices.CreateScope()) { if (scope.ServiceProvider.GetService <DatabaseCheckHelper>().Exist(_appConfiguration["ConnectionStrings:Default"])) { app.UseAbpRequestLocalization(); } } app.UseSignalR(routes => { routes.MapHub <AbpCommonHub>("/signalr"); routes.MapHub <ChatHub>("/signalr-chat"); }); if (WebConsts.HangfireDashboardEnabled) { //Hangfire dashboard &server(Enable to use Hangfire instead of default job manager) app.UseHangfireDashboard(WebConsts.HangfireDashboardEndPoint, new DashboardOptions { Authorization = new[] { new AbpHangfireAuthorizationFilter(AppPermissions.Pages_Administration_HangfireDashboard) } }); app.UseHangfireServer(); } if (bool.Parse(_appConfiguration["Payment:Stripe:IsActive"])) { StripeConfiguration.SetApiKey(_appConfiguration["Payment:Stripe:SecretKey"]); } if (WebConsts.GraphQL.Enabled) { app.UseGraphQL <MainSchema>(); if (WebConsts.GraphQL.PlaygroundEnabled) { app.UseGraphQLPlayground( new GraphQLPlaygroundOptions()); //to explorer API navigate https://*DOMAIN*/ui/playground } } app.UseMvc(routes => { routes.MapRoute( name: "defaultWithArea", template: "{area}/{controller=Home}/{action=Index}/{id?}"); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); if (WebConsts.SwaggerUiEnabled) { // Enable middleware to serve generated Swagger as a JSON endpoint app.UseSwagger(); // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.) app.UseSwaggerUI(options => { options.SwaggerEndpoint(_appConfiguration["App:SwaggerEndPoint"], "CoreAngularDemo API V1"); options.IndexStream = () => Assembly.GetExecutingAssembly() .GetManifestResourceStream("CoreAngularDemo.Web.wwwroot.swagger.ui.index.html"); options.InjectBaseUrl(_appConfiguration["App:ServerRootAddress"]); }); //URL: /swagger } }
public StripeEventService(StripeConfiguration config) : base(config) { }
public StripeService(IMailGunEmailSender emailSender) { _emailSender = emailSender; StripeConfiguration.SetApiKey(Environment.GetEnvironmentVariable("STRIPE")); }
public StripeCustomerService(StripeConfiguration config) : base(config) { }