【发布时间】:2021-06-01 12:08:30
【问题描述】:
现在我正在尝试在审核购买后创建发票。
如果客户购买了会员资格,我希望将发票 ID 分配给我的数据库,因为 webhook 能够通过链接将 pdf 发票分配给数据库。
当我尝试在代码中最后生成发票时。然后我不幸遇到了这个错误。
无需为订阅开具发票
当我查看 Stripe 日志时,这来自错误。
{
"error": {
"code": "invoice_no_subscription_line_items",
"doc_url": "https://stripe.com/docs/error-codes/invoice-no-subscription-line-items",
"message": "Nothing to invoice for subscription",
"param": "subscription",
"type": "invalid_request_error"
}
}
因此,我的请求 POST 正文是这样的:
{
"customer": "cus_J2ltIOWhr2BSGX",
"subscription": "sub_J2lto4EVvcfToq"
}
在这里你可以看到我如何发布请求到条带。
var createCustomer = new CustomerCreateOptions
{
Source = token,
Name = model.FuldName,
Email = model.Mail
};
var addService = new CustomerService();
var customer = await addService.CreateAsync(createCustomer);
var optionsProduct = new ProductCreateOptions
{
Name = $"Membership - {DateTime.Now}",
Type = "service",
};
var serviceProduct = new ProductService();
Product product = await serviceProduct.CreateAsync(optionsProduct);
var optionsA = new PriceCreateOptions
{
UnitAmount = amount,
Currency = "dkk",
Recurring = new PriceRecurringOptions
{
Interval = Helpers.Stripe.interval,
},
Product = product.Id,
};
var serviceA = new PriceService();
var price = await serviceA.CreateAsync(optionsA);
var options = new SubscriptionCreateOptions
{
Customer = customer.Id,
Items = new List<SubscriptionItemOptions>
{
new SubscriptionItemOptions
{
Price = price.Id,
},
},
};
var service = new SubscriptionService();
var subscription = await service.CreateAsync(options);
var optionsI = new InvoiceCreateOptions
{
Customer = customer.Id,
Subscription = subscription.Id
};
var serviceI = new InvoiceService();
var invoice = await serviceI.CreateAsync(optionsI);//I NEED INVOICE ID FROM HERE!
我试着看这里。
Adding shipping to first subscription invoice using stripe
EIDT:
var createCustomer = new CustomerCreateOptions
{
Source = token,
Name = model.FuldName,
Email = model.Mail
};
var addService = new CustomerService();
var customer = addService.Create(createCustomer);
var options = new ChargeCreateOptions
{
Amount = amount,
Currency = "dkk",
Description = $"Købt kursus {DateTime.Now}",
Customer = customer.Id,
};
var service = new ChargeService();
Charge charge = service.Create(options);
【问题讨论】:
标签: c# stripe-payments