在这种情况下,我非常想在数据库中获取发票ID,或者我基本上可以获取可放入数据库中的发票URL。客户可以在哪里领取发票。
我发现只有在创建发票后,我才可以下载将要使用或创建后的网址。
基本上,错误是我已经尝试了几个小时才能找到如何检索发票的URL,或者只是将要获取的发票URL索回数据库。
>var token = model.Source;
var trailDay = PricRules.PayUser.TrailDay;
var createCustomer = new CustomerCreateOptions
{
Source = token,
Email = userClass.Mail,
Name = userClass.FullName,
Description = $"UserId: {userClass.UserId} - CVR: {business.Cvr} - Navn: {business.Name} - TrailDay: {trailDay}"
};
var addService = new CustomerService();
var customer = await addService.CreateAsync(createCustomer);
var optionsProduct = new ProductCreateOptions
{
Name = $"Medlemskab - Brugerid: {userClass.UserId}",
Type = "service",
};
var serviceProduct = new ProductService();
Product product = serviceProduct.Create(optionsProduct);
var optionsPlan = new PlanCreateOptions
{
Currency = "dkk",
Interval = Stripe.interval,
Nickname = $"Medlemskab - InterVal: {Stripe.interval} Name: {userClass.FullName} - {DateTime.Now}",
Amount = amount,
Product = product.Id,
IntervalCount = getPriceClass.Month,
};
var servicePlan = new PlanService();
Plan plan = servicePlan.Create(optionsPlan);
var items = new List<SubscriptionItemOptions>()
{
new SubscriptionItemOptions()
{
Plan = plan.Id
}
};
var createSubscruption = new SubscriptionCreateOptions
{
Customer = customer.Id,
TrialEnd = new AnyOf<DateTime?, SubscriptionTrialEnd>(DateTime.Now.AddDays(trailDay)),
Items = items,
OffSession = true
};
var Addservice = new SubscriptionService();
Subscription subscription = Addservice.Create(createSubscruption);
var invoiceLink = ""; // HOW TO GET INVOICE URL/LINK HER? or Invoice Id
如您在代码底部所见。因此,基本上不管我是否获得发票ID还是URL。我知道我是如何使用它们的。
答案 0 :(得分:0)
您不会立即获得发票链接,因为它取决于首先付款的尝试。
您应该设置一个Webhook来监听invoice.created
事件。每个事件将包含一个invoice
对象,您可以从中访问客户的ID,订阅的ID和发票的链接,从而为您提供足够的信息以将发票链接回正确的客户。