2016-08-05 72 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