【发布时间】:2021-07-19 03:05:24
【问题描述】:
从 .Net Core 2.1 升级到 .Net 5(随后将我的 Stripe .net 库升级到 39.45)后,我注意到我的一些代码现在已损坏。我特别收到订阅对象的错误,因为它不再有“计划”对象。在下面的代码中,我有自己的名为“订阅”的内部表,为了方便起见,它实际上包含更多字段。无论如何,看起来他们从 Subscription 类中移动了“Plan”obj 类。
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,
是否有人知道他们将计划移至何处,或者如果我有订阅,具体如何检索计划?这段代码的目的是我想自己做
【问题讨论】:
标签: c# stripe-payments .net-5