#kronk-subscriptions
1 messages ยท Page 1 of 1 (latest)
Hello! Starting up a thread for you
give me a bit to mess with curl to get this working
thanks!
You want something like this
curl https://api.stripe.com/v1/subscriptions \
-u <SECRET KEY>: \
-d customer=<CUSTOMER ID> \
-d "items[0][price_data][currency]"=usd \
-d "items[0][price_data][unit_amount]"=1500 \
-d "items[0][price_data][product]"=<PRODUCT ID> \
-d "items[0][price_data][tax_behavior]"=exclusive \
-d "items[0][price_data][recurring][interval]"=day \
-d "items[0][price_data][recurring][interval_count]"=1
ah that worked, thanks!
sorry one more follow up, is there a way to create the subscription object such that tax is automatically calculated for the first invoice?
oh nevermind i see the automatic_tax field now
๐
Is there a way to speed up the subscription invoicing process for testing? For context, I'm trying to test an end to end flow for invoice finalization failures, so through the above command I was able to attach a customer with no address to a subscription. The problem I'm running into now is if I specify automatic_tax[enabled]=true on the POST body the entire request fails, so I have to create a subscription with manual tax collection.
I'm hoping now to create a draft + finalize it to induce an error, but creating the draft returns a 400 because there's no pending items to finalize
Hi, stepping in here as karbi needs to step away. Catching up
sure! let me know if there's more context i can provide
i'm testing the invoice.finalization_failed webhook event, so trying to get a customer with an unrecognized location (according to this guide: https://stripe.com/docs/tax/customer-locations#handling-errors) to subscribe to a resource and finalize an invoice
i'm trying to do an E2E test with a specific customer + resource to see how our webhook handling logic fares, so i'm not able to use the Stripe CLI to trigger this event. i asked in a previous thread for advice and was pointed towards using the API to construct an unrecognized location situation
so far i have a customer with no address, they're subscribed to a resource, and im wondering if there's a faster iteration speed for drafting -> finalizing invoices so i don't have to wait an entire day for the next billing cycle?
I see. I think the Test Clocks, https://stripe.com/docs/api/test_clocks is something that would benefit this testing. Have you tried this?
Essentially, you'd be able to speed up time with this
I tried test clocks previously but I didn't have any luck with having it send the downstream webhook events to the listeners we have ๐ฆ
Can you share a request id where you've tried this and did not recieve the event?
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_Vzj5qpqypWknHY
This is the ID for the request that I mentioned previously, where it 400'd due to not having any pending items to add to an invoice draft
I meant where when you were using Test Clocks the expected events were not sent.
Yeap, that error on this request is expected.
oh, well on test clock my issue was more that i couldn't link it to existing customers or subscriptions
You'd need to pass the test_clock id when creating the customer, https://stripe.com/docs/billing/testing/test-clocks?dashboard-or-api=api#setup-simulation . Here is the full guideline on how to use Test Clocks: https://stripe.com/docs/billing/testing/test-clocks
ohhh i completely missed this documentation, ill take a look. thank you!
is it possible to attach a test clock retroactively on customers? or can it only happen via API upon creation?
It can only be done when creating the customer, you won't be able to reatroactively apply a test_clock to a customer.
darn ok ill make a new customer for this then. thanks again for the help!
sorry last question, can you subscribe the customer to a subscription that already exists? or do you need to make a brand new one?
i tried passing in a subscription that already exists and the call seems to have no-oped
You can add the same price to a customer twice to create 2 different subscriptions. I'm unsure what you mean by subscribe the customer to a subscription that already exists, can you clarify?
since i'm trying to test E2E, I have published subscriptions I created via Stripe Checkout (outside of test clock). Am I able to subscribe a test clock customer to those resources?
No, you'd need to set up the simulation by creating the subscription, https://stripe.com/docs/billing/testing/test-clocks?dashboard-or-api=api#setup-simulation
oh, in that case i don't think i can use test clock for my use case
i'd like to test existing customers and subscriptions, since those are created via our website and we have the data representations for those objects locally as well
if I create everything through test clock then i wouldn't have the corresponding object locally, so then when test clock triggers webhook events it would just no-op through our handler since those resources don't exist in our DB
These objects will exist in your Stripe Dashboard.
so back to the original question, is there a way to forcefully create an invoice draft outside of the normal billing cycle?