找不到Stripe.net方法:';作废条纹.条纹客户创建选项.set_Card(条纹.条纹信用卡选项)'

本文关键字:选项 set Card 条纹 信用卡 创建 Stripe 方法 net 找不到 客户 | 更新日期: 2023-09-27 18:01:07

我使用的是最新的Stripe.net版本

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

提高

[MissingMethodException:找不到方法:"Void Stripe.StepeCustomerCreateOptions.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

找不到Stripe.net方法:';作废条纹.条纹客户创建选项.set_Card(条纹.条纹信用卡选项)'

据我所知,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