mirror of
https://github.com/valitydev/fistful-server.git
synced 2024-11-06 02:35:18 +00:00
TD-690: Fix withdrawal session finalization by notify (#67)
* fixed * removed legacy call * renamed
This commit is contained in:
parent
eecd4c823d
commit
09f6cccba9
@ -163,9 +163,6 @@
|
||||
| {unavailable_status, status()}}
|
||||
| ff_adjustment:create_error().
|
||||
|
||||
-type finalize_session_error() ::
|
||||
{wrong_session_id, session_id()}.
|
||||
|
||||
-type unknown_adjustment_error() :: ff_adjustment_utils:unknown_adjustment_error().
|
||||
|
||||
-type invalid_status_change_error() ::
|
||||
@ -200,7 +197,7 @@
|
||||
|
||||
%%
|
||||
|
||||
-export([process_session_finished/3]).
|
||||
-export([finalize_session/3]).
|
||||
|
||||
%% Accessors
|
||||
|
||||
@ -228,8 +225,6 @@
|
||||
-export([get_quote/1]).
|
||||
-export([is_finished/1]).
|
||||
|
||||
-export([finalize_session/3]).
|
||||
|
||||
-export([start_adjustment/2]).
|
||||
-export([find_adjustment/2]).
|
||||
-export([adjustments/1]).
|
||||
@ -573,9 +568,9 @@ format_activity(Activity) ->
|
||||
|
||||
%%
|
||||
|
||||
-spec process_session_finished(session_id(), session_result(), withdrawal_state()) ->
|
||||
-spec finalize_session(session_id(), session_result(), withdrawal_state()) ->
|
||||
{ok, process_result()} | {error, session_not_found | old_session | result_mismatch}.
|
||||
process_session_finished(SessionID, SessionResult, Withdrawal) ->
|
||||
finalize_session(SessionID, SessionResult, Withdrawal) ->
|
||||
case get_session_by_id(SessionID, Withdrawal) of
|
||||
#{id := SessionID, result := SessionResult} ->
|
||||
{ok, {undefined, []}};
|
||||
@ -992,18 +987,6 @@ create_session(ID, TransferData, SessionParams) ->
|
||||
ok
|
||||
end.
|
||||
|
||||
-spec finalize_session(session_id(), session_result(), withdrawal_state()) ->
|
||||
{ok, process_result()} | {error, finalize_session_error()}.
|
||||
finalize_session(SessionID, Result, Withdrawal) ->
|
||||
case {session_id(Withdrawal), get_current_session_status(Withdrawal)} of
|
||||
{SessionID, pending} ->
|
||||
{ok, {continue, [{session_finished, {SessionID, Result}}]}};
|
||||
{SessionID, _} ->
|
||||
{ok, {undefined, []}};
|
||||
_OtherSessionID ->
|
||||
{error, {wrong_session_id, SessionID}}
|
||||
end.
|
||||
|
||||
-spec process_session_sleep(withdrawal_state()) -> process_result().
|
||||
process_session_sleep(_Withdrawal) ->
|
||||
{sleep, []}.
|
||||
|
@ -86,8 +86,7 @@
|
||||
-type session_result() :: ff_withdrawal_session:session_result().
|
||||
|
||||
-type call() ::
|
||||
{start_adjustment, adjustment_params()}
|
||||
| {session_finished, session_id(), session_result()}.
|
||||
{start_adjustment, adjustment_params()}.
|
||||
|
||||
-define(NS, 'ff/withdrawal_v2').
|
||||
|
||||
@ -184,8 +183,6 @@ process_timeout(Machine, _, _Opts) ->
|
||||
-spec process_call(call(), machine(), handler_args(), handler_opts()) -> no_return().
|
||||
process_call({start_adjustment, Params}, Machine, _, _Opts) ->
|
||||
do_start_adjustment(Params, Machine);
|
||||
process_call({session_finished, SessionID, SessionResult}, Machine, _, _Opts) ->
|
||||
do_process_session_finished(SessionID, SessionResult, Machine);
|
||||
process_call(CallArgs, _Machine, _, _Opts) ->
|
||||
erlang:error({unexpected_call, CallArgs}).
|
||||
|
||||
@ -215,17 +212,6 @@ do_start_adjustment(Params, Machine) ->
|
||||
{Error, #{}}
|
||||
end.
|
||||
|
||||
-spec do_process_session_finished(session_id(), session_result(), machine()) -> {Response, result()} when
|
||||
Response :: ok | {error, session_not_found | old_session | result_mismatch}.
|
||||
do_process_session_finished(SessionID, SessionResult, Machine) ->
|
||||
St = ff_machine:collapse(ff_withdrawal, Machine),
|
||||
case ff_withdrawal:process_session_finished(SessionID, SessionResult, withdrawal(St)) of
|
||||
{ok, Result} ->
|
||||
{ok, process_result(Result, St)};
|
||||
{error, _Reason} = Error ->
|
||||
{Error, #{}}
|
||||
end.
|
||||
|
||||
process_result({Action, Events}, St) ->
|
||||
genlib_map:compact(#{
|
||||
events => set_events(Events),
|
||||
|
Loading…
Reference in New Issue
Block a user