c# - Stripe .NET 39.45 - Plan 类关联在 Subscription 类上移到了哪里?
问题描述
从 .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,
有谁知道他们将计划移至何处,或者如果我有订阅,具体如何检索计划?这段代码的目的是我想自己做
解决方案
Plan
Subscription
作为39.1.2 的一部分被删除。
您现在需要这样做:
var service = new PlanService();
service.Get("price_1IjsKp2eZvKYlo2C4nz7QGls");
推荐阅读
- reactjs - React Hook 表单 + Material UI 复选框
- html - 如何调整图像大小以适合移动设备?
- fullcalendar - 将日历显示下载为 CSV/XL 文件
- python - 具有多个参数的 Python 函数
- c++ - 私有成员数据不可用于公共成员函数
- javascript - JS:按数组过滤对象数组,当对象键是对象数组时
- android - FileReader 无法从相机读取文件 - Xamarin + WebView
- qt4 - 如何在alpine 3.12中安装qt4
- python - 为什么我的熊猫数据框只占用第一列和最后一列?
- sql - Azure 应用服务无法连接到 Azure SQL 数据库