#kronk-subscriptions

1 messages ยท Page 1 of 1 (latest)

wet spire
#

Hello! Starting up a thread for you

#

give me a bit to mess with curl to get this working

vast crystal
#

thanks!

wet spire
#

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 
vast crystal
#

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

wet spire
#

๐Ÿ‘

vast crystal
#

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

hexed urchin
#

Hi, stepping in here as karbi needs to step away. Catching up

vast crystal
#

sure! let me know if there's more context i can provide

hexed urchin
#

What do you mean by 'finalization failures'?

#

What errors are you trying to throw?

vast crystal
#

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?

hexed urchin
#

Essentially, you'd be able to speed up time with this

vast crystal
#

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 ๐Ÿ˜ฆ

hexed urchin
#

Can you share a request id where you've tried this and did not recieve the event?

vast crystal
#

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

hexed urchin
#

I meant where when you were using Test Clocks the expected events were not sent.

#

Yeap, that error on this request is expected.

vast crystal
#

oh, well on test clock my issue was more that i couldn't link it to existing customers or subscriptions

hexed urchin
vast crystal
#

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?

hexed urchin
#

It can only be done when creating the customer, you won't be able to reatroactively apply a test_clock to a customer.

vast crystal
#

darn ok ill make a new customer for this then. thanks again for the help!

vast crystal
#

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

hexed urchin
#

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?

vast crystal
#

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?

hexed urchin
vast crystal
#

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

hexed urchin
#

These objects will exist in your Stripe Dashboard.

vast crystal
#

so back to the original question, is there a way to forcefully create an invoice draft outside of the normal billing cycle?