使用stripe[java]预览具有按比例分配问题的即将发布的发票

wswtfjt7  于 2021-07-06  发布在  Java
关注(0)|答案(2)|浏览(386)

我正试着预告一张按比例收费的发票。
客户在第一天将从30欧元/年的计划更改为65欧元/年的计划(对于按比例分配日期的计算很重要)。
根据此处的文件,应向客户收取:
-老计划剩余时间30欧元
新计划剩余时间65欧元
总共35欧元。下一张发票应该是35欧元。使用java库进行以下调用以获取即将到来的发票:

  1. InvoiceUpcomingParams params = InvoiceUpcomingParams.builder()
  2. .setCustomer(userId)
  3. .setSubscription(subscriptionId)
  4. .addSubscriptionItem(
  5. InvoiceUpcomingParams.SubscriptionItem.builder()
  6. .setId(subscription.getItems().getData().get(0).getId())
  7. .setPrice(priceId)
  8. .build()
  9. ).setSubscriptionProrationDate(prorationDate)
  10. .build();

生成的发票具有以下属性:
已付金额:0
应付金额:9999
数量:9999
小计:9999
…和以下发票行(ID已被混淆):

  1. {
  2. "data": [
  3. {
  4. "amount": -3000,
  5. "currency": "eur",
  6. "description": "Unused time on xxxxx after 09 Jan 2021",
  7. "discount_amounts": [],
  8. "discountable": false,
  9. "discounts": [],
  10. "id": "---",
  11. "invoice_item": "---",
  12. "livemode": false,
  13. "metadata": {},
  14. "object": "line_item",
  15. "period": {
  16. "end": 1641756061,
  17. "start": 1610222989
  18. },
  19. "plan": {
  20. "active": true,
  21. "aggregate_usage": null,
  22. "amount": 3000,
  23. "amount_decimal": 3000,
  24. "billing_scheme": "per_unit",
  25. "created": 1598220277,
  26. "currency": "eur",
  27. "deleted": null,
  28. "id": "---",
  29. "interval": "year",
  30. "interval_count": 1,
  31. "livemode": false,
  32. "metadata": {},
  33. "nickname": null,
  34. "object": "plan",
  35. "product": "---",
  36. "tiers": null,
  37. "tiers_mode": null,
  38. "transform_usage": null,
  39. "trial_period_days": null,
  40. "usage_type": "licensed"
  41. },
  42. "price": {
  43. "active": true,
  44. "billing_scheme": "per_unit",
  45. "created": 1598220277,
  46. "currency": "eur",
  47. "deleted": null,
  48. "id": "---",
  49. "livemode": false,
  50. "lookup_key": null,
  51. "metadata": {},
  52. "nickname": null,
  53. "object": "price",
  54. "product": "---",
  55. "recurring": {
  56. "aggregate_usage": null,
  57. "interval": "year",
  58. "interval_count": 1,
  59. "trial_period_days": null,
  60. "usage_type": "licensed"
  61. },
  62. "tiers": null,
  63. "tiers_mode": null,
  64. "transform_quantity": null,
  65. "type": "recurring",
  66. "unit_amount": 3000,
  67. "unit_amount_decimal": 3000
  68. },
  69. "proration": true,
  70. "quantity": 1,
  71. "subscription": "---",
  72. "subscription_item": "---",
  73. "tax_amounts": [],
  74. "tax_rates": [],
  75. "type": "invoiceitem",
  76. "unified_proration": null
  77. },
  78. {
  79. "amount": 6499,
  80. "currency": "eur",
  81. "description": "Remaining time on xxxx after 09 Jan 2021",
  82. "discount_amounts": [],
  83. "discountable": false,
  84. "discounts": [],
  85. "id": "---",
  86. "invoice_item": "---",
  87. "livemode": false,
  88. "metadata": {},
  89. "object": "line_item",
  90. "period": {
  91. "end": 1641756061,
  92. "start": 1610222989
  93. },
  94. "plan": {
  95. "active": true,
  96. "aggregate_usage": null,
  97. "amount": 6500,
  98. "amount_decimal": 6500,
  99. "billing_scheme": "per_unit",
  100. "created": 1598220248,
  101. "currency": "eur",
  102. "deleted": null,
  103. "id": "---",
  104. "interval": "year",
  105. "interval_count": 1,
  106. "livemode": false,
  107. "metadata": {},
  108. "nickname": null,
  109. "object": "plan",
  110. "product": "---",
  111. "tiers": null,
  112. "tiers_mode": null,
  113. "transform_usage": null,
  114. "trial_period_days": null,
  115. "usage_type": "licensed"
  116. },
  117. "price": {
  118. "active": true,
  119. "billing_scheme": "per_unit",
  120. "created": 1598220248,
  121. "currency": "eur",
  122. "deleted": null,
  123. "id": "---",
  124. "livemode": false,
  125. "lookup_key": null,
  126. "metadata": {},
  127. "nickname": null,
  128. "object": "price",
  129. "product": "---",
  130. "recurring": {
  131. "aggregate_usage": null,
  132. "interval": "year",
  133. "interval_count": 1,
  134. "trial_period_days": null,
  135. "usage_type": "licensed"
  136. },
  137. "tiers": null,
  138. "tiers_mode": null,
  139. "transform_quantity": null,
  140. "type": "recurring",
  141. "unit_amount": 6500,
  142. "unit_amount_decimal": 6500
  143. },
  144. "proration": true,
  145. "quantity": 1,
  146. "subscription": "---",
  147. "subscription_item": "---",
  148. "tax_amounts": [],
  149. "tax_rates": [],
  150. "type": "invoiceitem",
  151. "unified_proration": null
  152. },
  153. {
  154. "amount": 6500,
  155. "currency": "eur",
  156. "description": "1 × xxxx (at €65.00 / year)",
  157. "discount_amounts": [],
  158. "discountable": true,
  159. "discounts": [],
  160. "id": "---",
  161. "invoice_item": null,
  162. "livemode": false,
  163. "metadata": {},
  164. "object": "line_item",
  165. "period": {
  166. "end": 1673292061,
  167. "start": 1641756061
  168. },
  169. "plan": {
  170. "active": true,
  171. "aggregate_usage": null,
  172. "amount": 6500,
  173. "amount_decimal": 6500,
  174. "billing_scheme": "per_unit",
  175. "created": 1598220248,
  176. "currency": "eur",
  177. "deleted": null,
  178. "id": "---",
  179. "interval": "year",
  180. "interval_count": 1,
  181. "livemode": false,
  182. "metadata": {},
  183. "nickname": null,
  184. "object": "plan",
  185. "product": "---",
  186. "tiers": null,
  187. "tiers_mode": null,
  188. "transform_usage": null,
  189. "trial_period_days": null,
  190. "usage_type": "licensed"
  191. },
  192. "price": {
  193. "active": true,
  194. "billing_scheme": "per_unit",
  195. "created": 1598220248,
  196. "currency": "eur",
  197. "deleted": null,
  198. "id": "---",
  199. "livemode": false,
  200. "lookup_key": null,
  201. "metadata": {},
  202. "nickname": null,
  203. "object": "price",
  204. "product": "---",
  205. "recurring": {
  206. "aggregate_usage": null,
  207. "interval": "year",
  208. "interval_count": 1,
  209. "trial_period_days": null,
  210. "usage_type": "licensed"
  211. },
  212. "tiers": null,
  213. "tiers_mode": null,
  214. "transform_quantity": null,
  215. "type": "recurring",
  216. "unit_amount": 6500,
  217. "unit_amount_decimal": 6500
  218. },
  219. "proration": false,
  220. "quantity": 1,
  221. "subscription": "---",
  222. "subscription_item": "---",
  223. "tax_amounts": [],
  224. "tax_rates": [],
  225. "type": "subscription",
  226. "unified_proration": null
  227. }
  228. ],
  229. "has_more": false,
  230. "object": "list",
  231. "request_options": null,
  232. "request_params": null,
  233. "url": "---"
  234. }

