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

Support unknown webhook events #85

Merged
merged 3 commits into from
Dec 2, 2024
Merged

Support unknown webhook events #85

merged 3 commits into from
Dec 2, 2024

Conversation

danbillson
Copy link
Contributor

Related to issue: #80

There are some webhook events that are no longer supported but there is still a use for them, some of the other SDKs have the concept of a generic event which is not explicitly handled or typed, this PR also introduces a GenericEvent which will not have any typing so it will be on the implementation to ignore or cast the types.

The recommended usage for this will be to handle the webhook as you would anything else but intervene with any ts suggestions i.e.

    switch (event?.eventType) {
      case EventName.SubscriptionCreated:
           // handle subscribtion created event

      // @ts-ignore
      case "invoice.paid":
          // handle invoice paid event as a generic event

To follow inline with the rest of the webhook events, the keys of the event object have been completely transformed to use camel case

@danbillson danbillson requested a review from a team as a code owner December 2, 2024 11:43
@danbillson danbillson self-assigned this Dec 2, 2024
@vifer vifer changed the title Support legacy webhook events Support unknown webhook events Dec 2, 2024
@danbillson danbillson merged commit 9d441c5 into main Dec 2, 2024
6 checks passed
@danbillson danbillson deleted the unknown-webhooks branch December 2, 2024 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants