#shainkey

1 messages · Page 1 of 1 (latest)

mighty hemlockBOT
low plinth
#

Where do you see that the subscription will expire after 1 hour?

#

Can you share the doc?

random lily
#

i created the 1 product with recurring payment monthly and i hit the request from my side from API. Where i need to test it should be expire after 1 hour for testing purpose and auto payment again through stripe

#

stripe.Subscription.create(
customer=customer['id'],
items=[
{"price": price_id},
],
payment_behavior="default_incomplete",
collection_method="send_invoice",
days_until_due=30,
)
This is my subscription function

low plinth
#

I see! This one hour refers to moving the invoice status from draft to finalised.

When the collection_method is set to send_invoice, the payment will not be charged automatically. Payment will only be charged automatically with with collection_method: charge_automatically: https://stripe.com/docs/api/subscriptions/create#create_subscription-collection_method

random lily
#

So here we need to pass
collection_method="charge_automatically"
right ?

#

and remove payment_behaviour and days_until_due

nocturne ocean
#

Let's take a step back and think about what you want to do

#

Based on that, we can choose collection_method of charge_automatically or send_invoice

#

I think you have misunderstand about the "1 hour expire" It's not really "expire", it's the time when an Invoice move from draft to finalized

random lily
#

i want to make it charge automatically
First time user will it manually from app(FE)
After that it should be auto renew after 1 month
But for testing purpose i need to test it should be expire in 1 hour and auto renew again

#

if i remove above 2 key
it is showing error This customer has no attached payment source or default payment method.
This is my subs id
sub_1M26T1A1AvSnwwTvdYmm4LKy

#

can u please check once

nocturne ocean
#

So you want to test the 2nd onward billing cycle, whereby generated Invoice has 1 hour draft?

random lily
#

Yes
But not from draft it should be auto renewal by default in 2nd time.
for ex: i buy any subs today after 1 month it will be expire correct so for 2nd month it should be auto renewal from my account.

nocturne ocean
#

Let's don't use the word "expire" because it's confusing

random lily
#

okay sure

nocturne ocean
#

If you have Sub today, on Nov 9, you will pay for the first month immediately. It will renew on Dec 9, and when the time comes, it generates an Invoice in draft state, wait 1 hour, then automatically finalize the Invoice and attempt to charge

random lily
#

okay i got it
So my Subscription function is correct ?
or else we need to modify

#

stripe.Subscription.create(
customer=customer['id'],
items=[
{"price": price_id},
],
payment_behavior="default_incomplete",
collection_method="send_invoice",
days_until_due=30,
)
for testing puporse
can i pass one hour here instead of 30

nocturne ocean
#

Your Subscription was correct because it had collection_method = "send_invoice". This parameter will keep the first Invoice in draft for 1 hour. It's contrast to collection_method="charge_automatically", which will immediately finalize the first Invoice, but let the 2nd onward Invoice has 1 hour

#

days_until_due = 30 is not related to that 1 hour

#

days_until_due = how many days your customer is allowed to pay the Invoice, after it is finalized and sent to your Customer

#

1 hour is the gap before it's finalized

random lily
#

okay
let me check and wait for an hour

#

Thanks

nocturne ocean
#

You can use test clock to accelerate the time

random lily
#

hey for 1 hour exp
is anything we need to set while creating the product?

#

or else i can use test clock

nocturne ocean
#

Just set the clock on the Customer, like above Doc specified

random lily
#

Here what we need to give me simulation time for an hour

nocturne ocean
#

Like I said, 1 hour gap is not related here. You simply create a Test clock simulation, set it to Nov8 20:14 and your Customer will be treat as in Nov8 20:14 forever unless you moving their clock