如何使用 Stripe API 计算销售税?

How to get sales tax calculations with Stripe API?

我在结帐过程中遵循此 guide 中的步骤,因此我可以使用 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"
  }
}

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

如果您将 --request GET 添加到您的 curl 命令,那应该可以。它目前正在尝试 POST 到 update an existing invoice,ID 'upcoming' 无效。