Skip to content

Explicitly ignore events listed in #609 - #639

Merged
joshsmith merged 2 commits into
developfrom
634-explicitly-ignore-events
Jan 15, 2017
Merged

joshsmith merged 2 commits into
developfrom
634-explicitly-ignore-events

Conversation

@begedin

@begedin begedin commented Jan 15, 2017

Copy link
Copy Markdown
Contributor

What's in this PR?

This PR first reorganizes the WebhookProcessor module so that the environment/livemode filtering goes into its own module.

Then it separates process_async and process so that process can be more easily tested.

Then it extracts the event handling logic from WebhookProcessor into EventHandler, so this can be further and more easily tested, while relying less on StripeTesting (though there is still some reliance.

Lastly, it hooks into EventHandler with a new IgnoredEventHandler module, which is in charge of explicitly ignoring some Stripe event types.

The term explicitly igoring here means

  • The event.status will be set to "ignored"
  • The new event.ignored_reason field will be set to an informative message based on event type.

References

Fixes #634

@begedin
begedin force-pushed the 634-explicitly-ignore-events branch 3 times, most recently from c2169d5 to 484ae4b Compare January 15, 2017 23:24
@begedin

begedin commented Jan 15, 2017

Copy link
Copy Markdown
Contributor Author

Ready for review, I believe. There are 2 commits, but I do not think we should squash, since each of them is a distinct change.

@@ -1,5 +1,5 @@
defmodule CodeCorps.StripeService.Events.AccountUpdated do
def handle(%{"data" => %{"object" => %{"id" => id_from_stripe}}}) do
def handle(%{data: %{object: %{id: id_from_stripe}}}) do

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

One of the changes involved passing in the fetched Stripe.Event into the handlers, instead of the raw json.

@begedin
begedin force-pushed the 634-explicitly-ignore-events branch from 484ae4b to 4124d53 Compare January 15, 2017 23:27
end

@spec get_reason(String.t) :: String.t
defp get_reason("application_fee.created"), do: "Event provides no useful information."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would rewrite to:

"We don't make use of the application fee."

defp get_reason("customer.source.created"), do: "Cards are only created from the client. No need to handle"
defp get_reason("customer.subscription.created"), do: "Subscriptions are only created from the client. No need to handle."
defp get_reason("invoice.created"), do: "Event provides no useful information."
defp get_reason("plan.created"), do: "Plans are only created from the client. No need to handle."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would remove "No need to handle." everywhere.

defp get_reason("customer.created"), do: "Customers are only created from the client. No need to handle."
defp get_reason("customer.source.created"), do: "Cards are only created from the client. No need to handle"
defp get_reason("customer.subscription.created"), do: "Subscriptions are only created from the client. No need to handle."
defp get_reason("invoice.created"), do: "Event provides no useful information."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would rewrite to:

"We prefer to handle other lifecycle events for invoices, like payment_succeeded."

@joshsmith
joshsmith force-pushed the 634-explicitly-ignore-events branch 2 times, most recently from 0cef9b5 to 7711fe6 Compare January 15, 2017 23:47
@joshsmith
joshsmith merged commit 5ff690f into develop Jan 15, 2017
@joshsmith
joshsmith deleted the 634-explicitly-ignore-events branch January 15, 2017 23:51
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.

2 participants