#Matt11-subscription webhooks
1 messages ยท Page 1 of 1 (latest)
Hello, thanks! For a customer I have this configuration.
We have customers registered on the platform who pay for year subscription and everything is made with stripe subscriptions
When stripe do some logic everything is updated on our database with webhooks
๐ happy to help
we changed some webhooks logic so I need to test it with a real case scenario, meaning that I need to create a user with an active subscription and the "force" the subscription to end triggering the update
Obviously it's impossible to wait 1 year to test it so I thought to create a plan with expiration 24h
So, two questions:
1- is it possible to create a plan with expiration 1 or 2 hours?
2- if not, how can I test the end of a subscription?
Ok, I will try. Can I talk to you later if there will be any problem?
yes sure let me know if you need any more help
I have a question
I read that you can't use a real customer during a simulation
but I need to write informations on my database, how can I link a stripe customer to my customer if I don't have the stripe_customer_id?
I read that you can't use a real customer during a simulation
what do you mean by this?
how are you integrating with Stripe?
with apis
I do this
email: email,
description: full_name.to_s,
source: params[:stripeToken]
)```
and then save on my database table 'users' the stripe_customer_id for the user
and I create a subscription
customer: stripe_customer_id,
payment_behavior: 'allow_incomplete',
items: [{
plan: stripe_plan_id.to_s
}],
trial_from_plan: true
}```
and save the stripe_subscription_id inside my subscriptions table
but If you cannot use a real customer, how can I test the webhooks?
they are going to write data without match on my database
I don't follow what you mean by real customer
a customer already present inside stripe
it is a real customer in that sense
no because I cannot test the webhook correctly.
This is my flow:
- the user signup in my platform and insert the card details
- with APIs I create a customer and a subscription on Stripe
- on my database I update the customer with the new stripe_customer_id and I create a custom_subscription with the new stripe_subscription_id
When Stripe trigger the webhooks I'm going to update the custom_subscription with the stripe_subscription_id inside the params
If the test_clock are not using a customer/subscription already present, how the webhooks can update the correct custom_subscription?
what webhook event are you listening to?
subscription updated
how can I import Stripe::TestHelpers into rails application? the stripe gems does not include it?
And you created the subscription with a Checkout Session?
how can I check this?