#pratikco - test clocks
1 messages · Page 1 of 1 (latest)
Hey there
Yep so you can set trial_end to any timestamp you want
There is no minimum
Any timestamp in the future from the creation timestamp
ohh ok got you means, subscription_data = {
trial_end : time_stamp
} like this right?
but what will be the format of timestamp?
It is a UNIX timestamp
Of a UNIX timestamp?
yeah
You can use something like: https://www.epochconverter.com/
To convert
Manually
To see what it would look like
thanyou so much
Sure thing
I am getting this error
Hmm that shouldn't be the case afaik
Can you drop me that request ID?
That is in the error
req_gRjG5YWvxJUAvS
Hello! I'm taking over and catching up...
The error message on that request is accurate. The timestamp you specified is only about five hours from now, which is less than the minimum of two days required.
actually i want to test if free trail code work or not
if i give min 2 days then i have to wait for 2 days to check if its working or not
You can manipulate time in test mode using Test Clocks: https://stripe.com/docs/billing/testing/test-clocks
got it thanks
when making a session to create payment I am not creating any customer, but in response from stripe I am getting a customer id I think stripe is creating it for me but the thing is whenever user stop the subscription and after some month he resumes it, do I need to use same customer id or no need
do you think I should store customer id of strip to customer table for use?
You should use the same Customer ID, yes.
Customers in Stripe are required for Subscriptions, and they're designed to represent your customers. Using them will make a lot of things easier, like keeping track of activity over time for a given person.
Not sure I understand?
you from, I mean your country
I'm in the United States.
Yep!
ohh nice
can you please tell me how to create customer and pass it into payment session
This is the API to create a Customer: https://stripe.com/docs/api/customers/create
When you say "payment session" are you referring to a Checkout Session?
yep
When you create the Checkout Session you can specify a Customer ID in the customer property: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer
hey I didn't find any attribute to provide customer_id in payment session in this link
like customer_id : 232323723
checkout_session = stripe.checkout.Session.create(
payment_method_types=["card"],
line_items=[
{
"price": price["id"],
"quantity": 1,
}
],
metadata={
"user_id": request.user.id,
"art_price": art_price,
"amount": amount,
},
mode="subscription",
success_url='http://127.0.0.1:8000/success' + "?session_id={CHECKOUT_SESSION_ID}",
cancel_url='http://127.0.0.1:8000/failed/',
subscription_data=subscription_data,
)
my code is like this, from that link I am not clear where to provide customer id details
You add it in the list of options you provide.
So you would add something like customer=customerID in there.
I written a code for free trial successfully with your help, but
if event['type'] == 'checkout.session.completed': this event will not trigger for free trial session?
👋 I'm hopping in since rubeus needs to head out soon - I believe that event would still be triggered with a free trial. are you seeing otherwise?
Hi I created one user and assigned 2-day free trial to it now I want to check what will happen after 2 days, to that particular user account can i check it?
What specifically do you want to check?
after 2 days stripe will make payment from that account and it will trigger payment event on webhook so that my code will run in that event and user get some credit credited to their account, so I want to check will this work or not
should I explain it propely again?
No, I see what you're trying to do - the way to really test this is by using Test Clocks, which allows you to move forward in time to preview actions that happen in the future (like when trials end) https://stripe.com/docs/billing/testing/test-clocks
yeah, but I want to test this with this particular customer only which I just created and assign a trial trial to it, can I do it?
If I use clock I will get this option in which i have to add new user, But I only want to test with my one particular user which I create by my backend
Yeah with test clocks you can't add them to exisitng customers, you'd have to create the customer with the test clock from the start, and then use that customer in a checkout session
yeah, so there is no way to check existing user
Correct - there is no way to use test clocks with an existing customer that does not already have a test clock
ok thanks for letting me know