Giter Site home page Giter Site logo

pedropaf / saas-ecom Goto Github PK

View Code? Open in Web Editor NEW
100.0 19.0 41.0 4.18 MB

Subscription support for ASP.NET MVC 5 apps using Stripe, including out-of-the-box view helpers. Available via NuGET

Home Page: http://www.saasecom.org

License: Apache License 2.0

C# 56.12% PowerShell 30.34% Pascal 12.21% JavaScript 1.09% Batchfile 0.25%

saas-ecom's People

Contributors

corymcm avatar pedropaf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

saas-ecom's Issues

Object reference required for non-static field

I am going through the tutorial here: http://code.tutsplus.com/tutorials/building-a-note-taking-software-as-a-service-using-aspnet-mvc-5-stripe-and-azure--cms-22922

In my Register post method, I have added:

await SubscriptionsFacade.SubscribeUserAsync(user, "Small");

But SubscribeUserAsync is not static so the call fails. Do I need to create a SubscriptionsFacade object somewhere?

EDIT: Just read down a little and realise I need to add the property! Sorry!

Missing required param: source.

Hello,

I keep getting the error message above. I am trying to add the card to stripe before creating the users subscription.

private StripeCard AddCardToStripe(CreditCard card, string stripeCustomerId)
{
var options = new StripeCardCreateOptions
{
Source = new StripeSourceOptions
{
TokenId = card.StripeToken
}
}; //nothing is picked up here i.e. the token is not being passed in.

        var requestOptions = new StripeRequestOptions
        {
            ApiKey = _apiKeyRequest,
            IdempotencyKey = IdempotencyKey,
            StripeConnectAccountId = StripeConnectAccountId        
        };

        return _cardService.Create(stripeCustomerId, options, requestOptions);
    }

Any help would be great, thanks.

Upgrade SaasEcom

Can you upgrade the API to use the latest version of the Stripe API??

There's no plan with Id

Could this be because I'm testing on local?

I pointed stripe credentials and everything.

I get:

There's no plan with Id: starter

when I register.

GetCountryFromIP fails when running locally

If you're running locally and using IPv6 then the call to GeoLocation.GetCountryFromIP will fail since the IP will be an empty string.

I changed this to:

IPAddressCountry = string.IsNullOrEmpty(userIP) ? null : GeoLocationHelper.GetCountryFromIP(userIP),

To get everything running locally.

Note that this was for the MyNotes example.

Roles changed

Hi,

I have just implemented saas-scom into my project. I was using roles to differentiate between different user roles but it seems to have broken this.

In my AspNetUserRoles table, I now have a SaasEcomUser_Id field which is used by SaasEcomUser to get the role.

In my code, I set the role when someone registers using the following code:

var roleStore = new RoleStore<IdentityRole>(context);
var roleManager = new RoleManager<IdentityRole>(roleStore);

var userStore = new UserStore<ApplicationUser>(context);
var userManager = new UserManager<ApplicationUser>(userStore);
userManager.AddToRole(user.Id, "Manager");

Now, This sets the UserId of AspNetUserRoles instead of the SaasEcomUser_Id and therefore my roles no longer get picked up when logging in.

Is there are way to set the SaasEcomUser_Id using my method above?

Thanks!

Missing documentation on IDbContext<ApplicationUser>

Hi there,

I followed your steps to get up and running but after the "it should now build without problems" I did have a problem: Your billing controller threw errors - I wasn't implementing your IDbContext in my ApplicationDbContext (I've extracted this class from the default Model it's placed in for better readability.

Please add this instruction for others :)

Can't Build, 3 Errors

I followed the blog post here http://www.pedroalonso.net/blog/2014/11/13/saas-ecom-available-in-nuget/

I am getting these three errors

Error 1 'SaasEcom.Core.Infrastructure.Facades.SubscriptionsFacade' does not contain a constructor that takes 4 arguments C:\Code\GitHub\aircss\aircss\Controllers\AccountController.cs 64 72 aircss

Error 2 'aircss.Models.ApplicationUser' does not contain a definition for 'CreatedAt' C:\Code\GitHub\aircss\aircss\Controllers\AccountController.cs 173 95 aircss

Error 3 'SaasEcom.Core.Infrastructure.Facades.SubscriptionsFacade' does not contain a definition for 'SubscribeNewUserAsync' and no extension method 'SubscribeNewUserAsync' accepting a first argument of type 'SaasEcom.Core.Infrastructure.Facades.SubscriptionsFacade' could be found (are you missing a using directive or an assembly reference?) C:\Code\GitHub\aircss\aircss\Controllers\AccountController.cs 186 71 aircss

Any help is appreciated

Stripe.StripeException: This customer has no attached payment source

Hi guys,

Stripe.net: 2.9.0.0

On register process we got an error from the backend. This caused because we need to attach a credit card to the customer when creating it on Stripe.

public async Task CreateCustomerAsync(RevolustoreUser user, string planId = null, DateTime? trialEnd = null, string cardToken = null)
{
var customer = new StripeCustomerCreateOptions
{
AccountBalance = 0,
Email = user.Email
};

        if (!string.IsNullOrEmpty(cardToken))
        {
            customer.Card = new StripeCreditCardOptions
            {
                TokenId = cardToken
            };
        }

        if (!string.IsNullOrEmpty(planId))
        {
            customer.PlanId = planId;
            customer.TrialEnd = trialEnd;
        }

        var stripeUser = await Task.Run(() => _customerService.Create(customer));
        return stripeUser;
    }

The exception throw when we call _customerService.Create(customer).

Any answer.

Nice, but can't see how it can support 'admin' users

This is really nice, if you didn't have admin users -
I can't see how this model / structure could support admin users?

The IdentityUser is of type SaasEcomUser - this doesn't lend itself very well to an over-seeing admin user?

Any ideas?

Add support for .NET Core? :)

Might just be me being an idiot, but i can't get this to work with ASP.NET MVC 6 on .NET Core, seems to be ambiguous references to old versions of the identity service or something.

Any plans on porting to .net core?

Method not found: 'Void Stripe.StripeCustomerCreateOptions.set_Card

So I updated Stripe.net to the latest version because I was getting the "Stripe doesn't support TLS 1.0" error.

However, now I'm getting

Method not found: 'Void Stripe.StripeCustomerCreateOptions.set_Card(Stripe.StripeCreditCardOptions)'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MissingMethodException: Method not found: 'Void Stripe.StripeCustomerCreateOptions.set_Card(Stripe.StripeCreditCardOptions)'.

Source Error:

Line 200: : model.SubscriptionPlan;
Line 201:
Line 202: await SubscriptionsFacade.SubscribeUserAsync(user, planId, taxPercent: taxPercent);
Line 203: await UserManager.UpdateAsync(user);
Line 204:

Source File: C:\Users\bob\Documents\Visual Studio 2015\Projects\saas-ecom-my-notes-sample-master\saas-ecom-my-notes-sample-master\MyNotes\Controllers\AccountController.cs Line: 202

Stack Trace:

[MissingMethodException: Method not found: 'Void Stripe.StripeCustomerCreateOptions.set_Card(Stripe.StripeCreditCardOptions)'.]
SaasEcom.Core.Infrastructure.PaymentProcessor.Stripe.d__5.MoveNext() +0
System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.Start(TStateMachine& stateMachine) +60 SaasEcom.Core.Infrastructure.PaymentProcessor.Stripe.CustomerProvider.CreateCustomerAsync(SaasEcomUser user, String planId, Nullable1 trialEnd, String cardToken) +121
SaasEcom.Core.Infrastructure.Facades.d__0.MoveNext() +347
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
System.Runtime.CompilerServices.TaskAwaiter1.GetResult() +28 MyNotes.Controllers.<Register>d__18.MoveNext() in C:\Users\bob\Documents\Visual Studio 2015\Projects\saas-ecom-my-notes-sample-master\saas-ecom-my-notes-sample-master\MyNotes\Controllers\AccountController.cs:202 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58 System.Runtime.CompilerServices.TaskAwaiter.GetResult() +26 System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task) +42 System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +73 System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +37 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +27
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +68 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +34 System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +69 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +230 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +27 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +27
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +68 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +34 System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +42 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +124 System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult asyncResult) +27
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +29 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +27 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +32 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +26 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +40
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +58 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +24 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +27 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +58
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +30
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +21
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +29
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +23
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +129

No Attached payment source for Trial plan

I'm testing a subscription plan with a 14 day trial. I set up the plan on the stripe dashboard. When I create a stripe customer and subscribe them to the plan, I get a response about no payment source:

Stripe::InvalidRequestError: This customer has no attached payment source

Using rails - here's the code

    def create_stripe_customer
      @stripe_customer = Stripe::Customer.create(
        :email => @user.email,
      )
      @user.update_attributes(stripe_customer_id: @stripe_customer.id)
    end

    def subscripe_patient_to_plan
      Stripe::Subscription.create(
        :customer => @user.stripe_customer_id,
        :items => [
          {
            :plan => "weekly-text-with-trial",
          },
        ],
      )
    end

screen shot 2017-12-11 at 4 50 47 pm

Is this expected behavior? According to the docs it shouldn't be an issue.

Invoice Paid Webhook Fails

This was when running the MyNotes example. Not sure if it applies to the core code.

BillingAddress is defined as a [ComplexType] which means it has to be initialised (even if it's properties are null). The current code will fail because Invoice.BillingAddress is null:

Null value for non-nullable member. Member: 'BillingAddress'.

I guess (looking at the MyNotes example) that the solution would be to grab the user's current billing address and attach this to the invoice before saving. This would require a way to obtain the User from the Stripe Customer Id. As a temporary fix I did the following:

                case "invoice.payment_succeeded": // Occurs whenever an invoice attempts to be paid, and the payment succeeds.
                    StripeInvoice stripeInvoice = Stripe.Mapper<StripeInvoice>.MapFromJson(stripeEvent.Data.Object.ToString());
                    Invoice invoice = SaasEcom.Core.Infrastructure.Mappers.Map(stripeInvoice);
                    if (invoice != null && invoice.Total > 0)
                    {
                        // TODO get the customer billing address
                        // get the customer billing address
                        // for now we still have to instantiate the address on the invoice
                        invoice.BillingAddress = new BillingAddress();

                        await InvoiceDataService.CreateOrUpdateAsync(invoice);

                        // TODO: Send invoice by email

                    }
                    break;

Personally I'm not a fan of the dependency on ASP.NET Identity and Entity Framework which is why I probably can't use this library. That said, it's a great point of reference!

Both the latest NuGet and Demo site YSOD

Hi,

just installed the NuGet packages and when trying to add a credit card, I get:

Server Error in '/' Application.
You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Stripe.StripeException: You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/.

Source Error:
Line 205: {
Line 206: var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
Line 207: await CardService.AddAsync(user, model.CreditCard);
Line 208:
Line 209: // TempData.Add("flash", new FlashSuccessViewModel("Your credit card has been saved successfully."));

This happens on your live demo site as well (peeking at your Elmah log):
Host Code Type Error User Date Time
RD000D3A108AAF 0 Stripe You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/. Details…

Any ideas how to fix this?

Thanks.

Registration Fails

The SaasEcomUser class defines non-nullable RegistrationDate and LastLoginDate properties. Anyone installing saas-ecom into their project will need to update their Registration action to define the user as below:

var user = new ApplicationUser { UserName = model.Email, Email = model.Email, RegistrationDate = DateTime.UtcNow, LastLoginTime = DateTime.UtcNow  };

Worth mentioning this on the docs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.