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

fix: remove param casting to atom [BREAKING CHANGE] #807

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions lib/stripe/error.ex
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ defmodule Stripe.Error do
extra: %{
optional(:card_code) => card_error_code,
optional(:decline_code) => String.t(),
optional(:param) => atom,
optional(:param) => String.t(),
optional(:charge_id) => Stripe.id(),
optional(:http_status) => 400..599,
optional(:raw_error) => map,
Expand Down Expand Up @@ -163,7 +163,7 @@ defmodule Stripe.Error do
%{raw_error: error_data, http_status: status}
|> maybe_put(:card_code, error_data |> Map.get("code") |> maybe_to_atom())
yordis marked this conversation as resolved.
Show resolved Hide resolved
|> maybe_put(:decline_code, error_data |> Map.get("decline_code"))
|> maybe_put(:param, error_data |> Map.get("param") |> maybe_to_atom())
|> maybe_put(:param, Map.get(error_data, "param"))
|> maybe_put(:charge_id, error_data |> Map.get("charge"))

%__MODULE__{
Expand Down
2 changes: 1 addition & 1 deletion test/stripe/error_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ defmodule Stripe.ErrorTest do
error = Error.from_stripe_error(400, error_data, "id")
assert error.code == :invalid_request_error
assert error.extra.http_status == 400
assert error.extra.param == :type
assert error.extra.param == "type"
assert error.extra.raw_error == error_data
assert error.message == "Received unknown parameter: type"
assert error.request_id == "id"
Expand Down
Loading