我正试着预告一张按比例收费的发票。
客户在第一天将从30欧元/年的计划更改为65欧元/年的计划(对于按比例分配日期的计算很重要)。
根据此处的文件,应向客户收取:
-老计划剩余时间30欧元
新计划剩余时间65欧元
总共35欧元。下一张发票应该是35欧元。使用java库进行以下调用以获取即将到来的发票:
InvoiceUpcomingParams params = InvoiceUpcomingParams.builder()
.setCustomer(userId)
.setSubscription(subscriptionId)
.addSubscriptionItem(
InvoiceUpcomingParams.SubscriptionItem.builder()
.setId(subscription.getItems().getData().get(0).getId())
.setPrice(priceId)
.build()
).setSubscriptionProrationDate(prorationDate)
.build();
生成的发票具有以下属性:
已付金额:0
应付金额:9999
数量:9999
小计:9999
…和以下发票行(ID已被混淆):
{
"data": [
{
"amount": -3000,
"currency": "eur",
"description": "Unused time on xxxxx after 09 Jan 2021",
"discount_amounts": [],
"discountable": false,
"discounts": [],
"id": "---",
"invoice_item": "---",
"livemode": false,
"metadata": {},
"object": "line_item",
"period": {
"end": 1641756061,
"start": 1610222989
},
"plan": {
"active": true,
"aggregate_usage": null,
"amount": 3000,
"amount_decimal": 3000,
"billing_scheme": "per_unit",
"created": 1598220277,
"currency": "eur",
"deleted": null,
"id": "---",
"interval": "year",
"interval_count": 1,
"livemode": false,
"metadata": {},
"nickname": null,
"object": "plan",
"product": "---",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"price": {
"active": true,
"billing_scheme": "per_unit",
"created": 1598220277,
"currency": "eur",
"deleted": null,
"id": "---",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
"product": "---",
"recurring": {
"aggregate_usage": null,
"interval": "year",
"interval_count": 1,
"trial_period_days": null,
"usage_type": "licensed"
},
"tiers": null,
"tiers_mode": null,
"transform_quantity": null,
"type": "recurring",
"unit_amount": 3000,
"unit_amount_decimal": 3000
},
"proration": true,
"quantity": 1,
"subscription": "---",
"subscription_item": "---",
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
"unified_proration": null
},
{
"amount": 6499,
"currency": "eur",
"description": "Remaining time on xxxx after 09 Jan 2021",
"discount_amounts": [],
"discountable": false,
"discounts": [],
"id": "---",
"invoice_item": "---",
"livemode": false,
"metadata": {},
"object": "line_item",
"period": {
"end": 1641756061,
"start": 1610222989
},
"plan": {
"active": true,
"aggregate_usage": null,
"amount": 6500,
"amount_decimal": 6500,
"billing_scheme": "per_unit",
"created": 1598220248,
"currency": "eur",
"deleted": null,
"id": "---",
"interval": "year",
"interval_count": 1,
"livemode": false,
"metadata": {},
"nickname": null,
"object": "plan",
"product": "---",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"price": {
"active": true,
"billing_scheme": "per_unit",
"created": 1598220248,
"currency": "eur",
"deleted": null,
"id": "---",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
"product": "---",
"recurring": {
"aggregate_usage": null,
"interval": "year",
"interval_count": 1,
"trial_period_days": null,
"usage_type": "licensed"
},
"tiers": null,
"tiers_mode": null,
"transform_quantity": null,
"type": "recurring",
"unit_amount": 6500,
"unit_amount_decimal": 6500
},
"proration": true,
"quantity": 1,
"subscription": "---",
"subscription_item": "---",
"tax_amounts": [],
"tax_rates": [],
"type": "invoiceitem",
"unified_proration": null
},
{
"amount": 6500,
"currency": "eur",
"description": "1 × xxxx (at €65.00 / year)",
"discount_amounts": [],
"discountable": true,
"discounts": [],
"id": "---",
"invoice_item": null,
"livemode": false,
"metadata": {},
"object": "line_item",
"period": {
"end": 1673292061,
"start": 1641756061
},
"plan": {
"active": true,
"aggregate_usage": null,
"amount": 6500,
"amount_decimal": 6500,
"billing_scheme": "per_unit",
"created": 1598220248,
"currency": "eur",
"deleted": null,
"id": "---",
"interval": "year",
"interval_count": 1,
"livemode": false,
"metadata": {},
"nickname": null,
"object": "plan",
"product": "---",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"price": {
"active": true,
"billing_scheme": "per_unit",
"created": 1598220248,
"currency": "eur",
"deleted": null,
"id": "---",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"object": "price",
"product": "---",
"recurring": {
"aggregate_usage": null,
"interval": "year",
"interval_count": 1,
"trial_period_days": null,
"usage_type": "licensed"
},
"tiers": null,
"tiers_mode": null,
"transform_quantity": null,
"type": "recurring",
"unit_amount": 6500,
"unit_amount_decimal": 6500
},
"proration": false,
"quantity": 1,
"subscription": "---",
"subscription_item": "---",
"tax_amounts": [],
"tax_rates": [],
"type": "subscription",
"unified_proration": null
}
],
"has_more": false,
"object": "list",
"request_options": null,
"request_params": null,
"url": "---"
}
简言之,发票行包含以下内容:
2021年1月9日后xx未使用时间:-3000
2021年1月9日后xx剩余时间:6499
1× xx(在€65.00/年):6500
第1期
我认为这是错误的。根据这里的文件,费用应该是:64.99-30=34.99欧元
现在,如果我通过实际订阅更新,stripe生成的发票确实是34.99欧元。因此,我如何调用即将到来的invoiceapi或者它返回什么似乎都有问题。
我错过了什么?我应该自己从应付款项中扣除订阅费吗?
2条答案
按热度按时间ddhy6vgd1#
我可以看到文档示例确实遵循相同的模式。它包含3行。按比例收费2人,实际收费1人。
因此,这是要点,即将到来的发票(在订阅续订日期)将包括按比例收费和新的分期付款费用。
因此,如果我想向我的客户展示下一张发票的样子,如果他们现在升级/降级,我必须手动从响应中减去商品价格。
生成的发票是34.99,因为我大致在即将到来的发票预览修改订阅项目价格的同时发出发票。
hi3rlvi22#
这是即将到来的发票终结点的预期行为。请查看用于预览按比例分配的文档,该文档显示了您在示例结果中看到的相同内容:
您可以展开下面的示例响应以查看:
按第36-38行上一价格计算的未使用时间信用。
第107-109行以新价格花费的时间成本。
第276-279行发票的新小计和合计。
您正在预览即将到来的发票,这意味着它将为当前期间的更改和下一期间的常规金额开具发票。当前期间的变更有两个行项目,下一个期间有一个行项目。
现在,如果我通过实际订阅更新,stripe生成的发票确实是34.99欧元。
听起来您正在进行此更改,然后立即生成发票,而不是等待通常作为订阅结果生成的发票。