From 51441ecb57920e344a959dfd9b8845049174bf0f Mon Sep 17 00:00:00 2001 From: Nick Kezhaya Date: Sun, 9 Jun 2019 17:46:36 -0500 Subject: [PATCH] Add outcome to charge view --- lib/stripe_mock/api/charge.ex | 2 +- lib/stripe_mock_web/views/charge_view.ex | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/stripe_mock/api/charge.ex b/lib/stripe_mock/api/charge.ex index 0dc45f8..0ee120b 100644 --- a/lib/stripe_mock/api/charge.ex +++ b/lib/stripe_mock/api/charge.ex @@ -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 diff --git a/lib/stripe_mock_web/views/charge_view.ex b/lib/stripe_mock_web/views/charge_view.ex index 5c560e5..92826f3 100644 --- a/lib/stripe_mock_web/views/charge_view.ex +++ b/lib/stripe_mock_web/views/charge_view.ex @@ -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