FF-82 Add exists session error handling (#80)

This commit is contained in:
Andrey Fadeev 2019-04-24 17:09:20 +03:00 committed by GitHub
parent 433f9dcde6
commit 907cfced48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -428,7 +428,7 @@ create_session(Withdrawal) ->
destination => destination_id(Withdrawal), destination => destination_id(Withdrawal),
provider_id => ProviderID provider_id => ProviderID
}, },
ok = unwrap(ff_withdrawal_session_machine:create(ID, TransferData, SessionParams)), ok = create_session(ID, TransferData, SessionParams),
{continue, [{session_started, ID}]} {continue, [{session_started, ID}]}
end). end).
@ -439,6 +439,14 @@ construct_session_id(ID) ->
construct_p_transfer_id(ID) -> construct_p_transfer_id(ID) ->
<<"ff/withdrawal/", ID/binary>>. <<"ff/withdrawal/", ID/binary>>.
create_session(ID, TransferData, SessionParams) ->
case ff_withdrawal_session_machine:create(ID, TransferData, SessionParams) of
ok ->
ok;
{error, exists} ->
ok
end.
poll_session_completion(Withdrawal) -> poll_session_completion(Withdrawal) ->
SessionID = ff_transfer:session_id(Withdrawal), SessionID = ff_transfer:session_id(Withdrawal),
{ok, SessionMachine} = ff_withdrawal_session_machine:get(SessionID), {ok, SessionMachine} = ff_withdrawal_session_machine:get(SessionID),