add payment error logs (#198)

This commit is contained in:
Petr Kozorezov 2018-04-03 13:47:27 +03:00 committed by GitHub
parent 0b0664b96d
commit a53f1c700f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 13 deletions

View File

@ -1738,16 +1738,15 @@ get_log_params(?payment_started(Payment, _, _, Cashflow), _) ->
event_type => invoice_payment_started
},
make_log_params(Params);
get_log_params(?payment_status_changed({Status, _}), State) ->
Payment = get_payment(State),
Cashflow = get_cashflow(State),
Params = #{
status => Status,
payment => Payment,
cashflow => Cashflow,
event_type => invoice_payment_status_changed
},
make_log_params(Params);
get_log_params(?payment_status_changed(Status), State) ->
make_log_params(
#{
status => Status,
payment => get_payment(State),
cashflow => get_cashflow(State),
event_type => invoice_payment_status_changed
}
);
get_log_params(_, _) ->
undefined.
@ -1791,11 +1790,24 @@ make_log_params(cashflow, CashFlow) ->
Reminders
),
[{accounts, Accounts}];
make_log_params(status, Status) ->
[{status, Status}];
make_log_params(status, {StatusTag, StatusDetails}) ->
[{status, StatusTag}] ++ format_status_details(StatusDetails);
make_log_params(event_type, EventType) ->
[{type, EventType}].
format_status_details(#domain_InvoicePaymentFailed{failure = Failure}) ->
[{error, list_to_binary(format_failure(Failure))}];
format_status_details(_) ->
[].
format_failure({operation_timeout, _}) ->
[<<"timeout">>];
format_failure({failure, Failure}) ->
format_domain_failure(Failure).
format_domain_failure(Failure) ->
payproc_errors:format_raw(Failure).
get_account_key({AccountParty, AccountType}) ->
list_to_binary(lists:concat([atom_to_list(AccountParty), ".", atom_to_list(AccountType)])).

View File

@ -36,7 +36,7 @@
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.0.2">>},2},
{<<"payproc_errors">>,
{git,"git@github.com:rbkmoney/payproc-errors-erlang.git",
{ref,"17e6976c6f05fc2c1adeccaff2b58b4aa99d0181"}},
{ref,"9c720534eb88edc6ba47af084939efabceb9b2d6"}},
0},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.4.0">>},2},
{<<"rfc3339">>,{pkg,<<"rfc3339">>,<<"0.9.0">>},0},