Skip to content

Commit

Permalink
Add outcome to charge view
Browse files Browse the repository at this point in the history
  • Loading branch information
nkezhaya committed Jun 9, 2019
1 parent 1bc93d7 commit 51441ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/stripe_mock/api/charge.ex
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ defmodule StripeMock.API.Charge do
validate_required(changeset, :source_id)

{nil, _source_id} ->
case source do
case source |> IO.inspect() do
%{card: %{customer_id: nil}} -> changeset
_ -> validate_required(changeset, :customer_id)
end
Expand Down
12 changes: 12 additions & 0 deletions lib/stripe_mock_web/views/charge_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,21 @@ defmodule StripeMockWeb.ChargeView do
description: charge.description,
metadata: charge.metadata,
object: "charge",
outcome: render_outcome(charge),
source: render(StripeMockWeb.CardView, "card.json", card: charge.source),
statement_descriptor: charge.statement_descriptor,
transfer_group: charge.transfer_group
}
end

defp render_outcome(_charge) do
%{
network_status: "approved_by_network",
reason: nil,
risk_level: "normal",
risk_score: 0,
seller_message: "Approved by network.",
type: "authorized"
}
end
end

0 comments on commit 51441ec

Please sign in to comment.