#Matt11-subscription webhooks

1 messages ยท Page 1 of 1 (latest)

sour plank
#

๐Ÿ‘‹ happy to help

grave fulcrum
#

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

sour plank
#

๐Ÿ‘‹ happy to help

grave fulcrum
#

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?

sour plank
#

you can use test clocks

grave fulcrum
#

Ok, I will try. Can I talk to you later if there will be any problem?

sour plank
#

yes sure let me know if you need any more help

grave fulcrum
#

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?

sour plank
#

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?

grave fulcrum
#

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

sour plank
#

I don't follow what you mean by real customer

grave fulcrum
#

a customer already present inside stripe

sour plank
#

it is a real customer in that sense

grave fulcrum
#

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?

sour plank
#

what webhook event are you listening to?

grave fulcrum
#

subscription updated

grave fulcrum
#

how can I import Stripe::TestHelpers into rails application? the stripe gems does not include it?

torn cobalt
#

And you created the subscription with a Checkout Session?

grave fulcrum
#

how can I check this?

torn cobalt
#

can you share the subscription ID?

#

Oh sorry, I mixed two conversation, pease ignore my last 2 messages.

#

I'm taking over tarzan. Could you summarize your question while I try to catchup?

grave fulcrum
#

maybe I sorting this out

#

can I write to you later?