Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New webhook triggers for subscriptions and customers #440

Closed
mnida opened this issue Jan 13, 2023 · 9 comments · Fixed by #539
Closed

New webhook triggers for subscriptions and customers #440

mnida opened this issue Jan 13, 2023 · 9 comments · Fixed by #539
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed request New feature or request

Comments

@mnida
Copy link
Collaborator

mnida commented Jan 13, 2023

Is your feature request related to a problem? Please describe.
Users want webhooks for these events:

  • when a subscription ends/is cancelled
  • when a subscription is created
  • when a subscription is renewed
  • customer created

Describe the solution you'd like
In the backend add this webhook functionality using our alerts framework and svix.

In the frontend simply add the checkbox in the create webhook url form.

@mnida mnida added request New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Jan 13, 2023
@djanda97
Copy link
Contributor

djanda97 commented Jan 25, 2023

Hi @mnida!

If this issue is still available, I would like to work on it. After cloning the repo and poking around the codebase for a while, I found a few files that look like a good starting point for adding new webhooks.

Backend:

Frontend:

Do you have a recommendation for other files (either backend or frontend) to look into that will require editing for adding new webhooks?

Cheers,
David

@mnida
Copy link
Collaborator Author

mnida commented Jan 26, 2023

@djanda97 Great! Yep this issue is still available! You should be all set on the frontend side beside that DeveloperTab you pointed out.

Looping in @diego-escobedo to check if there is anything else on the backend.

@diego-escobedo
Copy link
Collaborator

diego-escobedo commented Jan 26, 2023

Hey David! Sorry for the late response, missed this one. Looks like the right path for the backend. I'll add in a few other things you might find useful.

  • Webhooks need to be registered with the webhooks server (Svix) before being used, here's where we do it in the code:
    if SVIX_CONNECTOR is not None:
    Should be pretty plug and play
  • https://raw.githubusercontent.com/uselotus/lotus/442db21387ebaf47c65d6bf2fdb569d12abcd97d/docs/webhooks/webhooks.mdx the current documentation page we have for webhooks. Unfortunately, we don't have a great way of displaying the schema for the response objects in our mintlify docs atm, so what we do is: Run management command python manage.py generate_schema, copy paste the openapi spec into a different openapi renderer, and screenshot it. In the case of an existing response schema (like we have for invoices), we just link them to the appropriate place in the docs.

In terms of where you'd actually be putting the x_webhook() calls imported from the webhooks file:

Doing all of the webhooks at once might be too much to chew off / review in a single PR, so perhaps spinning them out one issue at a time might end up being easier.

Let me know if you need any more details or if you're curious about how the webhooks work in more detail! Happy to discuss.

@djanda97
Copy link
Contributor

Thanks for the info! I agree that trying to implement all the new webhooks would be a bit much to tackle in a single PR, so I'll start with the customer created webhook & reach out when I have any questions after diving into the code!

@mnida
Copy link
Collaborator Author

mnida commented Feb 7, 2023

Hey @djanda97 checking in to see how the issue is going?

@djanda97
Copy link
Contributor

Hi @mnida, so far so good! I've created a draft PR that registers the customer created webhook with the webhook server (svix) and adds it to the WEBHOOK_TRIGGER_EVENTS class. The bulk of the implementation is something I plan to get to this upcoming week.

@mnida
Copy link
Collaborator Author

mnida commented Feb 10, 2023

Great! Awesome to hear and excited to review next week.

@djanda97
Copy link
Contributor

Is your feature request related to a problem? Please describe. Users want webhooks for these events:

* when a subscription ends/is cancelled

* when a subscription is created

* when a subscription is renewed

* customer created

Describe the solution you'd like In the backend add this webhook functionality using our alerts framework and svix.

In the frontend simply add the checkbox in the create webhook url form.

Now that #539 is merged, could the subscription related webhooks be split up into different issues so that they could be worked on individually? I would be interested in implementing a few more now that I've done it once before and know the general locations where code would need to be added 😄

@mnida
Copy link
Collaborator Author

mnida commented Feb 21, 2023

Yeah! @djanda97 Feel free to create some more issues, we treated this one as just customer-created. You can use the same issue format and create and self-assign to as many as you are up for!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants