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

Minor webhook signing improvements #1107

Merged
merged 2 commits into from
Feb 21, 2018

Conversation

fred-stripe
Copy link
Contributor

Two improvements here:

  • (minor) ConstructEvent now throws a StripeException instead of a generic Exception, which prevents calling code from catching non-SDK related errors when constructing events.
  • (minor) Refactor the test suite to eliminate the EpochUtcNowOverride class member, which was only used by the test suite.

I had to add a couple more constructors to StripeException, as the existing constructor was only for errors during HTTP requests. As a bigger project I'd like to see us leave StripeException as a generic exception and derive an StripeHTTPException class from StripeException, which would cleanly break up the class responsibilities. It'd also allow us to add custom exception formatting and better surface non-200 HTTP responses and API error messages.

r? @ob-stripe
cc @stripe/api-libraries @rpaul-stripe

Copy link
Contributor

@ob-stripe ob-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ob-stripe
Copy link
Contributor

@fred-stripe Great changes -- +1 to removing the special EpochUtcNowOverride attribute and adding a signature to inject the time instead, much cleaner!

@fred-stripe fred-stripe merged commit 6cdf626 into master Feb 21, 2018
@fred-stripe fred-stripe deleted the fred-webhook-signing-improvements branch February 21, 2018 00:05
@ob-stripe
Copy link
Contributor

Released in 13.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants