I am following the steps from this guide for my checkout process so I can use Stripe to calculate the sales tax for me based on the country and postal code.
I created a customer and pending subscription as per steps 3 and 4. At this point, I want to get the response from the command below which should tell me the automatic_tax status (complete, requires_location_inputs, or failed). However, I get an error in response instead. When I go to my Stripe dashboard, I do see an invoice that is marked as open. Why is the response not as expected?
COMMAND
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
OUTPUT
{
"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"
}
}
The upcoming invoice endpoint is a GET
endpoint only. Ref
If you add --request GET
to your curl
command, that should work. It's currently trying to POST to update an existing invoice with id 'upcoming' which is not valid.