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

Log only to info on 402 errors from Stripe #874

Merged
merged 1 commit into from
Jun 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion stripe.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,25 @@ func (s *BackendImplementation) ResponseToError(res *http.Response, resBody []by
}
raw.E.Err = typedError

s.LeveledLogger.Errorf("Error encountered from Stripe: %v", raw.E.Error)
// The Stripe API makes a distinction between errors that were caused by
// invalid parameters or something else versus those that occurred
// *despite* valid parameters, the latter coming back with status 402.
//
// On a 402, log to info so as to not make an integration's log noisy with
// error messages that they don't have much control over.
//
// Note I use the constant 402 here instead of an `http.Status*` constant
// because technically 402 is "Payment required". The Stripe API doesn't
// comply to the letter of the specification and uses it in a broader
// sense.
if res.StatusCode == 402 {
s.LeveledLogger.Infof("User-compelled request error from Stripe: %v",

Choose a reason for hiding this comment

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

I find the wording here a bit confusing. Maybe a standard format could help, along the lines of:

“Stripe request GET /blah returned 402 User Error: Invalid Card Expiration”

With method, path, status, status text and error message being placeholders?

raw.E.Error)
} else {
s.LeveledLogger.Errorf("Request error from Stripe: %v",
raw.E.Error)
}

return raw.E.Error
}

Expand Down