4

I'm using latest Stripe.net version

await SubscriptionsFacade.SubscribeUserAsync(user, planId, taxPercent: taxPercent);

raises

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

Has something changed? I updated to the latest version and now my Stripe.net app is broken. Did Stripe introduce a new way of creating cards?

Here's the full code:

public async Task<ActionResult> Register(RegisterViewModel model)
{
    if (ModelState.IsValid)
    {
        var userIP = GeoLocation.GetUserIP(Request).Split(':').First();
        var user = new ApplicationUser
        {
            UserName = model.Email, 
            Email = model.Email,
            RegistrationDate = DateTime.UtcNow,
            LastLoginTime = DateTime.UtcNow,
            IPAddress = userIP,
            IPAddressCountry = GeoLocationHelper.GetCountryFromIP(userIP),
            BillingAddress = new BillingAddress()
        };
        var result = await UserManager.CreateAsync(user, model.Password);
        if (result.Succeeded)
        {
            // Create Stripe user
            var taxPercent = user.IPAddressCountry != null && EuropeanVat.Countries.ContainsKey(user.IPAddressCountry) ? 
                EuropeanVat.Countries[user.IPAddressCountry] : 0;

            // if no plan set, default to professional
            var planId = string.IsNullOrEmpty(model.SubscriptionPlan)
                ? "starter"
                : model.SubscriptionPlan;

            var customer = new StripeCustomerService();
            var customerInfo = customer.Get(user.CustomerIdentifier);

            await SubscriptionsFacade.SubscribeUserAsync(user, planId, taxPercent: taxPercent);
            await UserManager.UpdateAsync(user);

            await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
            await UserManager.EmailService.SendWelcomeEmail(user.UserName, user.Email);

            TempData["flash"] = new FlashSuccessViewModel("Congratulations! Your account has been created.");

            return RedirectToAction("Index", "Notes");
        }
        AddErrors(result);
    }

    // If we got this far, something failed, redisplay form
    return View(model);
}

and SubscribeUserAsync:

https://github.com/pedropaf/saas-ecom/blob/1370ac169807e97ffb7414610d5be4de4a3cc9ae/SaasEcom.Core/Infrastructure/Facades/SubscriptionsFacade.cs

user299709
  • 4,922
  • 10
  • 56
  • 88

1 Answers1

1

as far as I can tell SubscribeUserAsync is requiring a card with its call.

private async Task<Subscription> SubscribeUserAsync
(SaasEcomUser user, string planId, CreditCard creditCard, int trialInDays = 0, decimal taxPercent = 0)

or

public async Task<Subscription> SubscribeUserAsync
(SaasEcomUser user, string planId, decimal taxPercent = 0, CreditCard creditCard = null)

since you are subscribing a user it probably wants a credit card to go with it. I would add either a card via creating a token or via calling and existing one with

 var customer = new StripeCustomerService();
 var customerInfo = customer.Get(user.CustomerIdentifier);
 //then store card with  customerInfo.DefaultSourceId  somewhere and use it
Alex Rohr
  • 277
  • 4
  • 14
  • well I get compile error around `user.CustomerIdentifier`, I updated my answer for the full controller code – user299709 Aug 05 '16 at 22:35
  • Also I'm not sure how you would store the card (your third line comment), as the stripe user is created on account registration, with no credit card provided from the user. – user299709 Aug 05 '16 at 22:38
  • my user.CustomerIdentifier was attaching the customer's ID to my database and recalling it. you would have to add it to yours – Alex Rohr Aug 07 '16 at 01:08