2016-08-05 70 views
3

我使用的是最新版本的Stripe.netStripe.net方法: '无效Stripe.StripeCustomerCreateOptions.set_Card(Stripe.StripeCreditCardOptions)'

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

提高

[MissingMethodException:方法找不到:'虚空Stripe.StripeCustomerCreateOptions.set_Card(Stripe.StripeCreditCardOptions)'。]

有什么改变?我更新到最新版本,现在我的Stripe.net应用程序已损坏。 Stripe是否引入了创建卡片的新方法?

下面是完整的代码:

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); 
} 

和SubscribeUserAsync:

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

+0

添加或者是卡我不确定他们是否更新它多一些,但是我们可不可以看到多一点的是认购代码在你的控制? –

+0

@Alex罗尔我更新我的回答,显示控制器代码 – user299709

回答

1

据我可以告诉SubscribeUserAsync是需要具有其呼叫卡。

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

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

因为您订阅它可能想要一个信用卡去用它的用户。我将通过创建一个标志或通过打电话和现有的与

var customer = new StripeCustomerService(); 
var customerInfo = customer.Get(user.CustomerIdentifier); 
//then store card with customerInfo.DefaultSourceId somewhere and use it 
+0

现在正在测试这一点.... – user299709

+0

以及我得到编译左右'user.CustomerIdentifier',我更新了我的答案全控制器代码 – user299709

+0

错误另我不是请确定您将如何存储卡(您的第三行注释),因为条形码用户是在帐户注册时创建的,并且没有用户提供信用卡。 – user299709