C# Stripe.NET 39.45-订阅类上的计划类关联移动到了哪里?
在从.NETCore2.1升级到.NET5(随后将我的Stripe.Net库升级到39.45)之后,我注意到我的一些代码现在被破坏了。我在subscription对象上特别遇到了一个错误,因为它不再有“Plan”对象。在下面的代码中,我有自己的名为“Subscription”的内部表,为了方便起见,该表实际上还包含几个字段。不管怎样,看起来他们把“Plan”obj类从Subscription类移走了C# Stripe.NET 39.45-订阅类上的计划类关联移动到了哪里?,c#,stripe-payments,.net-5,C#,Stripe Payments,.net 5,在从.NETCore2.1升级到.NET5(随后将我的Stripe.Net库升级到39.45)之后,我注意到我的一些代码现在被破坏了。我在subscription对象上特别遇到了一个错误,因为它不再有“Plan”对象。在下面的代码中,我有自己的名为“Subscription”的内部表,为了方便起见,该表实际上还包含几个字段。不管怎样,看起来他们把“Plan”obj类从Subscription类移走了 var service = new SubscriptionSe
var service = new SubscriptionService();
var subscription = service.Get(successInvoice.SubscriptionId);
if (subscription != null)
{
var internalCustomer = _dbContext.Customers.First();
var internalSubscription = _dbContext.Subscriptions.FirstOrDefault(s => s.ExternalSubscriptionId == subscription.Id);
if (internalCustomer != null)
{
//If the subscription does not exist, it means this is the first time they are being charged
//and a new subscription must be added as well
if (internalSubscription == null)
{
internalSubscription = new Business.Entities.Billing.Subscription
{
CustomerId = internalCustomer.Id,
Customer = internalCustomer,
ExternalProductId = subscription.Plan.ProductId,
Amount = subscription.Plan.AmountDecimal.Value / 100,
Interval = subscription.Plan.Interval,
IntervalCount = subscription.Plan.IntervalCount,
ExternalSubscriptionId = subscription.Id
};
//Add this new subscription
_dbContext.Subscriptions.Add(internalSubscription);
_dbContext.SaveChanges();
}
因此,这些代码行抛出了错误:
ExternalProductId = subscription.Plan.ProductId,
Amount = subscription.Plan.AmountDecimal.Value / 100,
Interval = subscription.Plan.Interval,
IntervalCount = subscription.Plan.IntervalCount,
是否有人知道他们将计划移动到了哪里,或者特别知道如果我有订阅,如何检索计划?此代码的目的是我想制定自己的
计划
已从订阅
中删除
您现在需要执行以下操作:
啊,很有趣,谢谢。现在再次提醒我,从哪里获取价格(传递到函数中的字符串Id)?此代码驻留在if的my webhook中(stripeEvent.Type==“invoice.payment\u successed”)。谢谢你抽出时间来帮忙!您可以在其位置使用
计划
ID。
var service = new PlanService();
service.Get("price_1IjsKp2eZvKYlo2C4nz7QGls");