首页 > 解决方案 > 如何使用 Stripe API 计算销售税?

问题描述

我正在按照本指南中的步骤进行结帐流程,因此我可以使用 Stripe 根据国家和邮政编码为我计算销售税。

我按照步骤 3 和 4 创建了一个客户和待定订阅。此时,我想从下面的命令中获取响应,该响应应该告诉我 automatic_tax 状态(完成、requires_location_inputs 或失败)。但是,我得到了一个错误的响应。当我转到我的 Stripe 仪表板时,我确实看到了一张标记为未结的发票。为什么反应不如预期?

命令

curl https://api.stripe.com/v1/invoices/upcoming \
  -u sk_test_<STRIPE API TEST KEY>: \
  -d "customer"="{{ CUSTOMER_ID }}" \
  -d subscription_items[0][price]="{{ PRICE_ID }}" \
  -d subscription_items[0][quantity]=1 \
  -d "automatic_tax[enabled]"=true

输出

{
 "error": {
    "code": "resource_missing",
    "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
    "message": "No such invoice: 'upcoming'",
    "param": "id",
    "type": "invalid_request_error"
  }
}

标签: stripe-payments

解决方案


即将到来的发票端点只是一个GET端点。参考

如果您添加--request GETcurl命令中,那应该可以。它目前正在尝试 POST 以更新 ID 为“即将到来”的现有发票,该发票无效。


推荐阅读