-
Notifications
You must be signed in to change notification settings - Fork 86
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
Moved code from handler for "account.updated" into StripeConnectAccountService #627
Conversation
else | ||
{:error, %Ecto.Changeset{} = changeset} -> {:error, changeset} | ||
{:error, %Stripe.APIErrorResponse{} = error} -> {:error, error} | ||
_ -> {:error, :unhandled} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is outright error hiding and should go away, so I removed it.
else | ||
{:error, %Ecto.Changeset{} = changeset} -> {:error, changeset} | ||
{:error, %Stripe.APIErrorResponse{} = error} -> {:error, error} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one serves no function. It passes out the error response. Not having this line leaves behavior exactly the same.
else | ||
{:error, %Ecto.Changeset{} = changeset} -> {:error, changeset} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this one means the call in the do
block will just do the same thing automatically.
do | ||
{:ok, updated_account} | ||
account |> StripeConnectAccount.webhook_update_changeset(params) |> Repo.update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call will return {:ok, updated_account}
anyway. No point in first calling it in the with
block, then just passing it through in the do
block.
611f3b9
to
6ed9a91
Compare
6ed9a91
to
8b4ed28
Compare
8b4ed28
to
cf719d9
Compare
What's in this PR?
Figured this out while working on #625
For consistency, I moved the code from the "account.updated" handler into
StripeConnectAccountService.update_from_stripe
.I also removed some
else
cases from all 3 functions there, since they either just propagate the error response (basically doing nothing), or they outright swallow errors.We should also add an issue, good for contributors to add a test for
StripeConnectAccountService.update_from_stripe/1
- created #628