简言之,发票行包含以下内容:
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或者它返回什么似乎都有问题。
我错过了什么?我应该自己从应付款项中扣除订阅费吗?

ddhy6vgd

ddhy6vgd1#

我可以看到文档示例确实遵循相同的模式。它包含3行。按比例收费2人,实际收费1人。
因此,这是要点,即将到来的发票(在订阅续订日期)将包括按比例收费和新的分期付款费用。
因此,如果我想向我的客户展示下一张发票的样子,如果他们现在升级/降级,我必须手动从响应中减去商品价格。
生成的发票是34.99,因为我大致在即将到来的发票预览修改订阅项目价格的同时发出发票。

hi3rlvi2

hi3rlvi22#

这是即将到来的发票终结点的预期行为。请查看用于预览按比例分配的文档,该文档显示了您在示例结果中看到的相同内容:
您可以展开下面的示例响应以查看:
按第36-38行上一价格计算的未使用时间信用。
第107-109行以新价格花费的时间成本。
第276-279行发票的新小计和合计。
您正在预览即将到来的发票,这意味着它将为当前期间的更改和下一期间的常规金额开具发票。当前期间的变更有两个行项目,下一个期间有一个行项目。
现在,如果我通过实际订阅更新,stripe生成的发票确实是34.99欧元。
听起来您正在进行此更改,然后立即生成发票,而不是等待通常作为订阅结果生成的发票。

相关问题